Created
July 11, 2012 21:33
-
-
Save ckirkendall/3093732 to your computer and use it in GitHub Desktop.
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 charx [[ch str] idx] | |
(if ch | |
(conj [ch idx] (charx str (inc idx))) | |
()) | |
(defn charxy | |
([str] (charxy (.spit str "\n") 0) | |
([[s1 rst] idx] | |
(if s1 | |
(concat (map (concat % [idx]) (charx s1)) (charxy rst (inc idx))) | |
'())))) |
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 peudo-rand [player-lst] | |
(if (empty? player-lst) '() | |
(let [idx (rand 3) | |
pre (take idx player-lst) | |
[player end] (drop idx player-lst) | |
nlst (concat (butlast pre) end)] | |
(conj player (peudo-rand nlst))))) | |
(defn set-teams [team-lst player-lst] | |
(let [plst (pseudo-rand player-lst) | |
red #(reduce (fn [m [k v]] | |
(if (m k) | |
assoc m k (conj (m k) v)) | |
(assoc m k [v]))) %)] | |
(red (map %(do [%1 %2] team-lst player plst))))) | |
(map set-teams team-divs player-divs) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment