On Monday, October 5, 2015 at 2:33:50 PM UTC-4, puzzler wrote:
>
> You're not using the combinatorics library as efficiently as you could 
> be.  Here's the best strategy for generating all the team combinations with 
> the same number of players:
>

Is a combinatorics library even needed for this?

(-> (for [a teams
          b teams
          :when (= (count a) (count b))]
       #{a b})
  (hash-set))

Should produce all distinct pairs with equal player counts, given that 
"teams" is bound to a collection of teams, each of which is a collection of 
player objects, and "seq" works on the former collection and "count" on the 
latter ones. If each team is something more complex (e.g. a map with a 
:players key) things get only slightly more complicated (e.g. changing 
(count a) to (count (:players a))).

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to