[PHP] Algorithm Help
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? Thanks! Floyd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] delete S3 bucket with AWS PHP SDK
Hey Tim, It seems that deleteObject takes in 2 params, and you are sending it 1 param. I would recommend you look at the documentation and make sure you are sending the right params. Aziz On Sun, Sep 29, 2013 at 10:29 PM, Tim Dunphy wrote: > Hi Aziz, > > Thank you for getting back to me! > > I appreciate you spotting that error. > > So I corrected that > >require_once 'sdk.class.php'; > if (isset($_POST['submit'])) { > > * $bucket_name = $_POST['bucket_name'];* > > // Create the S3 Object from the SDK > $s3 = new AmazonS3(); > * > $result = $s3->deleteObject(array( > 'Bucket' => $bucket_name ));* > > > // The response comes back as a Simple XML Object > // In this case we just want to know if everything was okay. > // If not, report the message from the XML response. > if ((int) $response->isOK()) { > echo 'Deleted Bucket'; > echo ''; > echo 'List Buckets'; > } else { > echo (string) $response->body->Message; > } > //echo ''; > } > ?> > > Delete S3 Bucket > > Bucket Name: >* > * > > >
Re: [PHP] Algorithm Help
On 10/1/2013 12:51 PM, Floyd Resler 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? Thanks! Floyd Whatever solution you're going with will probably involve a relational database of some sort. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Algorithm Help
DB or flatfile? I would create a matrix of all kids crossed with every kid. Everytime a kid is put in a home with another kid, ++ that index. When dispatching kids, sort by index ASC. Aziz On Tue, Oct 1, 2013 at 3:01 PM, John Meyer wrote: > On 10/1/2013 12:51 PM, Floyd Resler 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? >> >> Thanks! >> Floyd >> >> >> Whatever solution you're going with will probably involve a relational > database of some sort. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >
Re: [PHP] Algorithm Help
On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: > DB or flatfile? > > I would create a matrix of all kids crossed with every kid. Everytime a kid > is put in a home with another kid, ++ that index. When dispatching kids, > sort by index ASC. > > Aziz > > > On Tue, Oct 1, 2013 at 3:01 PM, John Meyer > wrote: > > > On 10/1/2013 12:51 PM, Floyd Resler 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? > >> > >> Thanks! > >> Floyd > >> > >> > >> Whatever solution you're going with will probably involve a relational > > database of some sort. > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, visit: http://www.php.net/unsub.php > > > > This sounds remarkably like homework, which we can't help you with unless you've got a specific problem that you're stuck with. Thanks, Ash http://www.ashleysheridan.co.uk
Re: [PHP] Algorithm Help
m 1375 GLENDALE MILFORD RD., CINCINNATI, OH 45215 On Oct 1, 2013, at 3:14 PM, Ashley Sheridan wrote: > On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: > >> DB or flatfile? >> >> I would create a matrix of all kids crossed with every kid. Everytime a kid >> is put in a home with another kid, ++ that index. When dispatching kids, >> sort by index ASC. >> >> Aziz >> >> >> On Tue, Oct 1, 2013 at 3:01 PM, John Meyer >> wrote: >> >>> On 10/1/2013 12:51 PM, Floyd Resler 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? Thanks! Floyd Whatever solution you're going with will probably involve a relational >>> database of some sort. >>> >>> >>> -- >>> PHP General Mailing List (http://www.php.net/) >>> To unsubscribe, visit: http://www.php.net/unsub.php >>> >>> > > > This sounds remarkably like homework, which we can't help you with > unless you've got a specific problem that you're stuck with. > > Thanks, > Ash > http://www.ashleysheridan.co.uk > > Oh, no, this is definitely not homework! :) Although it certainly seems like a homework question. This is a real world problem. I'm keeping track of which kids stay with which host families in the database. My initial approach was to start with kid 1 and see how many times the other kids have stayed with kid 1. The move on to kid 2, and so it. This gives me a score for pairs of kids. However, if say three kids are staying at a host family, what is the best way to determine which set of three kids have stayed together the least? Thanks! Floyd
Re: [PHP] Algorithm Help
Assuming you don't have to be exact, somthing similar to this might work. Assign each kid to a host family randomly for each kid, check how frequently it has been combined with the kids in its assigned family. if it is too close, swap with a different family when all kids in that family are processed, move on to the next family and repeat, excluding the first family for swapping. do the same for all families excluding the previous families. when you have completed all families, do another iteration or two of the whole process. Kind regards/met vriendelijke groet, Serge Fonville http://www.sergefonville.nl 2013/10/1 Floyd Resler > m > > 1375 GLENDALE MILFORD RD., CINCINNATI, OH 45215 > > On Oct 1, 2013, at 3:14 PM, Ashley Sheridan > wrote: > > > On Tue, 2013-10-01 at 15:09 -0400, Aziz Saleh wrote: > > > >> DB or flatfile? > >> > >> I would create a matrix of all kids crossed with every kid. Everytime a > kid > >> is put in a home with another kid, ++ that index. When dispatching kids, > >> sort by index ASC. > >> > >> Aziz > >> > >> > >> On Tue, Oct 1, 2013 at 3:01 PM, John Meyer < > johnme...@pueblocomputing.com>wrote: > >> > >>> On 10/1/2013 12:51 PM, Floyd Resler 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? > > Thanks! > Floyd > > > Whatever solution you're going with will probably involve a relational > >>> database of some sort. > >>> > >>> > >>> -- > >>> PHP General Mailing List (http://www.php.net/) > >>> To unsubscribe, visit: http://www.php.net/unsub.php > >>> > >>> > > > > > > This sounds remarkably like homework, which we can't help you with > > unless you've got a specific problem that you're stuck with. > > > > Thanks, > > Ash > > http://www.ashleysheridan.co.uk > > > > > > Oh, no, this is definitely not homework! :) Although it certainly seems > like a homework question. This is a real world problem. I'm keeping track > of which kids stay with which host families in the database. My initial > approach was to start with kid 1 and see how many times the other kids have > stayed with kid 1. The move on to kid 2, and so it. This gives me a score > for pairs of kids. However, if say three kids are staying at a host > family, what is the best way to determine which set of three kids have > stayed together the least? > > Thanks! > Floyd > >