Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^4: Perl Golf ideaby brx (Pilgrim) |
on May 01, 2012 at 20:58 UTC ( [id://968333]=note: print w/replies, xml ) | Need Help?? |
And if you don't mind the (second) argument getting printed, another 3 chars less: perl -nlE'sub w{[sort/./g]}$w||=w$_=pop;$w~~w&&say' ./dict.txt acert This one is wrong (only) if the first line of 'dict.txt' contains a valid word (different from arg2). example:
First word is missing. Anyway, this is a very beautiful version: ++ UPDATE: with an extra newline perl -E'@a=sort pop=~/./g;say grep@a~~[sort/./g],<>' ./dict.txt acertUPDATE2: one char useless perl -E'@a=sort pop=~/./g;say grep@a~~[sort//g],<>' ./dict.txt acert
In Section
Seekers of Perl Wisdom
|
|