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
| (ns adventofcode.2018.day14) | |
| (def day-input 846601) | |
| (def day-input-vec [8 4 6 6 0 1]) | |
| (set! *unchecked-math* true) | |
| (def initial-state {:workers #{0 1} | |
| :table [3 7]}) |
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
| (ns oh-n0.core) | |
| (defn transpose [board] | |
| (apply mapv vector board)) | |
| (defn right-elems [board [i j]] | |
| (drop (inc j) (get board i))) | |
| (defn left-elems [board [i j]] | |
| (reverse (take j (get board i)))) |
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
| (require '[java-time :as t]) | |
| (defn at [t {:keys [hours minutes seconds]}] | |
| (let [m (t/as-map t)] | |
| (cond-> t | |
| hours (t/plus (t/hours (- hours (:hour-of-day m)))) | |
| minutes (t/plus (t/minutes (- minutes (:minute-of-hour m)))) | |
| seconds (t/plus (t/seconds (- seconds (:second-of-minute m))))))) | |
| (defn next-working-day [t] |
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
| (require '[clojure.string :as str]) | |
| (defn binary-partition [b-string] | |
| (let [bits (dec (count b-string))] | |
| (->> b-string | |
| (map-indexed (fn [i x] | |
| (if (#{\B \R} x) | |
| (Math/pow 2 (- bits i)) | |
| 0))) | |
| (reduce +)))) |
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
| (require '[clojure.string :as str]) | |
| (def example "abc\n\na\nb\nc\n\nab\nac\n\na\na\na\na\n\nb") | |
| (defn part-1 [a] | |
| (->> (str/split a #"\n\n") | |
| (map #(str/replace % #"\n" "")) | |
| (map set) | |
| (map count) | |
| (reduce +))) |
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
| (defn print-help [prefix cmds] | |
| (println "Usage:" prefix "[COMMAND] [FLAGS]") | |
| (println) | |
| (println "Flags:") | |
| (println (format " %s%-40s%s%s" log/blue "-v" log/nc "Verbose")) | |
| (println (format " %s%-40s%s%s" log/blue "-h" log/nc "Help")) | |
| (println) | |
| (when (seq cmds) | |
| (println "Commands:") | |
| (doseq [[cmd {:keys [description]}] (sort-by first cmds)] |
OlderNewer