Last active
December 4, 2021 17:21
-
-
Save ordnungswidrig/21224314590b871456cd4ccb2633ca8e to your computer and use it in GitHub Desktop.
AoC-2021 - pointfree - threading
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 characters
# part one | |
pbpaste | bb -I -e '(->> (-> *input* (#(vector % %)) (update 1 rest)) (apply map <) (filter true?) count)' | |
# part two | |
pbpaste | bb -I -e ' (->> *input* (iterate rest) (take 3) (apply map +) (#(vector % %)) (#(update % 1 rest)) (apply map <) (filter true?) count)' |
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 characters
# part one | |
pbpaste | bb -I -e '(->> *input* (partition 2) (reduce (fn [[x y] [c v]] (case (keyword (name c)) :forward [(+ x v) y] :down [x (+ y v)] :up [x (- y v)])) [0 0]) (apply *))' | |
# part two | |
pbpaste | bb -I -e '(->> *input* (partition 2) (reduce (fn [[x y a] [c v]] (case (keyword (name c)) :forward [(+ x v) (+ y (* a v)) a] :down [x y (+ a v)] :up [x y (- a v)])) [0 0 0]) butlast (apply *))' |
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 characters
# part one | |
pbpaste | bb -i -e ' (->> (-> (->> *input* (apply map (fn [& s] (->> s (map #(->> % {\0 1 \1 -1})) (reduce + 0) (#(/ % (Math/abs %))) (+ 1) (#(/ % 2)))))) (#(vector % %)) (update 1 (fn [x] (->> x (map #(- 1 %)))))) (map #(Integer/parseInt (apply str (map str %)) 2)) (apply *))' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment