From a85fb88c095355ddc940ada595f9d39198463944 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 11 Dec 2020 23:02:43 -0600 Subject: [PATCH] Go --- 2020/src/aoc2020.nim | 2 +- 2020/src/day11.nim | 6 +++--- 2020/src/day12.nim | 13 +++++++++++++ 3 files changed, 17 insertions(+), 4 deletions(-) create mode 100644 2020/src/day12.nim diff --git a/2020/src/aoc2020.nim b/2020/src/aoc2020.nim index 59c3679..169c5dc 100644 --- a/2020/src/aoc2020.nim +++ b/2020/src/aoc2020.nim @@ -9,4 +9,4 @@ proc solve_for_day(n: int) {.used.} = when isMainModule: # solve_all() - solve_for_day(11) + solve_for_day(12) diff --git a/2020/src/day11.nim b/2020/src/day11.nim index a8d5f98..52a6676 100644 --- a/2020/src/day11.nim +++ b/2020/src/day11.nim @@ -56,7 +56,7 @@ proc inBounds(g: Grid, x: int, y: int): bool = x >= 0 and y >= 0 and y < g.len and x < g.row(y).len proc toSightSeat(g: Grid[Seat], x: int, y: int): SightSeat = - echo "toSightSeat" + #echo "toSightSeat" result[0] = g.at(x, y) for vy in -1..1: for vx in -1..1: @@ -67,7 +67,7 @@ proc toSightSeat(g: Grid[Seat], x: int, y: int): SightSeat = tx += vx ty += vy if g.inBounds(tx, ty): result[1].add (x: tx, y: ty) - echo (x, y, result) + #echo (x, y, result) proc asSightGrid(s: Stream): SightGrid = let g = s.asGrid() @@ -106,7 +106,7 @@ proc part2*(s: Stream): int = var ng: Grid[SightSeat] var steps = 0 while g != ng: - echo "Step ", steps + #echo "Step ", steps ng = g g = g.stepSightGrid inc steps diff --git a/2020/src/day12.nim b/2020/src/day12.nim new file mode 100644 index 0000000..da5606d --- /dev/null +++ b/2020/src/day12.nim @@ -0,0 +1,13 @@ +import streams, sequtils + +type Dir = enum north, east, south, west + +proc left( + +proc part1*(s: Stream): int = + for l in s.lines: + echo l + 9 + +proc part2*(s: Stream): int = + 9