Day 6 part 1
This commit is contained in:
parent
7b5c3ff06d
commit
e43a036788
|
@ -9,4 +9,4 @@ proc solve_for_day(n: int) {.used.} =
|
||||||
|
|
||||||
when isMainModule:
|
when isMainModule:
|
||||||
# solve_all()
|
# solve_all()
|
||||||
solve_for_day(5)
|
solve_for_day(6)
|
||||||
|
|
8
2020/src/day6.nim
Normal file
8
2020/src/day6.nim
Normal file
|
@ -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
|
|
@ -3,7 +3,7 @@ import input_requestor, os, macros, strformat, tables
|
||||||
macro loadDays(): untyped =
|
macro loadDays(): untyped =
|
||||||
var solver_str = "var solvers = {\n"
|
var solver_str = "var solvers = {\n"
|
||||||
result = newStmtList()
|
result = newStmtList()
|
||||||
for day in 1..5:
|
for day in 1..6:
|
||||||
let module = fmt"day{day}"
|
let module = fmt"day{day}"
|
||||||
if fileExists joinPath("src/", &"{module}.nim"):
|
if fileExists joinPath("src/", &"{module}.nim"):
|
||||||
result.add parseStmt fmt"from {module} import nil"
|
result.add parseStmt fmt"from {module} import nil"
|
||||||
|
|
Loading…
Reference in a new issue