in reply to Re: Anagram Solver
in thread Anagram Solver

It seems that your trimming will make the code less efficient, as you are now reading the entire word list into memory at once. I would have liked to have seen your original code preserved and the golf versions added as a separate node.

Anyway, here's 12 more characters taken off (after Update2): perl -le'sub c{join"",sort split//,lc pop}$l=c pop;chop,c(lc)eq$l&&print for<>'

Replies are listed 'Best First'.
Re: Re: Re: Anagram Solver
by salvadors (Pilgrim) on Jan 10, 2001 at 16:07 UTC

    Here's 12 more characters taken off..

    Nice.

    -l switch to save 6 characters. Must remember that. In fact must learn a lot more of the command line switches.

    I should really have spotted the spurious space at the start, the calling the sub without ()s, the needless $_, and being able to remove the () on the for by moving the for to the end though ...

    That gets the actual 'executable' code down to 69 characters now, which I think is much more in keeping with the original "do it one line" ideal..

    You want it in one line? Does it have to fit in 80 columns? :-) 
    
       --Larry Wall in <7349@jpl-devvax.JPL.NASA.GOV>
    

    Tony