From 93fde21e2c8da7e0fdeaa4a670159f0bba0c3189 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Sun, 5 Dec 2021 11:14:33 -0600 Subject: [PATCH] Day 5 part 1 --- 2021/five.nim | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/2021/five.nim b/2021/five.nim index fab6ab4..5761aaa 100644 --- a/2021/five.nim +++ b/2021/five.nim @@ -10,21 +10,18 @@ proc part1(inputLines: seq[string]): int = for l in inputLines: let (x1, y1, x2, y2) = l.toPointPair() if x1 == x2 or y1 == y2: - echo &"{x1} {y1} -> {x2} {y2}" - for x in x1..x2: - for y in y1..y2: + for x in min(x1, x2)..max(x1, x2): + for y in min(y1, y2)..max(y1, y2): points.inc((x, y)) - echo &"{x} {y}" for p in points.values(): if p >= 2: - echo p inc result proc part2(inputLines: seq[string]): int = return 0 let input = 5.loadInput() -# time("day 5 part 1"): echo input.part1() +time("day 5 part 1"): echo input.part1() # time("day 5 part 2"): echo input.part2() when not defined(release):