Re: Golfing a signature

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs