Too sleepy for day 13...

This commit is contained in:
Daniel Flanagan 2020-12-13 00:04:37 -06:00
parent 40a1f7ca9d
commit 37ee031810
Signed by: lytedev
GPG key ID: 5B2020A0F9921EF4
3 changed files with 7 additions and 4 deletions

View file

@ -9,4 +9,4 @@ proc solve_for_day(n: int) {.used.} =
when isMainModule:
# solve_all()
solve_for_day(12)
solve_for_day(13)

View file

@ -1,4 +1,4 @@
import streams, sequtils, strutils, tables
import streams, strutils, tables
type Dir = enum north, east, south, west
@ -40,7 +40,6 @@ proc part2*(s: Stream): int =
var p = (0, 0)
var wp = (10, -1)
for l in s.lines:
echo (d, p, wp, l)
let arg = l[1..^1].parseInt
case l[0]:
of 'N': wp = wp.move(dirMap[north], arg)
@ -50,7 +49,6 @@ proc part2*(s: Stream): int =
of 'L': wp = wp.left(arg div 90)
of 'R': wp = wp.right(arg div 90)
else: p = p.move(wp, arg)
echo (d, p, wp)
p[0].abs + p[1].abs
doAssert "F10\nN3\nF7\nR90\nF11".newStringStream.part2 == 286

5
2020/src/day13.nim Normal file
View file

@ -0,0 +1,5 @@
import streams
proc part1*(s: Stream): int =
9
proc part2*(s: Stream): int =
9