first of all, the algorithm as it is now is only reliable if a hole doesn't hide a max. Otherwise you get false negatives like demonstrated here

You will need to cover that!

I have some efficient ideas, but no time right now.

( These kind of riddles cost me a lot of processing power I need elsewhere. :)

> make a sieve of length 2 * range

that's sufficient because range can always fit in that sliding window.

I shift the window to the right by pmax_known+n if positioning the first max means a negative sieve index.

It's important to realize that this can only happen with preceding holes covering a former max. Hence these holes will also ignore the position pmax+n in the sieve. °

> make both sieve and input into strings as below, and use a regexp match.

Not sure I understand, but the fastest way to compare two byte arrays is to xor the strings, a range of 256 or even 128 exponents should be sufficient

Of course representation of holes, like \xFF or \x00 makes this more challenging, needing a second and

But I consider this premature optimization, you should first test the validity of the algorithm with arrays.

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

°) Maybe it's even not necessary to try successive n and you can just shift by pmax - this equals swapping the sequence to the second half.

update

... to come...

... OK ... It's important to understand that those shifts and other problems are only due to one or more holes covering an e >= max ...

Without holes the algorithm works as is!

Now one needs to list the possible cases, for e=max and e >max and shift accordingly by + pe for all "dubious" holes till one has a pass or all failed.

There might be a simple solution like moving the first hole to pmax+1 and taking advantage of the fact that further collisions are not possible because of the constraints (first max) but I can't wrap my head around it.


In reply to Re^9: checking a set of numbers for consistency mod p by LanX
in thread checking a set of numbers for consistency mod p by hv

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.