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
| (def koch-curve-right-angles | |
| {:productions {\F "F+F-F-F+F"}, | |
| :axiom "F", | |
| :iterations 3, | |
| :actions {\F '(FD 20) | |
| \+ '(LT 90) | |
| \- '(RT 90)}}) | |
| (def sierpenski-triangle | |
| {:productions {\F "F-G+F+G-F" |
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
| ;; I've watched most, if not all of these. | |
| Korean: | |
| Oldboy | |
| Sympathy for Mr Vengeance | |
| Sympathy for Lady Vengeance | |
| Bakjwi | |
| JSA | |
| Memories of Murder | |
| Man From Nowhere |
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 max-adjacents [coll] | |
| (map max coll (rest coll))) | |
| (defn sum-of [prev current] | |
| (map + current (max-adjacents prev))) | |
| (defn max-path-sum [tree] | |
| (first (reduce sum-of (reverse tree)))) | |
| ;; To test use the following |
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 pow [x y] | |
| (loop [i y k 1N] | |
| (if (zero? i) | |
| k | |
| (recur (dec i) (* k x))))) | |
| (count (into #{} | |
| (for [a (range 2 101) | |
| b (range 2 101)] | |
| (pow a b)))) |
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 closest-integer-sqrt [x] | |
| (-> x Math/sqrt Math/floor int)) | |
| (defn prime-candidates-above-3 [x] | |
| (lazy-seq (list* (dec (* 6 x)) (inc (* 6 x)) (prime-candidates-above-3 (inc x))))) | |
| (def prime-candidates | |
| (lazy-seq (list* 2 3 (prime-candidates-above-3 1)))) | |
| (def none (comp not some)) |
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 take-while-adjacent | |
| [f coll] | |
| (lazy-seq | |
| (when-let [s (seq coll)] | |
| (if (f (first s) (second s)) | |
| (cons (first s) (take-while-adjacent f (rest s))) | |
| (cons (first s) nil))))) | |
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 game-of-life.core | |
| (:require [game-of-life.utils :refer [sum-of-vectors | |
| setify]])) | |
| (def neighbor-offsets | |
| (into (hash-set) | |
| (for [i (range -1 2) | |
| j (range -1 2) | |
| :when (not= [i j] [0 0])] | |
| [i j]))) |
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 foo [x y] | |
| `(intern *ns* ~x ~y)) | |
| (defmacro def-symbols-across-range | |
| [[from step] & symbols] | |
| (list* 'do | |
| (map foo symbols (range)))) | |
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
| (def event-probability-distribution {:red 20 :green 50 :yellow 30}) | |
| (def color-generator (utils.core/random-event-generator event-probability-distribution)) | |
| (def random-colors (repeatedly color-generator)) | |
| (def sample (take 100 random-colors)) | |
| (frequencies sample) |
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
| (deftest team-score-updation | |
| (testing "Keeps team score when no run scored" | |
| (on-game (helper/add-dot-ball-to-game-on-over game [0 1]) | |
| (is-total-score? 0) | |
| (is-on-over? [0 1]) | |
| (is-striker? "Kirat Boli") | |
| (is-non-striker? "N S Nodhi"))) | |
| (testing "Updates team score and rotates strike when single run scored" | |
| (on-game (helper/add-single-run-to-game-on-over game [0 1]) | |
| (is-total-score? 1) |