On Sep 28, 2006, at 10:49 AM, James Edward Gray II wrote:

> On Sep 28, 2006, at 1:23 AM, Michael Ulm wrote:
>
>> Not very impressive, but may give others some ideas.
>>
>> def f(n,m,k,o)
>> n*m==0?[]:(k>0?f(n-1,m-1,m-k-1,n+m-1+o).reverse<< n+k+o:(o+1..n 
>> +o).to_a)
>> end
>> x,y=ARGV.map{|t|t.to_i}
>> y.times{|i|puts f(x,y,i,0).map{|t|t.to_s.rjust((x*y).to_s.size)}*" "}
>
> I haven't figured out completely how it works yet, but I did shave  
> some bytes off of it:
>
> def f n,m,k,o
> n*m==0?[]:(k>0?f(n-1,m-1,m-k-1,n+m-1+o).reverse<< n+k+o:(o+1..n 
> +o).to_a)
> end
> x,y=$*.map{|t|t.to_i}
> y.times{|i|puts f(x,y,i,0).map{|t|"%#{"#{x*y}".size}s"%t}*" "}

One byte larger, but supporting the quiz interface:

f=proc{|n,m,k,o|n*m==0?[]:(k>0?f[n-1,m-1,m-k-1,n+m-1+o].reverse<<n+k 
+o:[*o+1..n+o])}
x,y=gets(" ").to_i,gets.to_i
y.times{|i|puts f[x,y,i,0].map{|t|"%#{"#{x*y}".size}s"%t}*" "}

(3 lines--first line was likely wrapped)

James Edward Gray II