Hello!
I've got a problem concerning combinatorics. Unfortunately, I can't describe it abstractly so I try to explain it as a story. :)
Problem:
- There are 100 children on the schoolyard.
- They all have unique heights, assuming the values are 100-199cm.
- You want to build 10 groups, each consisting of 1-99 children.
- How can you build all the groups while the children must be sorted by their height?
- I need all possible solutions for these groups since it isn't hard to find one constellation.
Short and easy:
All 100 children stand side by side. You only have to decide where to split them into groups and find all solutions for this.
Example (values are the heights):
[120 ... 190 ... 199] ... [126 ... 137 ... 144 ... 188] is not possible
[101] ... [104 ... 105 ... 112 ... 149] ... [169 ... 189] is possible
I hope you can help me. Thank you very much in advance!
PS: It's no homework. ;) Normally, I need a function which does this with numbers. But I couldn't describe this abstractly like "building k groups of numbers while all numbers are sorted". I thought you wouldn't understand it this way. :) A solution in PHP would be best but I would be glad to see solutions in other languages as well. :)