input =: ,.LF cut fread '~/code/advent_of_code/day_12.txt' | |
i =: 0 j. 1 | |
move =: 1 0 0;0 1 0;(,&0 1) | |
turn =: 1 0 0;;&0 0 1@(0,(,&0)) | |
F =: 1 0 0;0 0 1(;~)0(,~)1&(,~) | |
E =: move@(1&*) | |
N =: move@(i&*) | |
S =: move@((-i)&*) | |
W =: move@(_1&*) | |
R =: turn@((-i)&^@(%&90))) | |
L =: turn@((i)&^@(%&90)) | |
op =: {. | |
arg =: ".@:}. | |
do =: monad : '(>{.y)~ (>}.y)' | |
transforms =: ,.<"2 (786 3 3 $ ;; do @ (op ; arg) &.> input) | |
matmul =: dyad : 'y +/ . * (3 3 $;>x)' | |
+/ | +. {. 0 1 1 matmul F.. ] transforms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment