Skip to main content
replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/
Source Link

#PHP, 75 bytes

This uses a modified version of Jörg Hülsermann'sJörg Hülsermann's answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

Try it here:

if('\0' == "\0")
{
    $argv = Array($s = 0, prompt());
    function preg_replace($pattern, $replacement, $subject)
    {
        $regexp = new RegExp($pattern.replace(new RegExp('~', 'g'), ''), 'g');
        return $subject.replace($regexp, $replacement.split('\0').join('$&'));
    }
    
    function printf($string)
    {
        console.log($string);
    }
    
    function ord($chr)
    {
        return $chr.charCodeAt(0);
    }
}
else
{
    if(!isset($argv))
    {
        $argv = array('', '++*+');
    }
}

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));printf($s);

Or try on: http://sandbox.onlinephpfunctions.com/code/7d2adc2a500268c011222d8d953d9b837f2312aa

Differences:

  • Instead of echo$s, I'm using sprintf($s). Both perform the same action on numbers. Since this is just for testing, it is fine.
  • In case there's no passed argument, it will run as if you passed ++*+ as the first argument, which should show 5.

#PHP, 75 bytes

This uses a modified version of Jörg Hülsermann's answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

Try it here:

if('\0' == "\0")
{
    $argv = Array($s = 0, prompt());
    function preg_replace($pattern, $replacement, $subject)
    {
        $regexp = new RegExp($pattern.replace(new RegExp('~', 'g'), ''), 'g');
        return $subject.replace($regexp, $replacement.split('\0').join('$&'));
    }
    
    function printf($string)
    {
        console.log($string);
    }
    
    function ord($chr)
    {
        return $chr.charCodeAt(0);
    }
}
else
{
    if(!isset($argv))
    {
        $argv = array('', '++*+');
    }
}

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));printf($s);

Or try on: http://sandbox.onlinephpfunctions.com/code/7d2adc2a500268c011222d8d953d9b837f2312aa

Differences:

  • Instead of echo$s, I'm using sprintf($s). Both perform the same action on numbers. Since this is just for testing, it is fine.
  • In case there's no passed argument, it will run as if you passed ++*+ as the first argument, which should show 5.

#PHP, 75 bytes

This uses a modified version of Jörg Hülsermann's answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

Try it here:

if('\0' == "\0")
{
    $argv = Array($s = 0, prompt());
    function preg_replace($pattern, $replacement, $subject)
    {
        $regexp = new RegExp($pattern.replace(new RegExp('~', 'g'), ''), 'g');
        return $subject.replace($regexp, $replacement.split('\0').join('$&'));
    }
    
    function printf($string)
    {
        console.log($string);
    }
    
    function ord($chr)
    {
        return $chr.charCodeAt(0);
    }
}
else
{
    if(!isset($argv))
    {
        $argv = array('', '++*+');
    }
}

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));printf($s);

Or try on: http://sandbox.onlinephpfunctions.com/code/7d2adc2a500268c011222d8d953d9b837f2312aa

Differences:

  • Instead of echo$s, I'm using sprintf($s). Both perform the same action on numbers. Since this is just for testing, it is fine.
  • In case there's no passed argument, it will run as if you passed ++*+ as the first argument, which should show 5.
added 4 characters in body
Source Link
Ismael Miguel
  • 7.9k
  • 2
  • 25
  • 38

#PHP, 75 bytes

This uses a modified version of Jörg HülsermannHülsermann's of answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

Try it here:

if('\0' == "\0")
{
    $argv = Array($s = 0, prompt());
    function preg_replace($pattern, $replacement, $subject)
    {
        $regexp = new RegExp($pattern.replace(new RegExp('~', 'g'), ''), 'g');
        return $subject.replace($regexp, $replacement.split('\0').join('$&'));
    }
    
    function printf($string)
    {
        console.log($string);
    }
    
    function ord($chr)
    {
        return $chr.charCodeAt(0);
    }
}
else
{
    if(!isset($argv))
    {
        $argv = array('', '++*+');
    }
}

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));printf($s);

Or try on: http://sandbox.onlinephpfunctions.com/code/7d2adc2a500268c011222d8d953d9b837f2312aa

Differences:

  • Instead of echo$s, I'm using sprintf($s). Both perform the same action on numbers. Since this is just for testing, it is fine.
  • In case there's no passed argument, it will run as if you passed ++*+ as the first argument, which should show 5.

#PHP, 75 bytes

This uses a modified version Jörg Hülsermann of answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

Try it here:

if('\0' == "\0")
{
    $argv = Array($s = 0, prompt());
    function preg_replace($pattern, $replacement, $subject)
    {
        $regexp = new RegExp($pattern.replace(new RegExp('~', 'g'), ''), 'g');
        return $subject.replace($regexp, $replacement.split('\0').join('$&'));
    }
    
    function printf($string)
    {
        console.log($string);
    }
    
    function ord($chr)
    {
        return $chr.charCodeAt(0);
    }
}
else
{
    if(!isset($argv))
    {
        $argv = array('', '++*+');
    }
}

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));printf($s);

Or try on: http://sandbox.onlinephpfunctions.com/code/7d2adc2a500268c011222d8d953d9b837f2312aa

Differences:

  • Instead of echo$s, I'm using sprintf($s). Both perform the same action on numbers. Since this is just for testing, it is fine.
  • In case there's no passed argument, it will run as if you passed ++*+ as the first argument, which should show 5.

#PHP, 75 bytes

This uses a modified version of Jörg Hülsermann's answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

Try it here:

if('\0' == "\0")
{
    $argv = Array($s = 0, prompt());
    function preg_replace($pattern, $replacement, $subject)
    {
        $regexp = new RegExp($pattern.replace(new RegExp('~', 'g'), ''), 'g');
        return $subject.replace($regexp, $replacement.split('\0').join('$&'));
    }
    
    function printf($string)
    {
        console.log($string);
    }
    
    function ord($chr)
    {
        return $chr.charCodeAt(0);
    }
}
else
{
    if(!isset($argv))
    {
        $argv = array('', '++*+');
    }
}

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));printf($s);

Or try on: http://sandbox.onlinephpfunctions.com/code/7d2adc2a500268c011222d8d953d9b837f2312aa

Differences:

  • Instead of echo$s, I'm using sprintf($s). Both perform the same action on numbers. Since this is just for testing, it is fine.
  • In case there's no passed argument, it will run as if you passed ++*+ as the first argument, which should show 5.
added 1198 characters in body
Source Link
Ismael Miguel
  • 7.9k
  • 2
  • 25
  • 38

#PHP, 75 bytes

This uses a modified version Jörg Hülsermann of answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

Try it here:

if('\0' == "\0")
{
    $argv = Array($s = 0, prompt());
    function preg_replace($pattern, $replacement, $subject)
    {
        $regexp = new RegExp($pattern.replace(new RegExp('~', 'g'), ''), 'g');
        return $subject.replace($regexp, $replacement.split('\0').join('$&'));
    }
    
    function printf($string)
    {
        console.log($string);
    }
    
    function ord($chr)
    {
        return $chr.charCodeAt(0);
    }
}
else
{
    if(!isset($argv))
    {
        $argv = array('', '++*+');
    }
}

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));printf($s);

Or try on: http://sandbox.onlinephpfunctions.com/code/7d2adc2a500268c011222d8d953d9b837f2312aa

Differences:

  • Instead of echo$s, I'm using sprintf($s). Both perform the same action on numbers. Since this is just for testing, it is fine.
  • In case there's no passed argument, it will run as if you passed ++*+ as the first argument, which should show 5.

#PHP, 75 bytes

This uses a modified version Jörg Hülsermann of answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

#PHP, 75 bytes

This uses a modified version Jörg Hülsermann of answer.

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));echo$s;

It heavily relies on string substitution, using a simple regular expression (~.~).

The variable $s is re-assigned with the new value for each character. At the end, it outputs the result.


**Note**: This is meant to be executed using the `-r` flag.

Try it here:

if('\0' == "\0")
{
    $argv = Array($s = 0, prompt());
    function preg_replace($pattern, $replacement, $subject)
    {
        $regexp = new RegExp($pattern.replace(new RegExp('~', 'g'), ''), 'g');
        return $subject.replace($regexp, $replacement.split('\0').join('$&'));
    }
    
    function printf($string)
    {
        console.log($string);
    }
    
    function ord($chr)
    {
        return $chr.charCodeAt(0);
    }
}
else
{
    if(!isset($argv))
    {
        $argv = array('', '++*+');
    }
}

eval(preg_replace('~.~','$s=($s\0(2-ord("\0")%11%3))|0;',$argv[1]));printf($s);

Or try on: http://sandbox.onlinephpfunctions.com/code/7d2adc2a500268c011222d8d953d9b837f2312aa

Differences:

  • Instead of echo$s, I'm using sprintf($s). Both perform the same action on numbers. Since this is just for testing, it is fine.
  • In case there's no passed argument, it will run as if you passed ++*+ as the first argument, which should show 5.
Source Link
Ismael Miguel
  • 7.9k
  • 2
  • 25
  • 38
Loading