Last active
December 24, 2020 10:49
-
-
Save leetwinski/6b8b58ed818a43611ef5618b84cf57f7 to your computer and use it in GitHub Desktop.
Revisions
-
leetwinski revised this gist
Dec 24, 2020 . 1 changed file with 10 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,18 +7,16 @@ [(inc i) (- i (data n i))]]) (defn nth-num [seed n] (->> [(into {} (map vector (butlast seed) (range))) [(dec (count seed)) (last seed)]] (iterate next-num) (map second) (drop-while #(< (first %) (dec n))) first)) ;; part 1 (nth-num seed 2020) ;; part 2 (nth-num seed 30000000) -
leetwinski created this gist
Dec 24, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ (ns advent-2020-15) (def seed [1,2,16,19,18,0]) (defn next-num [[data [i n]]] [(assoc data n i) [(inc i) (- i (data n i))]]) ;; part 1 (->> [(into {} (map vector (butlast seed) (range))) [(dec (count seed)) (last seed)]] (iterate next-num) (map second) (drop-while #(< (first %) 2019)) first) ;; part 2 (->> [(into {} (map vector (butlast seed) (range))) [(dec (count seed)) (last seed)]] (iterate next-num) (map second) (drop-while #(< (first %) 29999999)) first)