Skip to main content
Commonmark migration
Source Link

#PHP, 100 101 99 104 bytes

PHP, 100 101 99 104 bytes

for($p=-1;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$k&1?$d:-$d]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for($p=-1;          // init position
    $d=$argv[++$k]; // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$k&1?$d:-$d     // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty

#PHP, 100 101 99 104 bytes

for($p=-1;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$k&1?$d:-$d]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for($p=-1;          // init position
    $d=$argv[++$k]; // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$k&1?$d:-$d     // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty

PHP, 100 101 99 104 bytes

for($p=-1;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$k&1?$d:-$d]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for($p=-1;          // init position
    $d=$argv[++$k]; // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$k&1?$d:-$d     // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty
fixed "no negative indexes" (+5 bytes)
Source Link
Titus
  • 14.8k
  • 1
  • 24
  • 41

#PHP, 100 101 9999 104 bytes

for(;$d=$argv[++$k];+$i<$p$p=-1;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$k&1?$d:-$d]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for(;$d=$argv[++$k];$p=-1;          // init position
    $d=$argv[++$k]; // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$k&1?$d:-$d     // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty

#PHP, 100 101 99 bytes

for(;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$k&1?$d:-$d]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for(;$d=$argv[++$k];    // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$k&1?$d:-$d     // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty

#PHP, 100 101 99 104 bytes

for($p=-1;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$k&1?$d:-$d]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for($p=-1;          // init position
    $d=$argv[++$k]; // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$k&1?$d:-$d     // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty
golfed the jump (-2 bytes)
Source Link
Titus
  • 14.8k
  • 1
  • 24
  • 41

#PHP, 100 101101 99 bytes

for(;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$d*($k&1$r[$p+=$k&1?$d:-1)]=$d;for$d]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for(;$d=$argv[++$k];    // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$d*($k&1$p+=$k&1?$d:-1)$d     // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty

#PHP, 100 101 bytes

for(;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$d*($k&1?:-1)]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for(;$d=$argv[++$k];    // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$d*($k&1?:-1)   // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty

#PHP, 100 101 99 bytes

for(;$d=$argv[++$k];+$i<$p?:$i=$p,$x>$p?:$x=$p)$r[$p+=$k&1?$d:-$d]=$d;for(;$i<=$x;)echo$r[$i++]?:_;

takes input from command line arguments; run with -nr.

breakdown

for(;$d=$argv[++$k];    // loop $d through command line arguments
    +$i<$p?:$i=$p,          // 3. $i=minimum index
    $x>$p?:$x=$p            // 4. $x=maximum index
)
    $r[
        $p+=$k&1?$d:-$d     // 1. jump: up for odd indexes, down else
    ]=$d;                   // 2. set result at that position to $d
for(;$i<=$x;)           // loop $i to $x inclusive
    echo$r[$i++]?:_;        // print result at that index, underscore if empty
fixed $i=minimum
Source Link
Titus
  • 14.8k
  • 1
  • 24
  • 41
Loading
Source Link
Titus
  • 14.8k
  • 1
  • 24
  • 41
Loading