mirror of
https://github.com/Ajetski/advent-of-code.git
synced 2025-09-30 13:03:19 -09:00
add auto-download input setup
This commit is contained in:
parent
506ab08957
commit
14ce95a390
1
2024/input/.gitignore
vendored
Normal file
1
2024/input/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.session
|
1000
2024/input/1.txt
Normal file
1000
2024/input/1.txt
Normal file
File diff suppressed because it is too large
Load Diff
25
2024/src/core.clj
Normal file
25
2024/src/core.clj
Normal 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))))
|
||||||
|
|
1006
2024/src/day01.clj
1006
2024/src/day01.clj
File diff suppressed because it is too large
Load Diff
15
2024/src/day02.clj
Normal file
15
2024/src/day02.clj
Normal 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)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user