Re: Stupid question

ARGH, Verizon’s overzealous spamfilter has been eating my replies
outbound. :stuck_out_tongue:

First, on Wed, Nov 30, 2011 at 15:14, Aaron D. Gifford
[email protected] wrote:

If we’re golfing, here’s my amateur golf attempt: chuckle

s=0;‘2011’.chars{|x|s+=x.to_i};s

And another four chars gone! Well done! Just goes to show, using
typical Ruby idioms doesn’t always yield (no pun intended) the
shortest code, nor the fastest.

(Are we allowing semicolons?)

Sure, why not. I’ll even allow carriage returns, counting them as one
char.

Second, on Wed, Nov 30, 2011 at 15:42, Admin T.
[email protected] wrote:

If the number of digits is less than five, how about this one for Ruby
Golf :wink:

“2011”.sum(48)%48

Cuuuuute. If we restrict it to years we’ve had so far (CE), okay.

-Dave

Dave A. wrote in post #1034582:

“2011”.sum(48)%48

Cuuuuute. If we restrict it to years we’ve had so far (CE), okay.

As Aaron pointed yesterday, if the number of digits is less than or
equal to five, the shortest code is

"2011".sum%48

(for some reason it didn’t work for me before). And if the digits are
longer, he has some shortest code for that.

Regards,

Bill

-----Messaggio originale-----
Da: Admin T. [mailto:[email protected]]
Inviato: gioved 1 dicembre 2011 17:32
A: ruby-talk ML
Oggetto: Re: Stupid question

Dave A. wrote in post #1034582:

“2011”.sum(48)%48

Cuuuuute. If we restrict it to years we’ve had so far (CE), okay.

As Aaron pointed yesterday, if the number of digits is less than or
equal to
five, the shortest code is

"2011".sum%48

(for some reason it didn’t work for me before). And if the digits are
longer, he has some shortest code for that.

Regards,

Bill


Posted via http://www.ruby-forum.com/.


Caselle da 1GB, trasmetti allegati fino a 3GB e in piu’ IMAP, POP3 e
SMTP autenticato? GRATIS solo con Email.it http://www.email.it/f

Sponsor:
Capodanno a Riccione, Pacchetto Relax: Mezza Pensione + bagno turco +
solarium + massaggio. Wifi e parcheggio gratis. 2 giorni euro 199 a
persona
Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid979&d)-12