Re: PHP Brain Teasers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 6/26/07, Daniel Brown <parasane@xxxxxxxxx> wrote:
   What the hell?  Why not start a thread that can be fun and
challenging for all of us.  It's something I haven't seen done
anywhere else yet, but I wouldn't be surprised if it has been.  Let's
put together some names, phrases, and other stuff expressed as PHP
code and see who can come up with a real stumper.  For example:

<?
   while($u_work) {
       whistle();
   }
?>

   .... would be "Whistle While You Work."

   Try to use some really common phrases that all of us around the
world should recognize, but feel free to get really elaborate with the
code.

   So here's the first one (it's simple):

Yes, of course, call it simple... :P It took me 20 minutes to figure
it out :S :P


<?

function at($level) {
       $level == 10 ? $ret = "winner" : '';
       $level == 15 ? $ret = "try" : '';
       $level == 20 ? $ret = "first" : '';
       $level == 25 ? $ret = "user" : '';
       $level == 30 ? $ret = "place" : '';
       $level == 35 ? $ret = "again" : '';
       $level == 40 ? $ret = "succeed" : '';
       $level == 45 ? $ret = "last" : '';
       $level == 50 ? $ret = "finish" : '';
       return $ret;
}

if(at(20) != "succeed") {
       try {
               $e = "again";
               throw new Exception($e);
       } catch(Exception $e) {
               echo "Try ".$e->getMessage()."\n";
       }
}
?>

--
Daniel P. Brown

Oh, and how do we make such things? Is there a manual about them? :P

TIjnema


--
Vote for PHP Color Coding in Gmail! -> http://gpcc.tijnema.info

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux