in reply to (Golf) Hangman Player

Part 1 with extra credit (since that is the only way it should be done) and matching case insensitive
sub f { ($a=shift)=~s/_/[^$a]/g;grep/^$a$/i,@{$_[0]} #23456789_123456789_123456789_123456789_1234 }
44 chars

Update I screwed up and didn't do most frequent char... now I have both...

sub g { shift;for(@{+shift}){s/[@_]//g;$c{$_}++for split//}(sort{$c{$b}<=>$c{$ +a}}%c)[0] #23456789_123456789_123456789_123456789_123456789_123456789_123456789_ +123456789 }
Done the right way I get 79 chars for part B
sub g { shift;for(@{+shift}){s/[@_]//g;$b||=chop}$b #23456789_123456789_123456789_123456789_123 }
43 chars without most common char (the wrong way :)

                - Ant
                - Some of my best work - Fish Dinner

Replies are listed 'Best First'.
Re: Re: (Golf) Hangman Player
by japhy (Canon) on Oct 04, 2001 at 22:11 UTC
    I can shorten it to 43.
    sub f { ($a=shift)=~s/_/[^$a]/g;grep/^$a$/i,@{+pop} #23456789_123456789_123456789_123456789_123 }

    _____________________________________________________
    Jeff[japhy]Pinyan: Perl, regex, and perl hacker.
    s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;