Advent Of Code 2022

I’ve done the first two days of advent of code in apl. Anyone else participating?

I am also thinking of trying K as an alternative array language.

gist

1 Like

I am working on it also. I just published day 1 and 2.

1 Like

Day 3 is published with explanation in the code in the same post here

f ← (⎕A,⍨⎕C ⎕A)∘⍳¨⊃⎕NGET'day3_input.txt'1
part1 ← +/1↑¨{(2÷⍨⍴¨⍵) (↑∩↓)¨ ⍵} f
part2 ← +/1↑¨∩/{(3÷⍨≢⍵)3⍴⍵}f

You may find Parsing content from text files using Dyalog APL's ⎕CSV - YouTube and Advent of Code - APL Wiki useful.

2 Likes

I just posted my day 4 solution, and that video was immediately useful! Thinking of a file like today’s as a CSV, with a nested CSV file with a different separator in it is not at all how I am used to thinking about file structures.

I’m enjoying doing these problems in APL this reason - I have to think differently than I am accustomed to in order to solve them with APL effectively :slight_smile:

1 Like

I needed the nested csv for day 5 as well. I’ve also used the ignore columns reduction from another example in the same video.

1 Like

I ended up using it for day 5 also.

APL cart was really helpful today. I needed to get rid of spaces and the function labeled “Remove leading, trailing and duplicate blanks” was just what I needed.