Re: [PHP] PHP Brain Teasers
tedd wrote: 2b || !2b this is not javascript dude. $_2b | ~$_2b; that said this is one of the coolest so far, nice one tedd. Cheers, tedd -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/6/07, tedd [EMAIL PROTECTED] wrote: My favorite. /world End of the world. Great! Brice Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/5/07, tedd [EMAIL PROTECTED] wrote: My favorite. /world Fan-freaking-tastic! I've never seen it before (I live under a rock), but it has so many potential uses. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
while( TRUE ) { $actions++; $words--; } $bets = array(1,2,3,4,5); unset( $bets ); $arr = array( 'this', 'that', 'times' ); $arr[] = 'behind'; for( $i = 0; $i = 6; $i++ ) { $deep++; } for( $i = 0; $i = 5; $i++ ) { $flies--; } thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/5/07, Chris Boget [EMAIL PROTECTED] wrote: while( TRUE ) { $actions++; $words--; } Actions speak louder than words. $bets = array(1,2,3,4,5); unset( $bets ); All bets are off. $arr = array( 'this', 'that', 'times' ); $arr[] = 'behind'; Behind the times. for( $i = 0; $i = 6; $i++ ) { $deep++; } Deep Six. for( $i = 0; $i = 5; $i++ ) { $flies--; } Time flies backwards? // Not sure on this one. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
Actions speak louder than words. Yup. All bets are off. Indeed. Behind the times. Correct. Deep Six. Got it. for( $i = 0; $i = 5; $i++ ) { $flies--; } Time flies backwards? // Not sure on this one. I wasn't sure if this one was done well enough; I guess it wasn't. The answer is 'Dropping like flies'. :p thnx, Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
2b || !2b Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
My favorite. /world Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
At 9:20 PM +0100 7/5/07, Chris Boget wrote: while( TRUE ) { $actions++; $words--; } $bets = array(1,2,3,4,5); unset( $bets ); $arr = array( 'this', 'that', 'times' ); $arr[] = 'behind'; for( $i = 0; $i = 6; $i++ ) { $deep++; } for( $i = 0; $i = 5; $i++ ) { $flies--; } thnx, Chris In similar vein. $actions $words Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
To be.. or not to be? On 7/5/07, tedd [EMAIL PROTECTED] wrote: 2b || !2b Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
$chickens = 1000; $roost = 0 $home = false; while ($chickens != $roost) { $chickens--; $roost++; } $home = true; Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
tedd wrote: $chickens = 1000; $roost = 0 $home = false; while ($chickens != $roost) { $chickens--; $roost++; } $home = true; The chickens have come home to roost. class Here { private $chickens; } -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On Wed, 2007-07-04 at 10:18 -0400, tedd wrote: $chickens = 1000; $roost = 0 $home = false; while ($chickens != $roost) { $chickens--; $roost++; } $home = true; When the chickens come home to roost. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On Tue, June 26, 2007 7:14 pm, Robert Cummings wrote: On Tue, 2007-06-26 at 17:00 -0700, Eric Newberry wrote: I think I have to answer to this one: 'If at first you don't succeed try, try again'. Here's another one... ?php $x = rand( 1, 20 ); for( $i = 0; $i $x; $i++ ); while( --$i 0 ); ? Didn't see an answer to this one... So I'll double-whammy it with a Name That Tune factor: ?php class Thread { var $wheel; function Thread (){ $this-wheel = 'roun\''; } } while($wheel = new Thread()); ? -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On Tue, 2007-07-03 at 02:17 -0500, Richard Lynch wrote: On Tue, June 26, 2007 7:14 pm, Robert Cummings wrote: On Tue, 2007-06-26 at 17:00 -0700, Eric Newberry wrote: I think I have to answer to this one: 'If at first you don't succeed try, try again'. Here's another one... ?php $x = rand( 1, 20 ); for( $i = 0; $i $x; $i++ ); while( --$i 0 ); ? Didn't see an answer to this one... It was pretty simple... What goes up must come down. :) So I'll double-whammy it with a Name That Tune factor: ?php class Thread { var $wheel; function Thread (){ $this-wheel = 'roun\''; } } while($wheel = new Thread()); ? Bleh, I'm stuck :B Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2007-07-03 at 02:17 -0500, Richard Lynch wrote: On Tue, June 26, 2007 7:14 pm, Robert Cummings wrote: On Tue, 2007-06-26 at 17:00 -0700, Eric Newberry wrote: I think I have to answer to this one: 'If at first you don't succeed try, try again'. Here's another one... ?php $x = rand( 1, 20 ); for( $i = 0; $i $x; $i++ ); while( --$i 0 ); ? Didn't see an answer to this one... It was pretty simple... What goes up must come down. :) So I'll double-whammy it with a Name That Tune factor: ?php class Thread { var $wheel; function Thread (){ $this-wheel = 'roun\''; } } while($wheel = new Thread()); ? Bleh, I'm stuck :B Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The wheel goes roun and roun [sic] -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Daniel Brown [EMAIL PROTECTED] wrote: On 7/3/07, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2007-07-03 at 02:17 -0500, Richard Lynch wrote: On Tue, June 26, 2007 7:14 pm, Robert Cummings wrote: On Tue, 2007-06-26 at 17:00 -0700, Eric Newberry wrote: I think I have to answer to this one: 'If at first you don't succeed try, try again'. Here's another one... ?php $x = rand( 1, 20 ); for( $i = 0; $i $x; $i++ ); while( --$i 0 ); ? Didn't see an answer to this one... It was pretty simple... What goes up must come down. :) So I'll double-whammy it with a Name That Tune factor: ?php class Thread { var $wheel; function Thread (){ $this-wheel = 'roun\''; } } while($wheel = new Thread()); ? Bleh, I'm stuck :B Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php The wheel goes roun and roun [sic] -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 A similar one: ? function sing($ignore) { echo It's a song!\n; } (float) $bus; $bus = 14.750; while($wheels = round($bus,2)) { sing($wheels); } ? -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On Tue, 2007-07-03 at 10:36 -0400, Daniel Brown wrote: A similar one: ? function sing($ignore) { echo It's a song!\n; } (float) $bus; $bus = 14.750; while($wheels = round($bus,2)) { sing($wheels); } ? Well when you say it like that... you trigger my kid friendly singing side that I picked up while bringing my son to playgroup :) Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Robert Cummings [EMAIL PROTECTED] wrote: On Tue, 2007-07-03 at 10:36 -0400, Daniel Brown wrote: A similar one: ? function sing($ignore) { echo It's a song!\n; } (float) $bus; $bus = 14.750; while($wheels = round($bus,2)) { sing($wheels); } ? Well when you say it like that... you trigger my kid friendly singing side that I picked up while bringing my son to playgroup :) Ha! Kids will do that to ya', that's for sure! -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
[snip] So I'll double-whammy it with a Name That Tune factor: ?php class Thread { var $wheel; function Thread (){ $this-wheel = 'roun\''; } } while($wheel = new Thread()); ? The wheel goes roun and roun [sic] [/snip] if($x == 0.01 || $x == 1.0){ $y = in; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] if($x == 0.01 || $x == 1.0){ $y = in; } One in a thousand ? [/snip] Nope. Yes it is, you just don't know it yet. ;-P -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] So I'll double-whammy it with a Name That Tune factor: ?php class Thread { var $wheel; function Thread (){ $this-wheel = 'roun\''; } } while($wheel = new Thread()); ? The wheel goes roun and roun [sic] [/snip] if($x == 0.01 || $x == 1.0){ $y = in; } One in a thousand ? -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
[snip] if($x == 0.01 || $x == 1.0){ $y = in; } One in a thousand ? [/snip] Nope. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
Ok, I'll play. Phrase: one = rand(1,100); Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
[snip] Ok, I'll play. Phrase: one = rand(1,100); [/snip] One in a million. Still waiting to see if who gets the last one I posted. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
[snip] if($x == 0.01 || $x == 1.0){ $y = in; } [/snip] Anyone? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
At 7/3/2007 12:11 PM, Jay Blanchard wrote: [snip] if($x == 0.01 || $x == 1.0){ $y = in; } [/snip] In for a penny, in for a pound. Metric, that is! Regards, Paul __ Paul Novitski Juniper Webcraft Ltd. http://juniperwebcraft.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
[snip] At 7/3/2007 12:11 PM, Jay Blanchard wrote: [snip] if($x == 0.01 || $x == 1.0){ $y = in; } [/snip] In for a penny, in for a pound. Metric, that is! [/snip] Correct! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] if($x == 0.01 || $x == 1.0){ $y = in; } [/snip] Anyone? Hint? ;) 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
RE: [PHP] PHP Brain Teasers
[snip] In for a penny, in for a pound. Metric, that is! Correct! [/snip] Another...(way easy) $one = six; $other = half-dozen; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Jay Blanchard [EMAIL PROTECTED] wrote: Another...(way easy) Y'think? Heh. $one = six; $other = half-dozen; -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
My two bits... if (goose($its)) { $gander = $its; } -and- for ($things = 1; $things 0; $things++) { for ($x = 0; $x $things; $x++) { $they = the same; } } John -Original Message- From: Daniel Brown [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 03, 2007 3:13 PM To: Jay Blanchard Cc: Paul Novitski; php-general@lists.php.net Subject: Re: [PHP] PHP Brain Teasers On 7/3/07, Jay Blanchard [EMAIL PROTECTED] wrote: Another...(way easy) Y'think? Heh. $one = six; $other = half-dozen; -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
[snip] if (goose($its)) { $gander = $its; } [/snip] What's good for the goose is good for the gander. [snip] for ($things = 1; $things 0; $things++) { for ($x = 0; $x $things; $x++) { $they = the same; } } [/snip] The more things change the more they stay the same. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] if (goose($its)) { $gander = $its; } [/snip] What's good for the goose is good for the gander. [snip] for ($things = 1; $things 0; $things++) { for ($x = 0; $x $things; $x++) { $they = the same; } } [/snip] The more things change the more they stay the same. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Oh, you bastard! I was going to answer that one first! ;-P Good ones, John. And to my friends here in the US, happy 4th to all of you. Be safe and enjoy! -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
[snip] Another...(way easy) Y'think? Heh. $one = six; $other = half-dozen; [/snip] function esquireEliminate($x){ unset($x); } $lawyers = 10; for($i = 0; $i $lawyers; $i++){ eliminateEsquire($i); } Shakespeare has his day in code! -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 7/3/07, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] Another...(way easy) Y'think? Heh. $one = six; $other = half-dozen; [/snip] function esquireEliminate($x){ unset($x); } $lawyers = 10; for($i = 0; $i $lawyers; $i++){ eliminateEsquire($i); } Shakespeare has his day in code! Ha! Nice The first thing we do, let's kill all the lawyers. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
Daniel Brown wrote: On 7/3/07, Jay Blanchard [EMAIL PROTECTED] wrote: [snip] Another...(way easy) Y'think? Heh. $one = six; $other = half-dozen; [/snip] function esquireEliminate($x){ unset($x); } $lawyers = 10; for($i = 0; $i $lawyers; $i++){ eliminateEsquire($i); } Shakespeare has his day in code! Ha! Nice The first thing we do, let's kill all the lawyers. Except that code technically copies all the lawyers and then kills the copy. But that's probably being over-pedantic. -Stut -- http://stut.net/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On Tue, 2007-07-03 at 18:09 -0400, Daniel Brown wrote: The first thing we do, let's kill all the lawyers. Let's wait a few more years, I like my soilent green fresh. Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
ok this one should be easy: ? $animal = array (pig,cow,bat,chicken,dog); for ($i = 0; $i sizeof($animal); $i++) { $sighted = ($animal[$i] != bat ? see : blind); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers [SPOILER]
On 6/29/07, clive [EMAIL PROTECTED] wrote: ok this one should be easy: ? $animal = array (pig,cow,bat,chicken,dog); for ($i = 0; $i sizeof($animal); $i++) { $sighted = ($animal[$i] != bat ? see : blind); } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php Blind as a bat. -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
Daniel Brown wrote: What the hell? Why not start a thread that can be fun and ... here's a easy one: interface Currency {} interface Employee {} class Peanut implements Currency {} class Primate implements Employee {} abstract class HeadHunter { static function match(Currency $c) { if ($c instanceof Peanut) return new Primate; throw new Exception(never heard of outsourcing?); } } try { echo get_class(HeadHunter::match(new Peanut)),\n; } catch (Exception $e) { echo $e-getMessage(),\n; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 6/26/07, Daniel Brown [EMAIL PROTECTED] 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
RE: [PHP] PHP Brain Teasers
So here's the first one (it's simple): ? 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; } } ? The correct answer is: Parse error: parse error, unexpected '{' in /var/www/html/m.php on line 17 Oh well, you know what they say: If at first you don't succeed... JM -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 6/26/07, Tijnema [EMAIL PROTECTED] wrote: On 6/26/07, Daniel Brown [EMAIL PROTECTED] 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 No, I just made some stuff up. I thought it could be fun, and a decent exercise in coding. Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( How so? I didn't use any 5th Generation-specific code -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
Daniel Brown wrote: On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( How so? I didn't use any 5th Generation-specific code er? catch, throw, try (again ;-) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] PHP Brain Teasers
On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( How so? I didn't use any 5th Generation-specific code http://us.php.net/try says: PHP 5 has an exception model similar to that of other programming languages I take that to mean that the throw/catch/try stuff is specific to PHP5, no? Maybe its a cut/paste error? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: On 6/26/07, Jim Moseby [EMAIL PROTECTED] wrote: Jim, I didn't get any parse errors when I tested it, it just output the stuff. You're right though that is what they say Bah - thwarted (again) by PHP4. :( How so? I didn't use any 5th Generation-specific code http://us.php.net/try says: PHP 5 has an exception model similar to that of other programming languages I take that to mean that the throw/catch/try stuff is specific to PHP5, no? Maybe its a cut/paste error? Yes, defenitly for PHP5 only, to be 100% sure, I tested it on my PHP4 server (parse error) and then run the same server with PHP5 module, and it says: Try again 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
Re: [PHP] PHP Brain Teasers
I think I have to answer to this one: 'If at first you don't succeed try, try again'. Eric ? 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; } } ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
On Tue, 2007-06-26 at 17:00 -0700, Eric Newberry wrote: I think I have to answer to this one: 'If at first you don't succeed try, try again'. Here's another one... ?php $x = rand( 1, 20 ); for( $i = 0; $i $x; $i++ ); while( --$i 0 ); ? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] PHP Brain Teasers
- Original Message - From: Robert Cummings [EMAIL PROTECTED] To: Eric Newberry [EMAIL PROTECTED] Cc: php-general@lists.php.net Sent: Tuesday, June 26, 2007 5:14 PM Subject: Re: [PHP] PHP Brain Teasers On Tue, 2007-06-26 at 17:00 -0700, Eric Newberry wrote: I think I have to answer to this one: 'If at first you don't succeed try, try again'. Here's another one... ?php $x = rand( 1, 20 ); for( $i = 0; $i $x; $i++ ); while( --$i 0 ); ? Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php