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
;; 2 blue balls, 6 yellow balls | |
;; opt a - take 3, win if there are not 2 blue | |
;; opt b - take 1, win if it isn't blue | |
;; which option better? | |
;;(def bag {:blueballs #{'x 'y} :yellow-balls #{'a 'b 'c 'd 'e 'f}}) | |
;;(def bag [1 1 0 0 0 0 0 0]) | |
(def prototype-bag |
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 demo.core) | |
;; inputs are "litres/s" | |
;; bucket is leaking 1 l/s | |
;; bucket has capacity of 10 | |
;; does the input overflow the bucket? | |
(defn leaky-bucket-overflowing? | |
[limit list] | |
(->> list |
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 demo.ui | |
(:require | |
[reagent.core :as r])) | |
(defonce state (r/atom {:game-board [[:x :o :x] [:o nil nil] [nil nil nil]] | |
:current-player :x})) | |
;; "how can i represent any moment of my app as a dictionary" | |
(defn flip0 [player] | |
(if (= player :x) |
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 exercises.core | |
(:require | |
[clojure.walk :as walk])) | |
;; trie | |
; "hello" | |
; "hi" | |
; "he" |
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 exercises.september | |
(:require [criterium.core :as criterium])) | |
#_(+ 1 2 3) | |
#_(println "asdasd") | |
(defn clamp [v min max] | |
(cond | |
(< v min) min |
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 exercises.marketplace) | |
;; there is marketplace of vendors | |
;; each offering a certain amount of foos for bars | |
;; want to be able to convert from foos to bars | |
;; function 1 - show cost of converting some number of foos to bars, via multiple trades in marketplace (ex. 2 foo => 5 bars) | |
;; function 2 - path to achieve that conversion 1 foo => 4 cats => 2 zigs => 25 bars | |
(def offers | |
[{:from [4 :banana] |
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
(cleave 5 [#(* % 2) dec #(* % %)]) | |
;; => [10 4 25] | |
(defn cleave [x fs] | |
((apply juxt fs) x)) | |
(defn cleave2 [x fs] | |
(map #(% x) fs)) |
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 demo) | |
(defn hello [] | |
"sagasgd x") | |
(defonce run? (atom true)) | |
(defn run [] | |
(future | |
(Thread/sleep 1000) |
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 dota2viz.client.graph | |
(:require | |
[clojure.string :as string])) | |
(defn interpolate | |
[x [x0 x1] [y0 y1]] | |
(+ y0 (/ (* (- x x0) | |
(- y1 y0)) | |
(- x1 x0)))) |
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
(defmethod read :episodes/all | |
[{:keys [state query]} _ _] | |
(let [episodes (->> (d/q '[:find (pull ?entity ?pattern) | |
:in $ ?pattern | |
:where [?entity :episode/name]] | |
@state | |
query) | |
(map first) | |
vec)] | |
(if (seq episodes) |
NewerOlder