Simon Kr÷šer wrote:
> >> I can't get this to work.
>
> Hmm.
>
> >> E:\Ruby>ruby try.rb
> >> 4 4
> >> try.rb:2:in `%': too few arguments. (ArgumentError)
> >>         from try.rb:2
> >>         from try.rb:2:in `map'
> >>         from try.rb:2
> >
> > irb(main):006:0> s=1; x=5; [*s...s+x]
> > => [1, 2, 3, 4, 5]
> > irb(main):007:0> s=1; x=5; [*s...s+=x]
> > => []
> > irb(main):009:0> s=1; x=5; s...s+=x
> > => 6...6
>
> Interesting:
>
> C:\development>ruby -v -e "s=1; x=5; p s...s+=x"
> ruby 1.8.5 (2006-08-25) [i386-mswin32]
> 1...6
>
>
> cheers
>
> Simon

E:\Ruby>ruby -v
ruby 1.8.2 (2004-12-25) [i386-mswin32]

So it seems that this won't work without modification under 1.8.2.

As for making it shorter,
  change
puts f[w=gets(' ').to_i,gets.to_i].map{|i|['%3i']*w*' '%i}
  to
puts f[w=gets.to_i,$_[-3,2].to_i].map{|i|"%3d "*w%i}

An invisible extra space is printed at the end of each line.