in reply to (golf) Triangle of numbers
Firstly, you can drop the extra $/'s being printed on yours by changing the 0..$a to 2..$a as shown in #1. The second thing i worked on was a one-liner version, which is #2. It weighs in at 71 characters. However, if i'm allowed to disregard numbers over 1000 (which would take more than 45 rows to get) i can drop that by three characters to 68 as shown in #3.
Anyway, thanks for the fun,# 1 $n=length$a++*$a/2;map{map{printf" %$n.d",++$k}2..$_;print$/}2..$a # 2 print+(map$"x(length(($a+1)*$a/2)+1-length++$l).$l,2..$_),$/for 2..$a+ +1 # 3 print+(map$"x(($a>13?4:$a>3?3:2)-length++$l).$l,2..$_),$/for 2..$a+1
|
|---|