in reply to Finding One String in Another
did i get your logic correct? i'm not sure how you're handling multiple letters... in my code they must be multiple in each wordsub match { my( $letters, $word ) = map lc, @_; return 0 if length $letters < length $word; my %letters_in_word; $letters_in_word{$_}++ for split //, $word; $letters_in_word{$_}-- for split //, $letters; for( values %letters_in_word) { return 0 if $_ > 0 } return 1 } print match('ABCDE', 'cab'); #prints 1 print match('abcde', 'cat'); #prints 0
and why are you using prototypes?
~Particle *accelerates*
|
|---|