On Tue, 2003-08-26 at 11:35, Curt Zirzow wrote:
> * Thus wrote Richard Baskett ([EMAIL PROTECTED]):
> > on 8/26/03 9:57 AM, Robert Cummings at [EMAIL PROTECTED] wrote:
> >
> > > This smells like a trick question... Are the switches connected to the
> > > same light bulb? You've only mentioned one light bulb? 8)
> > >
> > > Cheers,
> > > Rob.
> > >
> > >
> > > On Tue, 2003-08-26 at 12:35, Jay Blanchard wrote:
> > >> Also ask a couple of other questions that require thought, but have
> > >> nothing else to do with code. such as...
> > >>
> > >> In one room you have 3 light switches, each connected to one light bulb
> > >> in another room. How many trips must you make to determine which switch
> > >> is connected to which light bulb?
> >
> > Only one trip, and Im not sure if I should explain or let you guys figure it
> > out :)
>
> toggle_light(1);
> sleep(120);
> toggle_light(1);
>
> toggle_light(2);
> move('self', 'room/');
>
> if ($lightbulb['temp'] > $room['temp']) {
> echo "switch #1";
> } elseif ($lightbulb['ison']) {
> echo "switch #2";
> } else {
> echo "switch #3";
> }
>
unfortunately, this won't work... you need to loop through the
lightbulbs...
try something like:
foreach ($lightbulbs as $bulb){
}
and your if else logic needs a little tweaking so you don't incorrectly
label the "on" lightbulb as being switch #1 since it is also greater
than $temp['room']
see the following manual pages:
http://us4.php.net/manual/en/control-structures.foreach.php
http://us4.php.net/manual/en/thelightbulb-determination-problem.php
http://us4.php.net/manual/en/i-have-too-much-time-on-my-hands.php
</joking>
gabe.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php