Add correct day7pt1
[adventofcode2019.git] / src / adventofcode2019 / lib.clj
CommitLineData
cca08f5d
JK
1(ns adventofcode2019.lib
2 [:require [clojure.string :as str]
d0f13cd2
JK
3 [clojure.java.io :as io]
4 [clojure.java.shell :refer [sh]]])
cca08f5d
JK
5
6(defn get-list-from-file
7 ([file-name]
8 (str/split-lines (str/trim (slurp file-name))))
9 ([file-name split-regex]
10 (str/split (str/trim (slurp file-name)) split-regex)))
11
d0f13cd2
JK
12(def parse-int
13 #(Integer/parseInt %))
14
cca08f5d
JK
15(defmacro input-file []
16 (let [bottom-ns (last (str/split (str *ns*) #"\."))]
17 (str "resources/" bottom-ns)))
18
0503903a
JK
19(def part1
20 #(println (str "Part 1: " %)))
21(def part2
22 #(println (str "Part 2: " %)))
d0f13cd2
JK
23
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
29; (drop 3)
30; (str/join)
31; (parse-int)
32; (format input-url))
33; token (str/trim (slurp (io/resource "token")))
34; res-dir (-> (io/resource "token")
35; (.getPath)
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)]
41; input
42; (do (apply sh cmd) nil))))
43
44; (defmacro input-file []
45; (--input-file (str *ns*)))