Skip to main content
deleted 8 characters in body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59

PHP, 401 392 382382 363 characters:

<? $h=fgets(STDIN);function s($s,$l){return str_repeat($s,$l);}$w=$h*2;$d=$h;$s="str_repeat";$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo s";echo$s($c,$h/2+1)."+".s$s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo secho$s($c,($h/2+1)-$i)."/".s$s($c,$w)."/".s$s($c,$i-1)."|\n";}echo"+".s$s("-",$w)."+".s$s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".s$s($c,$w)."|";echo $a-->0?s$s($c,$b).($a>0?"|":"+")."\n":s$s($c,$h-$i)."/\n";}echo"+".s$s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

PHP, 401 392 382 characters:

<? $h=fgets(STDIN);function s($s,$l){return str_repeat($s,$l);}$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo s($c,$h/2+1)."+".s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo s($c,($h/2+1)-$i)."/".s($c,$w)."/".s($c,$i-1)."|\n";}echo"+".s("-",$w)."+".s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".s($c,$w)."|";echo $a-->0?s($c,$b).($a>0?"|":"+")."\n":s($c,$h-$i)."/\n";}echo"+".s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

PHP, 401 392 382 363 characters:

<? $h=fgets(STDIN);$s="str_repeat";$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo$s($c,$h/2+1)."+".$s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo$s($c,($h/2+1)-$i)."/".$s($c,$w)."/".$s($c,$i-1)."|\n";}echo"+".$s("-",$w)."+".$s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".$s($c,$w)."|";echo $a-->0?$s($c,$b).($a>0?"|":"+")."\n":$s($c,$h-$i)."/\n";}echo"+".$s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

deleted 7 characters in body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59

PHP, 401 392 382 380382 characters:

<? $h=$argv[1];function$h=fgets(STDIN);function s($s,$l){return str_repeat($s,$l);}$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo s($c,$h/2+1)."+".s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo s($c,($h/2+1)-$i)."/".s($c,$w)."/".s($c,$i-1)."|\n";}echo"+".s("-",$w)."+".s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".s($c,$w)."|";echo $a-->0?s($c,$b).($a>0?"|":"+")."\n":s($c,$h-$i)."/\n";}echo"+".s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

PHP, 401 392 382 380 characters:

<? $h=$argv[1];function s($s,$l){return str_repeat($s,$l);}$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo s($c,$h/2+1)."+".s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo s($c,($h/2+1)-$i)."/".s($c,$w)."/".s($c,$i-1)."|\n";}echo"+".s("-",$w)."+".s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".s($c,$w)."|";echo $a-->0?s($c,$b).($a>0?"|":"+")."\n":s($c,$h-$i)."/\n";}echo"+".s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

PHP, 401 392 382 characters:

<? $h=fgets(STDIN);function s($s,$l){return str_repeat($s,$l);}$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo s($c,$h/2+1)."+".s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo s($c,($h/2+1)-$i)."/".s($c,$w)."/".s($c,$i-1)."|\n";}echo"+".s("-",$w)."+".s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".s($c,$w)."|";echo $a-->0?s($c,$b).($a>0?"|":"+")."\n":s($c,$h-$i)."/\n";}echo"+".s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

added 7 characters in body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59

PHP, 401 392 382382 380 characters:

<? $h=fgets(STDIN);function$h=$argv[1];function s($s,$l){return str_repeat($s,$l);}$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo s($c,$h/2+1)."+".s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo s($c,($h/2+1)-$i)."/".s($c,$w)."/".s($c,$i-1)."|\n";}echo"+".s("-",$w)."+".s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".s($c,$w)."|";echo $a-->0?s($c,$b).($a>0?"|":"+")."\n":s($c,$h-$i)."/\n";}echo"+".s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

PHP, 401 392 382 characters:

<? $h=fgets(STDIN);function s($s,$l){return str_repeat($s,$l);}$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo s($c,$h/2+1)."+".s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo s($c,($h/2+1)-$i)."/".s($c,$w)."/".s($c,$i-1)."|\n";}echo"+".s("-",$w)."+".s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".s($c,$w)."|";echo $a-->0?s($c,$b).($a>0?"|":"+")."\n":s($c,$h-$i)."/\n";}echo"+".s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

PHP, 401 392 382 380 characters:

<? $h=$argv[1];function s($s,$l){return str_repeat($s,$l);}$w=$h*2;$d=$h/2;$b=$h;$c=" ";echo s($c,$h/2+1)."+".s("-",$w)."+\n";for($i=1;$i<=$d;$i++,$a=--$b){echo s($c,($h/2+1)-$i)."/".s($c,$w)."/".s($c,$i-1)."|\n";}echo"+".s("-",$w)."+".s($c,$d)."|\n";for($i=1;$i<=$h;$i++){echo"|".s($c,$w)."|";echo $a-->0?s($c,$b).($a>0?"|":"+")."\n":s($c,$h-$i)."/\n";}echo"+".s("-",$w)."+\n";

I originally did this to see how short I could manage to do this in PHP, as I knew that it would be pretty long. I'm sure it could be reduced, but not by much considering PHP doesn't have many shortcuts.

Validation:
http://codepad.viper-7.com/ftYYz9.php53

Ungolfed Version: http://codepad.viper-7.com/4D3kIA

added 13 characters in body; deleted 3 characters in body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59
Loading
edited body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59
Loading
added 5 characters in body
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59
Loading
Source Link
Kevin Brown-Silva
  • 6.5k
  • 5
  • 42
  • 59
Loading