Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re^5: Perl Golf idea

by thundergnat (Deacon)
on May 02, 2012 at 17:08 UTC ( #968487=note: print w/ replies, xml ) Need Help??


in reply to Re^4: Perl Golf idea
in thread Perl Golf idea

Nice. Here's one that returns the correct output using a few characters less:

perl -nE'$w//=pop;[sort$w=~/./g]~~[sort//g]&&print' ./dict.txt acert

or, two characters less than that, but with an extra newline between each word:

perl -nE'$w//=pop;[sort$w=~/./g]~~[sort//g]&&say' ./dict.txt acert

UPDATE: shorter version with correct output:

perl -nlE'$w//=pop;[sort$w=~/./g]~~[sort//g]&&say' ./dict.txt acert

or, same length, more efficient:

perl -nlE'($w//=[sort pop=~/./g])~~[sort//g]&&say' ./dict.txt acert


Comment on Re^5: Perl Golf idea
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2014-07-13 09:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (248 votes), past polls