From c1cba6750f6229eedc3b1ea58a8d519acea89590 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sun, 26 Dec 2021 14:56:14 -0600 Subject: [PATCH] Day 25 is done --- 2021/nim/day25.nim | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/2021/nim/day25.nim b/2021/nim/day25.nim index cd50355..0864ba2 100644 --- a/2021/nim/day25.nim +++ b/2021/nim/day25.nim @@ -7,32 +7,28 @@ proc p1(input: Lines): uint64 = while true: echo result var nextCukes = cukes - if result < 4: - echo nextCukes.join("\n") - echo "" - let startHash = nextCukes.hash - for y,line in nextCukes.pairs: + echo nextCukes.join("\n") + echo "" + let startHash = cukes.hash + for y,line in cukes.pairs: for x,c in line.pairs: let tx = if x >= w - 1: 0 else: x + 1 - if c == '>' and nextCukes[y][tx] == '.': + if c == '>' and cukes[y][tx] == '.': echo &"{x}, {y} going right" nextCukes[y][x] = '.' - nextCukes[y][tx] = 'r' + nextCukes[y][tx] = '>' + cukes = nextCukes for y,line in cukes.pairs: for x,c in line.pairs: let ty = if y >= h - 1: 0 else: y + 1 - if c == 'v' and nextCukes[ty][x] == '.': + if c == 'v' and cukes[ty][x] == '.': echo &"{x}, {y} going down" - nextCukes[y][x] = 'u' + nextCukes[y][x] = '.' nextCukes[ty][x] = 'v' - for y,line in nextCukes.pairs: - for x,c in line: - if c == 'u': nextCukes[y][x] = '.' - elif c == 'r': nextCukes[y][x] = '>' + inc result if nextCukes.hash == startHash: break cukes = nextCukes - inc result proc p2(input: Lines): uint64 = 0