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

Re: Perl Golf idea

by brx (Pilgrim)
on May 02, 2012 at 13:41 UTC ( #968452=note: print w/ replies, xml ) Need Help??

in reply to Perl Golf idea

Here is a summary of replies to this little informal golf contest. I hope there will be more replies.

  • thundergnat

    perl -e'sub w{join"",sort@_[0]=~/./g};$w=w pop;($w eq w$_)&&print for<>' ./dict.txt acert
  • tobyink

    perl -E'sub w{[sort/./g]}$w=w$_=pop;$w~~w&&print for<>' ./dict.txt acert
  • JavaFan

    perl -nlE'sub w{[sort/./g]}INIT{$w=w$_=pop}$w~~w&&say' ./dict.txt acert
  • brx

    perl -E'@a=sort pop=~/./g;print grep@a~~[sort//g],<>' ./dict.txt acert
  • JavaFan, with the second argument getting printed (a dummy line must be added at the begining of dict.txt)

    perl -nlE'sub w{[sort/./g]}$w||=w$_=pop;$w~~w&&say' ./dict.txt acert
  • brx, with an extra newline after last line printed

    perl -E'@a=sort pop=~/./g;say grep@a~~[sort//g],<>' ./dict.txt acert
  • Update: thundergnat

    perl -nlE'($w//=[sort pop=~/./g])~~[sort//g]&&say' ./dict.txt acert
Comment on Re: Perl Golf idea
Select or Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (5)
As of 2016-05-02 08:54 GMT
Find Nodes?
    Voting Booth?