From: tamouse mailing lists Date: 2013-06-02T00:50:23+09:00 Subject: Re: Eloquent Ruby Kaprekar's Number On Sat, Jun 1, 2013 at 9:51 AM, wrote: > Am 01.06.2013 15:21, schrieb Harry Kakueki: > >> >> def try2(n) >> s, q = n.to_s.size, n*n >> (s...s*2).each do|x| >> y = 10**x >> return true if n == q/y+q%y >> end >> false >> end > > > OP was asking for "eloquent" solutions... This may not be eloquent ruby, but it certainly is sublime. Only patch would be to test if n is a non-negative Integer.