Forum: Ruby on Rails Guests and Rooms - programming logic question

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
06dcd1d41f73b7edf56f66a0cb0a54ee?d=identicon&s=25 Jens (Guest)
on 2007-07-03 14:22
(Received via mailing list)
Hi everybody,

I am writing the registration and administration backend for a
worldwide youth club organisation, which will expect about 12'000
visitors next year on their meeting. For the activities and
accommodation, these visitors need to be divided into groups of 15-17
people according to certain criteria.

I'm hoping there is a way for Ruby (maybe Rails) to automate this
task. Here are the rules:

- 15-17 people per group
- all people in one group must be have the same "age range" (13-17,
28-25, 26-35, >35 years). This is easy, just divide them by age range
and treat each age range seperately.
- Siblings should not be seperated, and there should not be more than
one family/sibling-pair in each group. This could be done by leaving
out all users with a "sibling_id" entered, and filling them in later.
- People who checked "Traveling together with ..." in the application
form should not be seperated. (same as above)
- There should be a mix of nationalities, but no language barriers in
one group (ie. everybody must speak at least one common language).

and so on (some other rules aren't fixed yet). I'm actually thinking
to write a script that randomly distributes the people into groups and
then takes all "invalid" groups and re-distributes the people in
there, until all groups are OK by the above rules. But I guess coding
the validation process is just as hard as coming up with a procedure
that does this distribution in an "orderly" fashion, and is extensible
with additional rules where necessary.

Any ideas would be great. I could perhaps code this in a dumb
procedural fashion using lots of if, while, and for loops; but I kind
of suspect that Ruby can do better than that.

This topic is locked and can not be replied to.