diff --git a/2020/src/aoc2020.nim b/2020/src/aoc2020.nim index 4d5052a..282435e 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(5) + solve_for_day(6) diff --git a/2020/src/day6.nim b/2020/src/day6.nim new file mode 100644 index 0000000..2b903c8 --- /dev/null +++ b/2020/src/day6.nim @@ -0,0 +1,8 @@ +import streams, sets, strutils, sequtils + +proc part1*(s: Stream): int = + # s.readAll().split("\n\n").mapIt(it.split("\n").foldl(a.union(b.toHashSet), initHashSet)).len + s.readAll().split("\n\n").mapIt(it.split("\n").foldl(a.union(b.toHashSet), initHashSet[char]()).len).foldl(a + b) + +proc part2*(s: Stream): int = + 9 diff --git a/2020/src/day_loader.nim b/2020/src/day_loader.nim index e6fc2b4..12cf9de 100644 --- a/2020/src/day_loader.nim +++ b/2020/src/day_loader.nim @@ -3,7 +3,7 @@ import input_requestor, os, macros, strformat, tables macro loadDays(): untyped = var solver_str = "var solvers = {\n" result = newStmtList() - for day in 1..5: + for day in 1..6: let module = fmt"day{day}" if fileExists joinPath("src/", &"{module}.nim"): result.add parseStmt fmt"from {module} import nil"