Here is my version of Floyd's Triangle. I wanted to make it as compact as possible and created this one line in Ruby:Code: Ruby
(1..14).each {|x| puts (((1 + x) * (x / 2.0) - (x - 1)).to_i..((1 + x) * (x / 2.0)).to_i).to_a.to_s.split(",").join}
Anyone wants to post something in BASIC? But please, try to do something different than two loops and couple of variables. ;)
SB underdone? Incomplete? Overestimated? C'mon Tomaaz, you don't really mean that!
needs stack/rstack
: floyd \ rows --
dup >r r@ r@ n:1- 2 n:/ r> n:* n:+ n:int >s s:len nip "%%%dd " s:strfmt >r
( >r
( r@ n:1- 2 n:/ r@ n:* n:+ n:int 1 rpick s:strfmt . ) 1 r@ loop rdrop cr
) 1 rot loop rdrop ;
0 args >n floyd
bye