in reply to ASCII Pattern - Golf
Also, what he didn't mention is that it stemmed from an argument between PHP and Perl (don't bother preaching, i know the advantages and disadvantages of each, and use both ;)).
Anyway, this was the PHP solution I came up with.
#!/usr/bin/php4 -q <? for($i=1;$i<10;$i++){for($n=1;$n<10;$n++){echo max(abs($i-(10-$argv[2] +)),abs($n-$argv[1]));}echo"\n";} ?>
Not counting the #! line or the <?'s, I was the winner by about 4 characters I think (keeping in mind there was a time limit on the competition).
Since we basically had the same idea for the algorithm I guess all it really came down to was the length of php/perl's syntax. I have also since seen much much smaller perl answers but I think I would be very hard pressed to make the php solution any smaller.
- James
|
|---|