Forum: Ruby Re: Golfing a signature.

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Daniel S. (Guest)
on 2006-05-04 04:37
(Received via mailing list)
You can shave off another 12 characters by changing the construction of
the "z" array:


Firstly, z isn't used after this, so you don't need to reassign it:


But the whole thing is pointless, as it's not much better that spelling
out the entire array:

[[-1,-1],[-1,0],[-1,1],[0,-1],[0,1],[1,-1],[1,0],[1,1]].map {

so shorten that with a zip:


removing some repetition makes it slightly longer:


but we can fix that:



Also the:

c[i+x[0]][e+x[1]]rescue u

can be rewritten as:



I also rejuggled things to move that "\n" so that it made use of the end
of the line, and There was a reference to " ", which I replaced with f.
I might have done some other things too, but I don't have much of a

])[e+x[1]]}-[f,u]).size;b[i][e]=(n==2?b[i][e]:n==3?o:f)}};sleep 0.2;end

That's 292 characters.
This topic is locked and can not be replied to.