diff --git a/2020/makefile b/2020/makefile index d0a1bd3..4baa560 100644 --- a/2020/makefile +++ b/2020/makefile @@ -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 diff --git a/2020/src/aoc2020.nim b/2020/src/aoc2020.nim index 55a6b07..df5140a 100644 --- a/2020/src/aoc2020.nim +++ b/2020/src/aoc2020.nim @@ -8,4 +8,5 @@ proc solve_for_day(n: int) {.used.} = echo solvers[n]() when isMainModule: - solve_all() + # solve_all() + solve_for_day(4) diff --git a/2020/src/day4.nim b/2020/src/day4.nim new file mode 100644 index 0000000..5f943f4 --- /dev/null +++ b/2020/src/day4.nim @@ -0,0 +1,7 @@ +import streams + +proc part1*(s: Stream): int = + 1 + +proc part2*(s: Stream): int = + 2 diff --git a/2020/src/day_loader.nim b/2020/src/day_loader.nim index b6c382d..05da3eb 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..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" diff --git a/2020/src/input_requestor.nim b/2020/src/input_requestor.nim index c35d8f5..75b6542 100644 --- a/2020/src/input_requestor.nim +++ b/2020/src/input_requestor.nim @@ -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