I'm too busy right now for code or a proper proof and to be honest I don't grasp your algorithm ...
But my intuition says (examples for [ 2, [1, 0, 5, 0, 1]] )
- it's symmetric around the biggest entry here 5
- it's sufficent to investigate the neighbours of the first possible solution, here 2**5=32 . All other solutions 2**5*r will have the same pattern around them.
- to speed it up you can exploit the repeated sieves (like in the sieve algo for prime search) (see footnote °)
- the undefined holes make this more complicated if they disguise the biggest entry. But you can most probably just stick with the biggest known entry approach as long as you take the first one.
HTH!
PS: Hey, number theory is off-topic!!! ;-)
°) regarding sieves, every partial sequence is the combination of all former repeated p-1 times, just the last entry is incremented
for p=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>
for p=3
<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>
etc
update
You can easily precalculate the sieves if you have many sequences of a max length like m=32.
You'll just calculate the sieve up to m.
Any bigger max entry will just take the place of the precaclclated max and the sieve will be correct.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.