If I read it correctly, you currently make a sieve of length 2 * range, centred around pmax. I think you need the length to be around 2 * (range + pmax - 1).
I don't understand the logic you're using with $max_pos to decide where in the sieve to match, and I'm not sure it's correct. But I'd be tempted to punt on that - make both sieve and input into strings as below, and use a regexp match.
use List::Util qw{min}; my @order = '0' .. '9', 'A' .. 'Z'; # range of 2^36 is probably enou +gh sub to_string { my($max, $list) = @_; return join '', map { defined($_) ? $order[min($_, $max)] : '.' } @$list; }
In reply to Re^8: checking a set of numbers for consistency mod p (update: still buggy)
by hv
in thread checking a set of numbers for consistency mod p
by hv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |