From: Levin Alexander Date: 2005-12-05T09:28:50+09:00 Subject: Re: Weird Numbers (#57) Solution On 12/4/05, Christer Nilsson wrote: > The part I appreciate most is the beautiful and fast handling of the> binary set:>> def sum_in_subset?(a)> if self < 0> false> elsif a.include?(self)> true> else> if a.length == 1> false> else> f = a.first> remaining = a[1..-1]> (self - f).sum_in_subset?(remaining) or> sum_in_subset?(remaining)> end> end> end Yes, this is quite nice. I rewrote it a bit so that it does not needthe nested ifs. What do you think? def sum_in_subset?(div = self.divisors) return false if self < 0 return false if div.empty? return true if div.include?(self) f, remaining = div[0], div[1..-1] (self - f).sum_in_subset?(remaining) or sum_in_subset?(remaining) end Viele Gr����e,Levin