day 23 ivy minor cleanup

main
magical 2022-12-23 16:21:36 -08:00
parent 98a4dffb3c
commit 9e168db913
1 changed files with 6 additions and 26 deletions

View File

@ -5,27 +5,12 @@ sample = 7 7 rho '....#..' '..###.#' '#...#.#' '.#...##' '#.###..' '##.#.##' '.#
board = input == '#' board = input == '#'
#board #board
op north a = 1 flip a op show a = (text ".#23456789"[1+a]),"\n-"
op south a = -1 flip a
op west a = 1 rot a
op east a = -1 rot a
#north 3 3 rho iota 9
op lift a = (1,rho a) rho a op lift a = (1,rho a) rho a
op n moveNSWE a = (lift n flip a[1]), (lift (-n) flip a[2]), (lift n rot a[3]), (lift (-n) rot a[4]) op n moveNSWE a = (lift n flip a[1]), (lift (-n) flip a[2]), (lift n rot a[3]), (lift (-n) rot a[4])
op a coalesce b =
a: a
b
op any a = or/,a op any a = or/,a
op pad a = 0,(transp (0,(transp a),0)),0
op needsPad a = (any 0 != a[1,(rho a)[1]]) or (any 0 != a[;(1,(rho a)[2])])
op maybePad a =
needsPad a: pad a
a
op maybePad1 a = op maybePad1 a =
c1 = any a[1] c1 = any a[1]
c2 = any a[(rho a)[1]] c2 = any a[(rho a)[1]]
@ -39,20 +24,15 @@ op maybePad a =
(any a[;1]) or (any a[;(rho a)[2]]): transp maybePad1 transp a (any a[;1]) or (any a[;(rho a)[2]]): transp maybePad1 transp a
a a
op smearWE a = a or (west a) or (east a) op smearWE a = a or (1 rot a) or (-1 rot a)
op smearNS a = a or (north a) or (south a) op smearNS a = a or (1 flip a) or (-1 flip a)
op show a = (text ".#23456789"[1+a]),"\n-"
M = 0
op axis1 a = 3 1 2 transp a
op look a = op look a =
ns = lift smearNS a ns = lift smearNS a
we = lift smearWE a we = lift smearWE a
-1 moveNSWE (we, we, ns, ns) -1 moveNSWE (we, we, ns, ns)
op axis1 a = 3 1 2 transp a
op dup4 a = (4,rho a) rho a op dup4 a = (4,rho a) rho a
# look in each direction # look in each direction
@ -119,9 +99,9 @@ op score a =
n = */ (rho a) - 2 n = */ (rho a) - 2
n - +/, a n - +/, a
show round board show board
#show round board
show 10 rounds board show 10 rounds board
score 10 rounds board score 10 rounds board
1000 numrounds board 1000 numrounds board
#numrounds board