TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 02-28-2008, 12:06 AM   #21 (permalink)
The Wanderer
 
Join Date: Feb 2008
Posts: 18
Thanks: 0
CHASE is on a distinguished road
Default

I'm not sure if this follows the rule of 8 lines perfectly, but I did my best, and wasn't sure what a "line" was defined at.

PHP Code:
<?php

    $a 
1;
    
$b 2;
    
    
$string "The quick brown fox jumps over the lazy dog.";
    
$string explode(" "$string);
    
    foreach ( 
$string as $line )
    {
        if ( 
$numb == $a )
        {
            
$numb $b;
        }
        else
        {
            
$numb $a;
        }
        
        
$array[] = $numb;
    }
    
    
$a $array[1];
    
$b $array[2];
    
    
var_dump($a);
    
var_dump($b);
    
?>

Last edited by CHASE : 02-28-2008 at 06:46 AM.
Send a message via AIM to CHASE Send a message via MSN to CHASE Send a message via Skype™ to CHASE
CHASE is offline  
Reply With Quote
Old 02-28-2008, 01:00 AM   #22 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,258
Thanks: 90
Wildhoney is on a distinguished road
Default

It's a jolly good attempt, Chase! We've had some wonderful additions. Really put my attempt to shame !
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 02-28-2008, 04:29 PM   #23 (permalink)
The Wanderer
 
Join Date: Feb 2008
Posts: 18
Thanks: 0
CHASE is on a distinguished road
Default

Had to make a fix to my code. It wasn't swapping the two variables, just overwriting them with 1 or 2. Now it's back on track ;)
__________________
World domination would be much easier, if you would all just surrender to me already.
Send a message via AIM to CHASE Send a message via MSN to CHASE Send a message via Skype™ to CHASE
CHASE is offline  
Reply With Quote
Old 03-26-2009, 08:28 PM   #24 (permalink)
The Contributor
 
Join Date: Mar 2008
Posts: 62
Thanks: 2
Seraskier is on a distinguished road
Default

codefreek thanked every post....

PHP Code:
<?php
$a
=1;
$b=2;

$a++;
$b--;
?>
hah, didnt see that one.
Send a message via MSN to Seraskier
Seraskier is offline  
Reply With Quote
Old 04-04-2009, 10:46 AM   #25 (permalink)
The Contributor
 
Sakakuchi's Avatar
 
Join Date: Feb 2009
Posts: 64
Thanks: 1
Sakakuchi is on a distinguished road
Default

Damn, you guys make my head blow.

Here is my try:
PHP Code:
$a 1;
$b 2;

$a += $b;
$b $a $b;
$a -= $b;
echo 
'$b = ' $b '<br />';
echo 
'$a = ' $a
And another one, think its quite smooth
PHP Code:


$a 
1;
$b 2;
if(
$b $a && $a $b)echo '$b = ' $b .'<br />$a = ' $a
Sakakuchi is offline  
Reply With Quote
Old 04-08-2009, 10:47 PM   #26 (permalink)
Wizard
Top Contributor 
 
Village Idiot's Avatar
 
Join Date: Sep 2007
Posts: 1,296
Thanks: 17
Village Idiot is on a distinguished road
Default

I haven't done any in a while. This certainly is not inventive, just lower level that need be.
C++
Code:
    int a = 0;
    int b = 1;
    int temp;

    int *addrA = &a;
    int *addrB = &b;
    temp = *addrA;
    a = *addrB;
    b = temp;
What this code does:
Assign 2 ints with the value of zero and one respectively
Assign two pointers to the memory address of each
Manually go into memory and get the values opposed to letting C++ do it.
__________________

Village Idiot is offline  
Reply With Quote
Old 06-25-2009, 01:13 AM   #27 (permalink)
The Wanderer
 
Mike's Avatar
 
Join Date: Jun 2009
Posts: 11
Thanks: 0
Mike is on a distinguished road
Default

Quote:
Originally Posted by Sakakuchi View Post
Damn, you guys make my head blow.

Here is my try:
PHP Code:
$a 1;
$b 2;

$a += $b;
$b $a $b;
$a -= $b;
echo 
'$b = ' $b '<br />';
echo 
'$a = ' $a
Damn, i like this one, it's awsome, it's simple and works in any language

Last edited by Mike : 06-25-2009 at 03:42 AM.
Mike is offline  
Reply With Quote
Old 06-25-2009, 02:33 AM   #28 (permalink)
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,258
Thanks: 90
Wildhoney is on a distinguished road
Default

Haha Einstein does live after all! We've had some utter madness in this thread.
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote
Old 06-25-2009, 05:16 AM   #29 (permalink)
The Addict
 
adamdecaf's Avatar
 
Join Date: May 2009
Posts: 287
Thanks: 5
adamdecaf is on a distinguished road
Default

Anyone who knows what I'm doing gets a cookie!

PHP Code:
<?php
var $a$b;

$t pow(210);
    
$t pow(($t $t), 2);

// First
    
for ($n 0$n <= $t$n++) {
       
$b pow(-1$n);
           
$b *= 4;
       
$b /= ($n) + 1;
    }

$b %= 2;


// Next
$t /= 2;
    for (
$n 0$n <= $t$n++) {
        
$a pow((1+(1/$n)), $n);
    }
    
$a -= $b;
?>
It's not really inventive, just really CPU intensive. FYI please don't run this script.

Another try:
PHP Code:
<?php
// Start
   
$f = Array();
      
$f[0] = 0;
      
$f[1] = 1;

// Note the pattern....
for ($n 2$n 7$n++) {
   
$f[$n] = $f[$n 1] + $f[$n 2]; 
}

echo 
'b: ' $f[2] , ' ' 'a: ' $f[3];

?>
__________________
My Site
adamdecaf is offline  
Reply With Quote
Old 08-17-2009, 11:43 AM   #30 (permalink)
The Wanderer
 
eStrategy's Avatar
 
Join Date: Aug 2009
Location: Torquay
Posts: 16
Thanks: 2
eStrategy is on a distinguished road
Default

Just a quick one cos im supposed to be working really.

PHP Code:
<?php

    $a 
1;
    
$b 2;
    
    
$ar = array('cat'=>$a&97,'dog'=>$b&98);
    
$a $ar['dog'];
    
$b $ar['cat'];
    
    echo 
'a: '.$a.'<br />b: '.$b;
?>
Send a message via Skype™ to eStrategy
eStrategy is offline  
Reply With Quote
Old 05-27-2010, 01:57 PM   #31 (permalink)
The Wanderer
 
Join Date: May 2010
Posts: 19
Thanks: 1
core1024 is on a distinguished road
Default

I see this threat is old, but I like classics
Here is my try:
PHP Code:
$a=1;
$b=2;
function 
swab($x,$y){
  global 
$a;
  
$a=$y;
  
$y=$x;
}
swab($a,&$b);
echo 
"\$a=$a; \$b=$b"
core1024 is offline  
Reply With Quote
Old 05-31-2010, 05:11 PM   #32 (permalink)
The Wanderer
 
Join Date: Jan 2010
Posts: 10
Thanks: 4
Monferno is on a distinguished road
Default

Wow. Never thought that there were this many ways to do this.
Mine is:
PHP Code:
$a 1;
    
$b 2;
    
    
$a $a $b;
    
$b $b $a;
    
$a $a + ($b $b $b);
    
    print 
"\$a = $a & \$b = $b"
Monferno is offline  
Reply With Quote
Old 08-10-2010, 06:10 AM   #33 (permalink)
The Visitor
 
Join Date: Aug 2010
Posts: 1
Thanks: 0
cheekote is on a distinguished road
Default

Hmmm no need to do any strange math on this one.
You can use the HowPoliticiansDoIt Design Pattern created by the GoF.

PHP Code:
$a 1;
$b 2;
echo 
'$a = 2' "\n";
echo 
'$b = 1'
cheekote is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 06:53 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design