in reply to (golf) Triangle of numbers
Update: blakem pointed out that mine doesn't align the numbers. Darn.$a=5; print map{@_=$j+1..($j+=++$i);"@_\n"}1..$a #Update 2 chars better (39) print map{"@{[$j+1..($j+=++$i)]}\n"}1..$a
Last Update: Thanks to help from master caddy Albannach (for figuring out that 'f' works), 60 characters:$#="%@{[2*length $a]}d";print map"@{[$j+1..($j+=++$i)]}\n",1..$a $#="%@{[2*length $a]}u";print map"@{[$j+1..($j+=++$i)]}\n",1..$a $#="%@{[2*length $a]}s";print map"@{[$j+1..($j+=++$i)]}\n",1..$a
Really last update: Following the letter AND spirit of that last 'updated' condition, at 67 characters:$#=" %@{[2*length$a]}.f";print map{$j+1..($j+=++$i),$/}1..$a
Tired of updating :) But more caddy help, this time from blakem(65 characters):$#=" %@{[length int$a*$a/2]}.f";print map{$j+1..($j+=++$i),$/}1..$a # or $#=" %@{[length$a++*$a/2]}.f";print map{$j+1..($j+=++$i),$/}1..$a-1 # or $#=" %@{[length$a*($a+1)/2]}.f";print map{$j+1..($j+=++$i),$/}1..$a
$#=" %@{[length$a++*$a/2]}g";map{print$j+1..($j+=++$i),$/}1..$a-1
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: (golf) Triangle of numbers
by demerphq (Chancellor) on Oct 27, 2001 at 22:48 UTC |