Skip to content

Commit

Permalink
Day 20
Browse files Browse the repository at this point in the history
  • Loading branch information
caseneuve committed Apr 7, 2023
1 parent c18ec38 commit 5cd98ab
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions Clojure/day20.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(ns day20
(:require [input :refer [f->str]]))

(defn -main [day]
(let [input (->> day f->str (re-seq #"\d+") (map parse-long) (partition 2) (sort-by first))
max-ip 4294967295]
(loop [[[a b] & rx] (rest input), [x y] (first input), result {:part1 [] :part2 0}]
(cond
(empty? rx) (-> result (update :part1 first) (update :part2 + (- max-ip y)))
(> a (inc y)) (recur rx [a b] (-> result (update :part1 conj (inc y)) (update :part2 + (dec (- a y)))))
:else (recur rx [x (max b y)] result)))))

0 comments on commit 5cd98ab

Please sign in to comment.