day 23 ivy minor cleanup
parent
98a4dffb3c
commit
9e168db913
|
@ -5,27 +5,12 @@ sample = 7 7 rho '....#..' '..###.#' '#...#.#' '.#...##' '#.###..' '##.#.##' '.#
|
|||
board = input == '#'
|
||||
#board
|
||||
|
||||
op north a = 1 flip a
|
||||
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 show a = (text ".#23456789"[1+a]),"\n-"
|
||||
|
||||
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 a coalesce b =
|
||||
a: a
|
||||
b
|
||||
|
||||
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 =
|
||||
c1 = any 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
|
||||
a
|
||||
|
||||
op smearWE a = a or (west a) or (east a)
|
||||
op smearNS a = a or (north a) or (south a)
|
||||
|
||||
op show a = (text ".#23456789"[1+a]),"\n-"
|
||||
|
||||
M = 0
|
||||
|
||||
op axis1 a = 3 1 2 transp a
|
||||
op smearWE a = a or (1 rot a) or (-1 rot a)
|
||||
op smearNS a = a or (1 flip a) or (-1 flip a)
|
||||
|
||||
op look a =
|
||||
ns = lift smearNS a
|
||||
we = lift smearWE a
|
||||
-1 moveNSWE (we, we, ns, ns)
|
||||
|
||||
op axis1 a = 3 1 2 transp a
|
||||
op dup4 a = (4,rho a) rho a
|
||||
|
||||
# look in each direction
|
||||
|
@ -119,9 +99,9 @@ op score a =
|
|||
n = */ (rho a) - 2
|
||||
n - +/, a
|
||||
|
||||
show round board
|
||||
show board
|
||||
#show round board
|
||||
show 10 rounds board
|
||||
score 10 rounds board
|
||||
|
||||
1000 numrounds board
|
||||
#numrounds board
|
||||
|
|
Loading…
Reference in New Issue