The function takes the obvious parameters to it, a pattern and the word.
Mine does not exhibit the same problem as yours, I think because I scan the pattern against the word, not the word against the pattern. Therefore, the UNIQUENESS of the testing is dependant on the pattern, not the word.sub match { my $pattern=shift; my $word=shift; ## have to be exact return unless length($pattern) == length($word); my %seen; my @pattern=split //,$pattern; my @word=split //,$word; for my $let (@word) { my $pat=shift @pattern; ## if this is a new pattern, make sure it doesn't ## match a previous letter if (!defined $seen{$pat}) { ## bad if this letter exists return if grep /$let/,join("",values %seen); ## it's OK, $seen{$pat}=$let; } else { ## must be the same return if $seen{$pat} ne $let; } ## tis good } 1; }
any senselessness you detect is due to medication
Oh, duh. I didn't realize what this solution could be used for :)
Implementing a brute force decrypter using this would be simplistic, eh?
In reply to Re: Cryptogram Solver
by mr.nick
in thread Cryptogram Solver
by pchou
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |