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

Re: [FWP] Golf challenge: Scoring a word list



Today around 12:30am, Ronald J Kimball hammered out this masterpiece:

: 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

56 characters, including 5 for -le'':

perl -le'$c=pop;@1{/[^$c\n]/g}=%1=(),$n+=keys%1for<>;print$n' as <test

-- 
print(join(' ', qw(Casey R. Tweten)));my $sig={mail=>'crt@kiski.net',site=>
'http://home.kiski.net/~crt'};print "\n",'.'x(length($sig->{site})+6),"\n";
print map{$_.': '.$sig->{$_}."\n"}sort{$sig->{$a}cmp$sig->{$b}}keys%{$sig};
my $VERSION = '0.01'; #'patched' by Jerrad Pierce <belg4mit at MIT dot EDU>


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