Skip to content

Instantly share code, notes, and snippets.

@ckirkendall
Created July 11, 2012 21:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ckirkendall/3093732 to your computer and use it in GitHub Desktop.
Save ckirkendall/3093732 to your computer and use it in GitHub Desktop.
(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)))
'()))))
(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