fork download
  1. <?php
  2. error_reporting(E_ERROR);
  3.  
  4. // The width of the ground is intentionally reduced here.
  5. $f = function($l){for($y=count($l);$y>=0;$f[]="$a| |$a")$a=str_repeat($y--?$w=' ':'-',9);
  6. foreach($l as$x){for($x+=11,$s=$y=0;!$s;$b[$x]!=$w?$b[$x+1]!=$w?$b[$x-1]!=$w?$s=1:--$x
  7. :++$x:0)$b=$f[$y++];$f[$y-2][$x]=a;}echo join('
  8. ',$f);};
  9.  
  10. $f([-3, 5, 5, -4, -4, 5, -3]); echo "\n\n";
  11. $f([3, 3, 3, 3, 8, 9]); echo "\n\n";
  12. $f([-5, -5, -5, -5, -5, -5, -5, -5, -5]); echo "\n\n";
Success #stdin #stdout 0.02s 52480KB
stdin
Standard input is empty
stdout
         |   |         
         |   |         
         |   |         
         |   |         
         |   |         
        a|   |         
      aaa|   | aaa     
---------|   |---------

         |   |         
         |   |         
         |   |         
         |   |         
         |   |a        
         |   |aaa  aa  
---------|   |---------

         |   |         
         |   |         
         |   |         
         |   |         
         |   |         
         |   |         
      a  |   |         
     aaa |   |         
    aaaaa|   |         
---------|   |---------