Utility for loading the Advent of Code 2020 input into the Clojure REPL on demand
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns pez.aoc2020.util | |
(:require [clj-http.client :as client])) | |
(defn fetch-input [day] | |
(try | |
(let [cookie (slurp ".aoc-session")] | |
(:body (client/get | |
(str "https://adventofcode.com/2020/day/" day "/input") | |
{:cookies {"session" {:value cookie}}}))) | |
(catch Exception e | |
(println "Ho, ho, ho! Did you forget to populate `.aoc-session` with your AOC session cookie?") | |
(throw e)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a utility for fetching Advent of Code 2020 input data.
How to use:
In preparation. (The cookie lives for only 10 years, so you need to redo this in a decade):
adventofcode.com/2020
and open the problem page2020
for index page)..aoc-session
at the root of your project.When trying to collect a star or two:
(util/fetch-input <day>)
(probably into adef
)It looked like this in my Rich comment block for Day 2 (don't worry, no spoilers).
I made do with the sample input until I thought my solution worked, then redefined
input
by fetching the problem input.