------ art_16851_15732795.1209919957752 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sun, May 4, 2008 at 12:36 PM, Marcelo <marcelo.magallon / gmail.com> wrote: > On Sun, May 4, 2008 at 6:22 AM, Harry Kakueki <list.push / gmail.com> wrote: > > > ruby q161.rb 10000000000000000 > > 84 numbers > > I've got 106 in that range: > > $ time ./reverse_divisible 10_000_000_000_000_000 > 106 > > real 0m1.457s > user 0m1.364s > sys 0m0.092s > > The only reason why I don't post the solution yet is because I'm stuck > on a proof that the method is correct :-( > > Marcelo > > Here's my attempt: class Integer def divisible_by_reverse? return false unless self % 9 0 return false if self % 10 0 reverse elf.to_s.reverse return false if self.to_s.eql?(reverse) return self % reverse.to_i 0 end end max RGV[0] ? ARGV[0].to_i : 1_000_000 1.upto(max) { |n| puts n if n.divisible_by_reverse? } -- Shane Emmons E: semmons99 / gmail.com ------ art_16851_15732795.1209919957752--