[Date Prev][Date Next][Thread Prev][Thread Next]
[Search]
[Date Index]
[Thread Index]
Re: [FWP] Golf challenge: Scoring a word list
On Sat, Feb 24, 2001 at 10:58:57PM -0500, Tom Moertel wrote:
>
> THE GOLF CHALLENGE
>
> Write the shortest Perl one-liner that reads a list of words on
> standard input and prints its score, given that the letters in
> $ARGV[0] have been guessed. For example, if the file "test" contains:
>
> makers
> primal
> vulcan
>
> You should be able to enter the following command line
>
> perl [MAGIC STUFF HERE] "as" <test
>
> and see "14" as output.
>
> I've got my golf entry ready (73 chars), but I'll wait a while before
> posting it to avoid tainting the idea pool.
>
60 characters, including 5 for -le'':
perl -le'$a=pop;%0=(),@0{/./g}=s/[$a]//g,$n+=keys%0for<>;print$n' as < test
Ronald
==== Want to unsubscribe from Fun With Perl? Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
==== unsubscribe