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

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
> >
> > 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...
> > 

Then Ronald J. Kimball wrote:
> > 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}'

Well, here's something *nasty*, but it's worth two characters:

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

or, if you want a solution that only works on systems where (ord("\n") ==
10) && (ord("A") == 65), you can shave 8 characters ...

  perl -e'for(<>){$t=0;for(split//){$t+=ord(uc)-64}$t==46&&print}'

---Eli

--------------------------------------------
 Eli Evans
 "I must Create a System, or be enslavd by 
 another Mans"---William Blake, _Jerusalem_
--------------------------------------------

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