From: "Simon Kröger" Date: 2007-09-10T21:25:12+09:00 Subject: Re: Count and Say (#138) Phrogz wrote: > For fun, I thought I'd see what it looked like to implement the > integer-based algorithm that this quiz is based on. Here's what I came > up with. (I'm a big fan of monkeypatching. :) Another monkeypatchingversion (i like reopening classes, i'm not realy a fan of the term 'monkeypatching') -------------------------------------------- class String def look_and_say gsub(/(.)\1*/){|s| "#{s.size}#{s[0,1]}"} end end s = '1' 12.times {p s; s = s.look_and_say} -------------------------------------------- cheers Simon