Pausing again
This commit is contained in:
parent
6b00c07dae
commit
43903485ca
|
@ -1,21 +1,48 @@
|
||||||
import ./common, std/[strutils, sequtils, tables, strformat, algorithm, hashes]
|
import ./common, std/[strutils, hashes, sugar, strformat]
|
||||||
|
|
||||||
proc p1(input: Lines): uint64 =
|
proc p1(input: Lines): uint64 =
|
||||||
|
var h = input.len
|
||||||
|
var w = input[0].len
|
||||||
var cukes = input
|
var cukes = input
|
||||||
while cukes.hash != nextCukes.hash
|
while true:
|
||||||
|
echo result
|
||||||
var nextCukes = cukes
|
var nextCukes = cukes
|
||||||
for y,line in cukes:
|
if result < 4:
|
||||||
for x,c in cukes:
|
echo nextCukes.join("\n")
|
||||||
case c:
|
echo ""
|
||||||
# don't forget to wrap
|
let startHash = nextCukes.hash
|
||||||
of '>': # TODO: check next x
|
for y,line in nextCukes.pairs:
|
||||||
of 'v': # TODO: check next y
|
for x,c in line.pairs:
|
||||||
else: continue
|
let tx = if x >= w - 1: 0 else: x + 1
|
||||||
|
if c == '>' and nextCukes[y][tx] == '.':
|
||||||
|
echo &"{x}, {y} going right"
|
||||||
|
nextCukes[y][x] = '.'
|
||||||
|
nextCukes[y][tx] = 'r'
|
||||||
|
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] == '.':
|
||||||
|
echo &"{x}, {y} going down"
|
||||||
|
nextCukes[y][x] = 'u'
|
||||||
|
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] = '>'
|
||||||
|
|
||||||
|
if nextCukes.hash == startHash: break
|
||||||
cukes = nextCukes
|
cukes = nextCukes
|
||||||
inc result
|
inc result
|
||||||
|
|
||||||
proc p2(input: Lines): uint64 =
|
proc p2(input: Lines): uint64 =
|
||||||
0
|
0
|
||||||
|
|
||||||
time(&"Day 25 Part 1"): echo 25.loadInput.p1
|
doDayX 25, (n: int) => n.loadInput, p1, p2, ("""v...>>.vv>
|
||||||
time(&"Day 25 Part 2"): echo 25.loadInput.p2
|
.vv>>.vv..
|
||||||
|
>>.>v>...v
|
||||||
|
>>v>>.>.v.
|
||||||
|
v>v.vv.v..
|
||||||
|
>.>>..v...
|
||||||
|
.vv..>.>v.
|
||||||
|
v.v..>>v.v
|
||||||
|
....v..v.>""".split('\n'), 58'u64, 0'u64)
|
||||||
|
|
Loading…
Reference in a new issue