in reply to Re^2: checking a set of numbers for consistency mod p
in thread checking a set of numbers for consistency mod p

> Eh? It's just an algorithm question, right?

I was joking.

> Taking my last example [1,0,0,1,0,0,1], 3, for example: you find that the biggest known entry is 1

take the pre-calculated sieve for 27 entries from my post and anchor the first 1 (marked ^) from both sequences for a one-on-one comparison

[1,0,0,1,0,0,1] <0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 0 2 0 0 1 0 0 1 0 0 3> ^ *

and you'll see they diverge for the last entry (marked *) hence it's a fail.

I hope it's clearer now. :)

If you have billions of comparisons and max m=32 length sequences for a limited number of possible p, this should be very fast.

(disclaimer: I'm not 100% sure I covered all edge cases caused by the holes)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

update

for the other examples given

[0,1,0,2,0] <0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 5> ^ -> PASS

[1,0,5,0,1] <0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 5 0 1 . +.. > ^ -> PASS

[2,?,?,?,2] <0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 5> ^ * -> FAIL

update

and if you have a sequence [2,[1,0,9,0,1]] with a max (here 9) which isn't in your pre-calculated sieve, identify it with the max from your sieve (here 5)

[1,0,9,0,1] <0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 4 0 1 0 2 0 1 0 3 0 1 0 2 0 1 0 5 0 1 . +.. > ^ -> PASS

of course this would also work by identifying 9 with 4 or 3 or 2 because this sequence is so short. But with a possible m=32 you need that full length.