This file contains 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
(def input | |
(-> (slurp "input_2019_6") | |
clojure.string/trim | |
(clojure.string/split #"\n"))) | |
(def orbits-graph | |
(->> input | |
(map #(clojure.string/split % #"\)")) | |
(reduce (fn [ret [v k]] | |
(assoc! ret k v)) |
This file contains 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 prefix-params [default params] | |
(let [diff-ln (- (count default) (count params))] | |
(if-not (== 0 diff-ln) | |
(str (subs default 0 diff-ln) params) | |
params))) | |
(defn read-instruction [s] | |
(case s | |
"1" [1 0 0 1] | |
"2" [2 0 0 1] |
This file contains 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 increasing? [d] | |
(re-matches #"1*2*3*4*5*6*7*8*9*" d)) | |
(defn repeating-by? [op s] | |
(->> (frequencies s) | |
(some #(op 2 (val %))))) | |
(defn solve-day4-p1 [from to] | |
(->> (range from (inc to)) | |
(map str) |
This file contains 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 read-move [s] | |
[(keyword (subs s 0 1)) | |
(read-string (subs s 1))]) | |
(comment | |
(= [:R 1009] (read-move "R1009"))) | |
(def input | |
(->> (slurp "input_2019_3") | |
(clojure.string/split-lines) |
This file contains 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 execute-instruction! [opcode input offset] | |
(let [p1 (nth input (+ 1 offset)) | |
p2 (nth input (+ 2 offset)) | |
p3 (nth input (+ 3 offset)) | |
op (case opcode | |
1 + | |
2 *)] | |
(->> (op (nth input p1) (nth input p2)) | |
(assoc! input p3)))) |
This file contains 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
(def input | |
(->> (clojure.string/split (slurp "src/day01_input") #"\s") | |
(map read-string))) | |
(defn calc-fuel [m] | |
(-> m (/ 3) int (- 2))) | |
(defn solve-day1-p1 [input] | |
(->> (map calc-fuel input) | |
(reduce +))) |
This file contains 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 test.core) | |
(defn add [^i32 a ^i32 b] | |
(let [x 1 | |
y 2] | |
(if (= a b) | |
(+ x y) | |
(+ a b)))) | |
(defn main [] |
This file contains 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
type Thunk = Function; | |
type Result = any; | |
class Adapton { | |
thunk: Thunk; | |
result: Result; | |
sub: Set<Adapton>; | |
sup: Set<Adapton>; | |
isClean: boolean; |
This file contains 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
[data-testid="sidebarColumn"] { | |
display: none; | |
} | |
[data-testid="primaryColumn"] { | |
max-width: 1000px; | |
} | |
[data-testid="primaryColumn"] > div:first-child > div:nth-child(3) { | |
max-width: 800px; | |
} | |
[aria-label=Primary] > a > div > div:nth-child(2), |
This file contains 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
createStore({ | |
dropTargetIDToBoxID: { | |
"drop1": "box1" | |
"drop2": "box2" | |
"drop3": null | |
}, | |
boxes: { | |
"box1": {x:0, y: 0}, | |
"box2": {x:100, y: 100}, | |
} |