Day 6 part 1
This commit is contained in:
parent
7b5c3ff06d
commit
e43a036788
3 changed files with 10 additions and 2 deletions
|
@ -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
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 =
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue