From: Simon Kröger on 20 Jan 2007 09:38 William James wrote:>> s,f=1,proc{|x,y|y<1?[]:[[*s...s+=x]]+f[y-1,x].reverse.transpose} > > This is more obfuscated than > > s=1 > f=proc{|x,y|y<1?[]:[[*s...s+=x]]+f[y-1,x].reverse.transpose} > > and is no shorter. depends on your line end character(s) :) >> puts f[w=gets(' ').to_i,gets.to_i].map{|i|['%3i']*w*' '%i} >> ---------------------------------------------------------------- >> >> It draws a number spiral, starting with '1' in the upper left >> corner and the highest number in the middle, it also features >> spirals that are not quadratic. >> >> Yes, you will get some score at the codegolf site if you repost >> this solution there > > If the site accepted this, then it wasn't tested thoroughly > enough. '%3i' gives every number-spiral a column-width > of 3; the column-width should equal the width of the > largest number. Well, consider it cheating, most spirals have a column width of 3 - so you may have to post it twice to have it accepted. cheers Simon From: William James on 20 Jan 2007 15:42 Simon Kröger wrote:> William James wrote: > >> s,f=1,proc{|x,y|y<1?[]:[[*s...s+=x]]+f[y-1,x].reverse.transpose} > > > > This is more obfuscated than > > > > s=1 > > f=proc{|x,y|y<1?[]:[[*s...s+=x]]+f[y-1,x].reverse.transpose} > > > > and is no shorter. > > depends on your line end character(s) :) Only if you're under windoze and you neglect to remove the carriage-returns before uploading. Using vile, for example, I do :set-unix-mode and save before uploading. If you're not doing this, then you are really hurting your score. By the way, in the ASCII Art contest I got the size down to 76. I would pay to see how "flagitious" did it in 71 bytes! > > >> puts f[w=gets(' ').to_i,gets.to_i].map{|i|['%3i']*w*' '%i} > >> ---------------------------------------------------------------- > >> > >> It draws a number spiral, starting with '1' in the upper left > >> corner and the highest number in the middle, it also features > >> spirals that are not quadratic. > >> > >> Yes, you will get some score at the codegolf site if you repost > >> this solution there > > > > If the site accepted this, then it wasn't tested thoroughly > > enough. '%3i' gives every number-spiral a column-width > > of 3; the column-width should equal the width of the > > largest number. > > Well, consider it cheating, most spirals have a column width of > 3 - so you may have to post it twice to have it accepted. The site really should do more thorough testing. First  |  Prev  |  Pages: 1 2 3 4 5 6 Prev: Send over raw socket?Next: Web service client help needed