Rick Delaney <rick.delaney@home.com> writes: > Tom Moertel wrote: > > > > 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. > > Here's a couple using Abigail's trick. > > 57 characters: > perl -lpe'INIT{$x=pop}s/[$x]//g;s/./$c{$&.$.}++/ge}{$_=keys%c' as <test > > 55 characters: > perl -lpe'INIT{$x=pop}s/(?![$x])./$c{$&.$.}++/ge}{$_=keys%c' as <test > > -- > Rick Delaney > rick.delaney@home.com > > ==== Want to unsubscribe from Fun With Perl? Well, if you insist... > ==== Send email to <fwp-request@technofile.org> with message _body_ > ==== unsubscribe I didn't see a definition of score anywhere so I am not sure I've deduced it correctly other fwpers posts - these two can't both be correct since they give different answers on some inputs. =) But at 48 and 51 characters each, they're too nice to keep hidden for something as trivial as merely being wrong ;-) perl -e'$/=0;$_=<STDIN>;print eval"tr/$ARGV[0]\n//c"' as <test perl -e'$/=0;print0+grep/[^$ARGV[0]\n]/,split"",<STDIN>' as <test All abuse graciously accepted Jas "who would submit helloworld as quicksort coz it was shorter" ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe