-
1 Attachment(s)
Grouping Numbers
Hi to all,
I have a range of 30 integer numbers (see attached zip), which i want to group them in 4 teams and one of the following requirements must be met
1)the sum of the numbers in each team to be the same
or
2)the sum of the numbers in each pair of teams to be the same
any ideas??
-
Just my thoughts....
You could start out taking groups of two (or larger) and try to create groupings that equal each other as a seed (I am not certain that you could have teams that are of different lengths.) and then start adding equal groups as such.
I could see some potential difficulties with this solution though (if you find that the rest of the numbers cannot be divided equally among the rest of the groups, then you will have to throw the run out.)
-
I'd suggest writing a program to brute force it. 40 numbers un any order... that's only:
40! = 8.157 * 10^47 calculations
Only take a few days.
Maybe you'll need a genetic algorythm.
*Edit*
No wait! You only need to try 4 values on each number once. So:
4^40 = 1,21 * 10^24
That's much less. Maybe a few hours. Ok maybe days instead of weeks.
-
thnks for the reply guys. but if u could post some sort of implementation to help me....
i m still very confused
-
OK... the teams are going to be unequal amounts of numbers...
30 numbers
4 teams
The list of numbers happens to total 1000
so for rule 1 - each team must be 250
rule 2.. uh well I think this has a lot more flexible results...
Sounds like a logic problem or an upper level maths problem.
Where did it come from?
Vince
<edit>
I notice all the numbers are divisible by 6 (the lowest denominator)
- something there perhaps?
<edit>
Except 10 :p
</edit>
</edit>
-
it is not just happen but always the sum of all number is equal to 1000. This algorithm i m trying to build is for a statistical program i m trying to build for a lucky game like LOTTO.
I want to make a generic algorithm to produce the 4 teams i stated above so i can use it thorough out my program.
the numbers are going to change but their total sum will always be 1000
-
1 Attachment(s)
Uh well you may want different numbers then ;)
Had a go thought it may be possible.. but I don't think it is with these numbers.
1) Can only get one team of 250 - the rest are 240 or 260 perhaps
2) this is the one I really thought would work - but doesn't appear too. OK, so I based it on the division by 6 - but if only one 10 is outside that division then it won't balanec (two teams equal)...
Attached is my attempts - sorry I couldn't help. A rethink is in order I believe ;)
Vince