diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2022-11-30 19:55:31 -0500 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2022-11-30 19:55:31 -0500 |
commit | 8d43e37df99f280377bed90284d6ac2428334804 (patch) | |
tree | 3a5042c9af29da52b4bac38fd78b3ccde77a1dbc /day2 | |
parent | 66ed0b9d27850dc653abc8baa75884f3de311bfa (diff) |
move 2021 days to folder; update README
Diffstat (limited to 'day2')
-rw-r--r-- | day2/part1.clj | 26 | ||||
-rw-r--r-- | day2/part2.clj | 27 |
2 files changed, 0 insertions, 53 deletions
diff --git a/day2/part1.clj b/day2/part1.clj deleted file mode 100644 index e4e9d49..0000000 --- a/day2/part1.clj +++ /dev/null @@ -1,26 +0,0 @@ -; Day 2, part 1 -; Read a list of instructions from stdin: -; "down X" increases depth number by X, -; "up X" decreases depth by X, -; "forward X" increases xpos by X. -; Print (xpos * depth) after end of data. -; - -(require '[clojure.string :as str]) - -(println - (reduce * - (vals - (reduce - #(case (first %2) - "forward" (update %1 :xpos + (second %2)) - "up" (update %1 :depth - (second %2)) - "down" (update %1 :depth + (second %2)) - ) - {:xpos 0 :depth 0} - (->> (slurp "./in") - str/split-lines - (map #(str/split % #" ")) - (map #(update % 1 read-string)) - ))))) - diff --git a/day2/part2.clj b/day2/part2.clj deleted file mode 100644 index 9487a49..0000000 --- a/day2/part2.clj +++ /dev/null @@ -1,27 +0,0 @@ -; Day 2, part 2 -; Read a list of instructions from stdin: -; "down X" increases aim number by X, -; "up X" decreases aim by X, -; "forward X" increases xpos by X and depth by (aim * X). -; Print (xpos * depth) after end of data. -; - -(require '[clojure.string :as str]) - -(println - (apply * - (map - (reduce - #(case (first %2) - "forward" (-> %1 (update :xpos + (second %2)) - (update :depth + (* (%1 :aim) (second %2)))) - "up" (update %1 :aim - (second %2)) - "down" (update %1 :aim + (second %2))) - {:xpos 0 :depth 0 :aim 0} - (->> (slurp "./in") - str/split-lines - (map #(str/split % #" ")) - (map #(update % 1 read-string)))) - [:xpos :depth] - ))) - |