Day 6 part 1

This commit is contained in:
Daniel Flanagan 2020-12-05 23:10:59 -06:00
parent 7b5c3ff06d
commit e43a036788
Signed by: lytedev
GPG Key ID: 5B2020A0F9921EF4
3 changed files with 10 additions and 2 deletions

View File

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

8
2020/src/day6.nim Normal file
View 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

View File

@ -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"