Re: Generate all possible teams

2015-10-07 Thread Gerrit Jansen van Vuuren
Have a look at http://www.afronski.pl/sicp-in-clojure/2015/10/05/sicp-in-clojure-chapter-4.html scroll to "Ambiguous operator", this implements searching for combinations in a search space based on the conditions you give it using backtracking, also as already mentioned you could directly g

Re: Generate all possible teams

2015-10-05 Thread Mark Engelberg
On Mon, Oct 5, 2015 at 1:08 PM, andrea crotti wrote: > Yes I came up with the same idea in the end, this is the code that does > that. > > (defn list-teams-combo [players] > "List all the possible team combinations" > (let [players-count (count players) > size (/ (combo/count-combinat

Re: Generate all possible teams

2015-10-05 Thread andrea crotti
2015-10-05 19:33 GMT+01:00 Mark Engelberg : > 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: > > Case 1: Even number of players. > Let's call the first player "A". "A"

Re: Generate all possible teams

2015-10-05 Thread Fluid Dynamics
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?

Re: Generate all possible teams

2015-10-05 Thread Mark Engelberg
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: Case 1: Even number of players. Let's call the first player "A". "A" is going to be assigned to a team. To avoid duplicatio

Re: Generate all possible teams

2015-10-05 Thread andrea crotti
Yes this could actually work thanks, I only need to iterate over all the possible permutations of the first partition and combine it, still certainly a lot less stuff to compute. 2015-10-05 12:08 GMT+01:00 Franklin M. Siler : > On Oct 5, 2015, at 0545, andrea crotti wrote: > >> Any idea how to ma

Re: Generate all possible teams

2015-10-05 Thread andrea crotti
1. it could be odd in case we don't manage, the first solution I did was just a greedy algorithm, but that only worked with even number of players 2. yes well now I pass the rankings and the list of players separately, but yeah every player will be part of a team 3. this looks the same as 1), and s

Re: Generate all possible teams

2015-10-05 Thread andrea crotti
Yes so well for example the rankings can be defined in this way [{:name "P1" :skills {:control 3 :speed 3 :tackle 4 :dribbling 10 :shoot 4} :position :attack} {:name "P2" :skills {:control 3 :speed 3 :tackle 4 :dr

Re: Generate all possible teams

2015-10-05 Thread Mark Engelberg
Sample input data would also be useful, including some examples that are too large for you to currently solve with your existing approach. On Mon, Oct 5, 2015 at 4:36 AM, 'Alan Forrester' via Clojure < clojure@googlegroups.com> wrote: > On 5 Oct 2015, at 11:45, andrea crotti wrote: > > > Hi ever

Re: Generate all possible teams

2015-10-05 Thread 'Alan Forrester' via Clojure
On 5 Oct 2015, at 11:45, andrea crotti wrote: > Hi everyone, > > I was trying for fun to solve the following problem: > > given a list of football players with some defined skills, find out which > team selection would be balanced. > > For example given just 4 players A, B, C, D there would be

Re: Generate all possible teams

2015-10-05 Thread Mark Engelberg
Are there an even number of players? Are all players assigned to teams? Are the two teams necessarily of equal sizes? On Mon, Oct 5, 2015 at 3:45 AM, andrea crotti wrote: > Hi everyone, > > I was trying for fun to solve the following problem: > > given a list of football players with some define

Re: Generate all possible teams

2015-10-05 Thread Franklin M. Siler
On Oct 5, 2015, at 0545, andrea crotti wrote: > Any idea how to make this faster? > Other advices on the code are welcome as well.. Why not generate the the possible left-hand teams and then cartesian product with the leftover players? E.g., if you want to match 2 on 2 and have players A B C