From: "Aaron D. Gifford" Date: 2011-12-01T06:09:49+09:00 Subject: Re: Stupid question On Wed, Nov 30, 2011 at 1:42 PM, Admin Tensor wrote: > If the number of digits is less than five, how about this one for Ruby > Golf ;-) > >    "2011".sum(48)%48 > > Regards, > > Bill Clever! Is the parameter to sum even required in this case? The docs say the parameter n merely limits the sum modulo 2**n-1 which defaults to 16, or modulo 65535. And the number of digits could be more than five I'd think, as the limiting factor is that modulo operation and so long as the actual sum of each character does NOT cross that threshold (65535 in the default parameter case), it should be fine, no? (And using ASCII values 48-57 inclusive, we should be safe at least up to strings of 1149 digits in length.) Thanks for teaching me yet another interesting tidbit of Ruby--I'd never known about String#sum before. Aaron out.