Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
(defn dutch-flag-order [color]
|
||||
(get {:red 1 :white 2 :blue 3} color))
|
||||
|
||||
(defn sort-in-dutch-flag-order [balls]
|
||||
(sort-by dutch-flag-order balls))
|
||||
|
||||
;; Get a collection of 'n' balls of Dutch-flag colors
|
||||
(defn random-balls [num-balls]
|
||||
(repeatedly num-balls
|
||||
#(rand-nth [:red :white :blue])))
|
||||
|
||||
;; Get random set of balls and insure they're not accidentally sorted
|
||||
(defn starting-balls [num-balls]
|
||||
(let [balls (random-balls num-balls)
|
||||
in-dutch-flag-order? (= balls
|
||||
(sort-in-dutch-flag-order balls))]
|
||||
(if in-dutch-flag-order?
|
||||
(recur num-balls)
|
||||
balls)))
|
||||
Loading…
Add table
Add a link
Reference in a new issue