Created
March 1, 2017 14:18
-
-
Save LeartS/182f68f00d8eef2e83798db3ec01af71 to your computer and use it in GitHub Desktop.
Estrazioni per il secondo torneo di calcetto!
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
(def players | |
[:agostino :alessio :andrea :cesare :domenico :emanuela :fabio | |
:francesco :gennaro :jean-pierre :leonardo :luca :nelson :pierpaolo :rosario :sara]) | |
(def old-teams | |
(set (map sort [[:agostino :rosario], | |
[:alessio :domenico], | |
[:emanuela :fabio], | |
[:francesco :gennaro], | |
[:pierpaolo :cesare], | |
[:leonardo :andrea], | |
]))) | |
(defn all-valid-teams? | |
"Returns true if all teams are valid (i.e. no old teams)" | |
[teams] | |
(empty (clojure.set/intersection old-teams teams))) | |
(loop [] | |
(let [teams (partition 2 (shuffle players))] | |
(if (all-valid-teams? (set (map sort teams))) (println teams) (recur)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment