Created
December 15, 2021 13:14
-
-
Save xpqz/75a25a23365da82448cbbe47ce46c1c4 to your computer and use it in GitHub Desktop.
AoC 2021, day 15, Dyalog APL
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
⎕IO←0 | |
'wpath'⎕cy'dfns' | |
d←↑⍎¨¨⊃⎕NGET'../d/15'1 | |
shifts←{(⍺,2⊣/⍵)(2⊢/⍵,⍺)(2⊢⌿⍵⍪⍺)(⍺⍪2⊣⌿⍵)} | |
day15←{ | |
nnnn←{⍵~¯1}¨,↓2 0 1⍉↑¯1shifts(⍴⍵)⍴(⍳×/⍴⍵) | |
flat←∊⍵ | |
values←{flat[⍵]}¨nnnn | |
graph←↑(nnnn)(values) | |
path←graph wpath 0 (¯1+≢flat) | |
+/1↓flat[path] | |
} | |
day15 d | |
merge←{((⍴×⍴∘⊃)⍴0 2 1 3⍉↑)⍵} | |
day15 9@(⍸0=9|mddd)⊢9|mddd←merge (5 5⍴⊂d)+∘.+⍨⍳5 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment