Generating sets that pass is straightforward: here's code that generates full sets for a given prime, and you can mask out a subset of the values with undef. All such sets should return true when queried with the same prime:
#!/usr/bin/perl use strict; use warnings; my($prime, $range, $count) = @ARGV; for (1 .. $count) { # report the full range for a random start point my $start = int rand(2 ** 32 - $range); print join(' ', map val($start + $_), 0 .. $range - 1), "\n"; } exit 0; # return the $p-adic order of $n sub val { my($n) = @_; my $val = 0; ++$val, $n /= $prime while 0 == $n % $prime; return $val; }
It's less obvious how to generate a useful collection of sets that should not pass. Best I can suggest is to take one of the passing sets, randomly increment or decrement an element (that has not been masked out), and see if the valid_set() function in my original post rejects it.
In reply to Re^4: checking a set of numbers for consistency mod p
by hv
in thread checking a set of numbers for consistency mod p
by hv
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |