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

RE: [FWP] 100 point words.



Sure.

perl -ne'$t+=ord($&)-ord"`"while/./g;print if$t==100;$t=0'

-----Original Message-----
From: Ronald J Kimball [mailto:rjk@linguist.dartmouth.edu]
Sent: Friday, July 23, 1999 2:24 PM
To: Brent Michalski
Cc: fwp@technofile.org
Subject: Re: [FWP] 100 point words.


On Fri, Jul 23, 1999 at 12:52:35PM -0500, Brent Michalski wrote:
> Last summer my son came home with an assignment to find as many words as
> he could that add up to 100 points.  With A=1, B=2, ... Z=26
> 
> We were going on vacation that week and had 2 10 hour drives in the
> car.  At the end of the 20 hours, we had 4 or 5 words that added up to
> 100.  PRINTER is a word that adds up to 100.
> 
> Well, it was driving me nuts so I told him that when we got back, i'd
> write a Perl program to figure this out for us.  The kid who found the
> most words got a prize :-)  [motivation]...
> 
> Anyway, I wrote a program in about 15 minutes with about 20 lines of
> code.  We ran it against several dictionary files and came up with 10
> 4-column pages with words that add up to 100!
> 
> It would be fun to create such a program and run it against a
> "standard/common" dictionary and see who could do it in the coolest, or
> shortest, way...
> 
> What do you think?
> 

For shortest, can anyone beat this one-liner?


perl -e'while(<>){$t+=1+ord($1)-ord"a"while/(.)/g;print if$t==100;$t=0}'


Ronald

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

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