Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Golf: Count unique words

by !1 (Hermit)
on Nov 30, 2004 at 20:40 UTC ( [id://411269]=note: print w/replies, xml ) Need Help??


in reply to Golf: Count unique words

Just throwing this one out there for fun and to show a different approach:

#!/usr/bin/perl -nla INIT{undef$/};$w{$_}++for@F;print"$_ ($w{$_})"for keys%w;print"".@F # 345678 1 2345678 2 2345678 3 2345678 4 2345678 5 2345678 6 234567

67 + 4 = 71 strokes

Replies are listed 'Best First'.
Re^2: Golf: Count unique words
by Anonymous Monk on Dec 07, 2004 at 13:10 UTC
    #!/usr/bin/perl -0nla $w{$_}++for@F;print"$_ ($w{$_}) "for keys%w;print~~@F small correction :)
      #!/usr/bin/perl -0na
      $w{$_}++for@F;print"$_ ($w{$_})
      "for keys%w;print~~@F

      there is literal \n at the end of second line

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://411269]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-24 11:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found