Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

Commonmark migration
Source Link

PHP 113

##PHP 113 FiguredFigured i'd chime in with a php version:

113 chars (adjust $h to change the height, the number of lines includes the star):

$h=10;for($n=0;$n<$h;$n++){$i=$n>0?$n:1;$c=$n<1?"*":"0";echo str_repeat(" ",$h-$i).str_repeat($c,($i*2)-1)."\n";}

I tried to make it short, not readable and we already knew php can't compete on conciseness so this isn't going to win anything, still a fun little puzzle tho.

output is as spec:

 *
 0
 000
 00000
 0000000
 000000000
 00000000000
 0000000000000
 000000000000000
00000000000000000

##PHP 113 Figured i'd chime in with a php version:

113 chars (adjust $h to change the height, the number of lines includes the star):

$h=10;for($n=0;$n<$h;$n++){$i=$n>0?$n:1;$c=$n<1?"*":"0";echo str_repeat(" ",$h-$i).str_repeat($c,($i*2)-1)."\n";}

I tried to make it short, not readable and we already knew php can't compete on conciseness so this isn't going to win anything, still a fun little puzzle tho.

output is as spec:

 *
 0
 000
 00000
 0000000
 000000000
 00000000000
 0000000000000
 000000000000000
00000000000000000

PHP 113

Figured i'd chime in with a php version:

113 chars (adjust $h to change the height, the number of lines includes the star):

$h=10;for($n=0;$n<$h;$n++){$i=$n>0?$n:1;$c=$n<1?"*":"0";echo str_repeat(" ",$h-$i).str_repeat($c,($i*2)-1)."\n";}

I tried to make it short, not readable and we already knew php can't compete on conciseness so this isn't going to win anything, still a fun little puzzle tho.

output is as spec:

 *
 0
 000
 00000
 0000000
 000000000
 00000000000
 0000000000000
 000000000000000
00000000000000000
Source Link
Kris
  • 131
  • 3

##PHP 113 Figured i'd chime in with a php version:

113 chars (adjust $h to change the height, the number of lines includes the star):

$h=10;for($n=0;$n<$h;$n++){$i=$n>0?$n:1;$c=$n<1?"*":"0";echo str_repeat(" ",$h-$i).str_repeat($c,($i*2)-1)."\n";}

I tried to make it short, not readable and we already knew php can't compete on conciseness so this isn't going to win anything, still a fun little puzzle tho.

output is as spec:

 *
 0
 000
 00000
 0000000
 000000000
 00000000000
 0000000000000
 000000000000000
00000000000000000

AltStyle によって変換されたページ (->オリジナル) /