add auto-download input setup

This commit is contained in:
2024-12-01 12:10:49 -05:00
parent 506ab08957
commit 14ce95a390
5 changed files with 1043 additions and 1004 deletions
+1
View File
@@ -0,0 +1 @@
.session
+1000
View File
File diff suppressed because it is too large Load Diff
+25
View File
@@ -0,0 +1,25 @@
(ns core
(:require
[babashka.fs :as fs]
[babashka.http-client :as http]
[clojure.string :as str]))
(def session (first (fs/read-all-lines "input/.session")))
(defn input-file-loc [day]
(str "input/" day ".txt"))
(defn download-input [day]
(->> {:headers {:cookie (str "session=" session)}}
(http/get (str "https://adventofcode.com/2024/day/" day "/input"))
:body
(str/split-lines)
(fs/write-lines (input-file-loc day))))
(defn get-input [day]
(try
(fs/read-all-lines (input-file-loc day))
(catch java.nio.file.NoSuchFileException _e
(download-input day)
(get-input day))))
+2 -1004
View File
File diff suppressed because it is too large Load Diff
+15
View File
@@ -0,0 +1,15 @@
(ns day02
(:require
[clojure.string :as str]))
(def raw-input (str/split-lines ""))
(def input (->> raw-input
(map identity)))
;; part 1
(->> input)
;; part 2
;; (->> input)