Generating a test case is relatively easy:
- pick b (4 to 8 bits)
- pick a f value (it's an integer between 0 and 2**b)
- pick a v0 value (it's an integer between 0 and 2**b)
- use the formula to generate some sequence
- then slice the sequence
admin wrote:Explanation of skip, let's use a variation of the test case from random.johnnyh
- Code: Select all
1
1 2
7 64 32 16 8 4 2 1
126
128
The answer should be
- Code: Select all
63
skip
The reason is that the sequence 64->32->...->1 proves that the bits f[i]=0 for i=1,..,6
However the bits f[0] and f[7] are unknown, they can be either 0 or 1.
So f can any of these values 00000000, 00000001, 10000000 or 10000001.
Trying each possible value of f to predict the next value of 126, we get:Since all values agree the next value is 63.
- Code: Select all
(01111110 >> 1) | (^(01111110 & 00000000)<<7) = 00111111 = 63
(01111110 >> 1) | (^(01111110 & 00000001)<<7) = 00111111 = 63
(01111110 >> 1) | (^(01111110 & 10000000)<<7) = 00111111 = 63
(01111110 >> 1) | (^(01111110 & 10000001)<<7) = 00111111 = 63
Now for 128, we do the sameSince not all values agrees, we cannot predict the next one with certainty, consequently we get skip.
- Code: Select all
(10000000 >> 1) | (^(10000000 & 00000000) << 7) = 01000000 = 64
(10000000 >> 1) | (^(10000000 & 00000001) << 7) = 01000000 = 64
(10000000 >> 1) | (^(10000000 & 10000000) << 7) = 11000000 = 192
(10000000 >> 1) | (^(10000000 & 10000001) << 7) = 11000000 = 192
_smp wrote:Hi,
I'm really struggling on this one. A couple of questions:
1. Do the values f = 167, b = 3 make for a valid function?
2. If yes, what should the program answer with this sequence (generated with these values):
1 2
6 112 60 30 15 7 3
22
119
demo wrote:what's the upper bound of L[1]+L[2]+...+L[p]? L[i] is the length of the i-th sequence.
The sum of the sequence lengths is between b/2 and 2*b (lower/upper bounds).
Users browsing this forum: No registered users and 2 guests