From 9e168db913054a26c1227f0d09fa5220b123101a Mon Sep 17 00:00:00 2001 From: Andrew Ekstedt Date: Fri, 23 Dec 2022 16:21:36 -0800 Subject: [PATCH] day 23 ivy minor cleanup --- day23/sol.ivy | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/day23/sol.ivy b/day23/sol.ivy index e18d351..b2d55ff 100644 --- a/day23/sol.ivy +++ b/day23/sol.ivy @@ -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