[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] 100 point words.

>>>>> "Brent" == Brent Michalski <perlguy@technologist.com> writes:

Brent> Last summer my son came home with an assignment to find as many words as
Brent> he could that add up to 100 points.  With A=1, B=2, ... Z=26

Brent> We were going on vacation that week and had 2 10 hour drives in the
Brent> car.  At the end of the 20 hours, we had 4 or 5 words that added up to
Brent> 100.  PRINTER is a word that adds up to 100.

Brent> Well, it was driving me nuts so I told him that when we got back, i'd
Brent> write a Perl program to figure this out for us.  The kid who found the
Brent> most words got a prize :-)  [motivation]...

Brent> Anyway, I wrote a program in about 15 minutes with about 20 lines of
Brent> code.  We ran it against several dictionary files and came up with 10
Brent> 4-column pages with words that add up to 100!

Brent> It would be fun to create such a program and run it against a
Brent> "standard/common" dictionary and see who could do it in the coolest, or
Brent> shortest, way...

perl -ne '$o = $_; $s = 0; $s += $n while $n = tr/A-Za-z/@-Y`-y/; print $o if $s == 100' /usr/dict/words

Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe