Created
December 12, 2022 06:43
-
-
Save LdBeth/6489c8ac56603d08653c44eb3e2e5685 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
⎕CR 'part2' | |
res←part2 map;n;p;i;e;x;hist | |
p←path height map | |
e←1=height map | |
i←{'E'=⍵}map | |
hist←i | |
x←0 | |
Loop: | |
x+←1 | |
hist⌈←x×i | |
i←(∨/({mask/,⍵}⌺3 3⊢i)∧p)∧~×hist | |
→(0=+/,i)/Err | |
→(∨/,i∧e)⍴End | |
→Loop | |
End: | |
res←x | |
→0 | |
Err: | |
'Error' | |
x | |
res←hist | |
⎕cr 'path' | |
path←{{(b<c)∨1≥|(b←mask/,⍵)-c←center/,⍵}⌺3 3⊢10+⍵} | |
⎕cr 'height' | |
height←{26@(28∘=)1@(27∘=)((⎕C ⎕A),'SE')⍳⍵} | |
mask | |
0 1 0 1 0 1 0 1 0 | |
center | |
0 0 0 0 1 0 0 0 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment