On 1 Oct 2013, at 19:51, Floyd Resler <fres...@adex-intl.com> wrote:

> Here's my task: A group of kids is going to be staying with different host 
> families throughout the next 8 months.  The number of kids staying with a 
> host family can range from 2 to 10.  When deciding which kids should stay 
> together at a host family, the idea is for the system to put together kids 
> who have stayed with each other the least on past weekends.  So, if a host 
> family can keep 5 kids, then the group of 5 kids who have stayed together the 
> least will be chosen.
> 
> I can't think of an easy, quick way to accomplish this.  I've tried various 
> approaches that have resulted in a lot of coding and being very slow.  My 
> idea was to give each group of kids a score and the lowest score is the group 
> that is selected.  However, this approach wound of iterating through several 
> arrays several times which was really slow.  Does anyone have any ideas on 
> this puzzle?

Sounds like a job for a directed graph data structure. I wish I had time to 
knock up a solution but I don't right now. This article should help you get 
started: 
http://www.codediesel.com/algorithms/building-a-graph-data-structure-in-php/

-Stuart

-- 
Stuart Dallas
3ft9 Ltd
http://3ft9.com/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to