# Re: Golfing a signature

**URL:** <https://www.ruby-forum.com/t/re-golfing-a-signature/94463>\
**Category:** Ruby\
**Created:** [May 4, 2006, 2:40am UTC](https://www.ruby-forum.com/t/re-golfing-a-signature/94463 "2006-05-04T02:40:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dasch](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/b2d939/32.png) [@dasch](https://www.ruby-forum.com/u/dasch)\
**Post date:** [May 4, 2006, 2:40am UTC](https://www.ruby-forum.com/t/re-golfing-a-signature/94463/1 "2006-05-04T02:40:30Z")

</div>

Also, somewhere along the line you changed what the program was actually  
doing - originally you produced a 20x21 grid, but that got reduced to a  
20x20.

I used this to make sure I didn’t change the program during golfing:

require ‘stringio’  
out = “”  
$stdout = StringIO.new(out)  
srand(1);

$\>\<\<"\e[2J";s,o,f,c,u=20,"#","  
“;b,q=(z=0…s).map{z.map{(rand\<0.3)?o:f}},  
(m=[-1,0,1])-[0];until  
c==b;c=b.map{|z|z.dup};$\>\<\<”\e[H"\<\<b.map{|x|x_f}_"  
";s.times{|i|s.times{|e|n=((m\*2+q).sort.zip(m+q+m).map{|x|(c[i+x[0]]||[  
])[e+x[1]]}-[f,u]).size;b[i][e]=(n==2?b[i][e]:n==3?o:f)}};sleep 0.2;end

$stdout = STDOUT

#uncomment this to reset the content of the file.  
#File.open(“monkeys”,“w”) {|f| f \<\< out }

raise “Different” unless File.read(“monkeys”) === out
