1 (ns adventofcode2019.lib
2 [:require [clojure.string :as str]
3 [clojure.java.io :as io]
4 [clojure.java.shell :refer [sh]]])
6 (defn get-list-from-file
8 (str/split-lines (str/trim (slurp file-name))))
9 ([file-name split-regex]
10 (str/split (str/trim (slurp file-name)) split-regex)))
13 #(Integer/parseInt %))
15 (defmacro input-file []
16 (let [bottom-ns (last (str/split (str *ns*) #"\."))]
17 (str "resources/" bottom-ns)))
20 #(println (str "Part 1: " %)))
22 #(println (str "Part 2: " %)))
24 ;; FIXME: this is still broken but i give up for now
25 ; (defn --input-file [for-ns]
26 ; (let [bottom-ns (last (str/split for-ns #"\."))
27 ; input-url "https://adventofcode.com/2019/day/%d/input"
28 ; day-url (->> bottom-ns
33 ; token (str/trim (slurp (io/resource "token")))
34 ; res-dir (-> (io/resource "token")
36 ; (str/replace "token" bottom-ns))
37 ; cmd ["curl" "-s" "-b"
38 ; (format "\"session=%s\"" token)
39 ; day-url ">" res-dir]]
40 ; (if-let [input (io/resource bottom-ns)]
42 ; (do (apply sh cmd) nil))))
44 ; (defmacro input-file []
45 ; (--input-file (str *ns*)))