Skip to content

Instantly share code, notes, and snippets.

@LeartS
Created March 1, 2017 14:18
Show Gist options
  • Save LeartS/182f68f00d8eef2e83798db3ec01af71 to your computer and use it in GitHub Desktop.
Save LeartS/182f68f00d8eef2e83798db3ec01af71 to your computer and use it in GitHub Desktop.
Estrazioni per il secondo torneo di calcetto!
(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