Ready for day 4
This commit is contained in:
parent
7419eccd05
commit
8ebbe45a29
5 changed files with 28 additions and 4 deletions
|
@ -1,2 +1,17 @@
|
|||
.PHONY: default run install build build-release build-tiny
|
||||
default: run
|
||||
|
||||
run:
|
||||
nimble run
|
||||
|
||||
build:
|
||||
nimble build
|
||||
|
||||
build-release:
|
||||
nimble build -d:release
|
||||
|
||||
build-tiny:
|
||||
nimble build -d:release --opt:size
|
||||
|
||||
install:
|
||||
nimble install
|
||||
|
|
|
@ -8,4 +8,5 @@ proc solve_for_day(n: int) {.used.} =
|
|||
echo solvers[n]()
|
||||
|
||||
when isMainModule:
|
||||
solve_all()
|
||||
# solve_all()
|
||||
solve_for_day(4)
|
||||
|
|
7
2020/src/day4.nim
Normal file
7
2020/src/day4.nim
Normal file
|
@ -0,0 +1,7 @@
|
|||
import streams
|
||||
|
||||
proc part1*(s: Stream): int =
|
||||
1
|
||||
|
||||
proc part2*(s: Stream): int =
|
||||
2
|
|
@ -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..3:
|
||||
for day in 1..4:
|
||||
let module = fmt"day{day}"
|
||||
if fileExists joinPath("src/", &"{module}.nim"):
|
||||
result.add parseStmt fmt"from {module} import nil"
|
||||
|
|
|
@ -5,7 +5,7 @@ var consoleLog = newConsoleLogger()
|
|||
addHandler(consoleLog)
|
||||
addHandler(fileLog)
|
||||
|
||||
let cacheDir = joinPath(getEnv("XDG_CACHE_HOME", expandTilde("~/.cache")), "/aoc2020-cache")
|
||||
let cacheDir = joinPath(getEnv("XDG_CACHE_HOME", expandTilde("~/.cache")), "/aoc2020")
|
||||
createDir(cacheDir)
|
||||
|
||||
# TODO: add login capabilities via `pass` for auto-cookie-retrieval?
|
||||
|
@ -14,7 +14,8 @@ proc requestAocContentAuthed(url: string): TaintedString =
|
|||
let cookie = getEnv("ADVENT_OF_CODE_AUTH_COOKIE", readFile(expandTilde("~/.advent-of-code-auth-cookie")))
|
||||
let client = newHttpClient()
|
||||
client.headers = newHttpHeaders({"cookie": cookie})
|
||||
client.getContent(url)
|
||||
# client.getContent(url)
|
||||
""
|
||||
|
||||
proc getInputFileStreamForDay*(day: int): FileStream =
|
||||
# retrieve the input and dump it to a file if we don't have it yet
|
||||
|
|
Loading…
Reference in a new issue