Skip to content

Instantly share code, notes, and snippets.

@xpqz
Created December 3, 2020 08:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xpqz/916827a8ac4983958f60f768f35f0d83 to your computer and use it in GitHub Desktop.
Save xpqz/916827a8ac4983958f60f768f35f0d83 to your computer and use it in GitHub Desktop.
Advent of Code 2020, Day03 in Dyalog APL
⎕IO←0
DAY03←↑⊃⎕NGET'data/2020/day03.txt'1
Slope←{
(dy dx)←⍵
d←⍺
0 {
(y x)←⍵
y≥0⊃⍴d:⍺
(⍺+'#'=d[y;(1⊃⍴d)|x])∇dy dx + y x
} 0 0
}
⊢result←DAY03∘Slope¨(1 1)(1 3)(1 5)(1 7)(2 1)
assert 203=1⊃result ⍝ Part 1
assert 3316272960=×/result ⍝ Part 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment