Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://968452]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2018-01-20 17:51 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (227 votes). Check out past polls.