in reply to (golf) Triangle of numbers
Update: with the param already in $a, I can cut it down to an even 50....sub g { # 1 2 3 4 5 #2345678901234567890123456789012345678901234567890123456 $^=pop;for(1..$^){printf"%$^d",++$,for(0..$@++);print$/} } =g(3) OUTPUT 1 2 3 4 5 6 =g(5) OUTPUT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 =g(7) OUTPUT 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
Update2: Jumping through the new rules clarification (and borrowing the cleverly ordered calculation) I'm at 70....$a = 5; # 1 2 3 4 5 #2345678901234567890123456789012345678901234567890 for(1..$a){printf"%$a.d",++$;for(0..$@++);print$/}
Final update before I have to go# 1 2 3 4 5 6 7 #234567890123456789012345678901234567890123456789012345678901234567890 $b=length$a++*$a/2;for(2..$a){printf" %$b.d",++$;for(0..$@++);print$/}
63 chars... follows the letter (if not the spirit) of the new rules. ;-)
# 1 2 3 4 5 6 #23456789012345678901234567890123456789012345678901234567890123 map{map{$a=0if$_>$a-2;printf" %$a.d",++$;}0..$@++;print$/}1..$a
-Blake
|
|---|