Jump to content
BrainDen.com - Brain Teasers
  • 0


superprismatic
 Share

Question

I have take a 1000-long bit stream which

satisfies the following 11 relations

(Si is the ith bit of the bit stream):

Si + Si+11 = Si+48 (mod 2)

Si + Si+22 = Si+96 (mod 2)

Si + Si+44 = Si+192 (mod 2)

Si + Si+30 = Si+275 (mod 2)

Si + Si+244 = Si+297 (mod 2)

Si + Si+214 = Si+341 (mod 2)

Si + Si+88 = Si+384 (mod 2)

Si + Si+60 = Si+550 (mod 2)

Si + Si+488 = Si+594 (mod 2)

Si + Si+428 = Si+682 (mod 2)

Si + Si+176 = Si+768 (mod 2)

and performed the following modification

on it:

Each bit has either been flipped (with

probability 0.35) or left as is (with

probability 0.65) independently of the

other bits. The resulting stream is:


00010000110111101011001000011000010110000101001001
00011100000010100101001101010110011011101111101110
10100101010010000101111011101011010110001111001000
10010110100111100111110110000101000010010101100100
10010001010110110101010110111001010011011111111001
11101001111101111001000111010100111100101010001111
11100011011101010001110010000011111101011100101010
00110010110110001101001001000000100001110101001010
10000010011110001111111100100110010010000110110111
11110010111110101100000000111011010011001101010001
10100000001011001000100111101010001000001000001001
10111001111110001111101001100001011010010100110000
01110000101001111000111000111011010000110111011110
01100101001100000101111010100000101000111100001000
10000111110100001111000010100100101111001100011110
00101010110010010110100100100101011010100000110101
01011000001011001111010111001110100101000010111110
00001101100101100011100000110010010010111110001010
01010001000000011100000000011110010110101011001100
10011100001101100011100100011101001000010111001101
[/code]

Find the original stream.

Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

Nice puzzle

  Reveal hidden contents

This is what I have

Edited by bushindo
Link to comment
Share on other sites

  • 0
  On 11/3/2010 at 12:40 AM, bushindo said:

Nice puzzle

  Reveal hidden contents

This is what I have


1 1 0 1 0 1 0 0 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 1 0 0 0 1 1 1 1 1 0 1 0 1 0 1 0 0 1 1 1 1 0 1 1 1 1 1 0 1 0 0
0 0 1 1 1 0 0 1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 1 0 1 1 1 0 0 0 0 1 0 1 1 0 1 1 1 0 0 0
1 1 1 1 0 1 0 0 0 0 1 0 0 1 0 0 1 0 1 0 0 1 0 1 1 0 1 1 0 1 1 0 0 1 0 0 0 0 1 0 0 0 0 1 1 0 0 1 1 1 0 1 0 0 0 1 0 0 0 0
1 0 0 1 0 0 0 1 0 1 1 1 1 0 1 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0 0 1 0 0 0 1 1 0 0 1 1 0 0 1 1 0 1 1 0 1 0 0 0 0 1 0 0 0 1 1
1 1 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 1 1 0 0 0 0 1 1 1 0 0 0 1 0 1 0 1 0 1 0 0 0 1 1 0 0 1 1 1 1 0 0 0 0 0 0 1 1 1 0
0 0 0 1 1 0 0 1 1 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 1 0 0 0 0 1 1 0 1 0 0 1 1 0 0 1 1 0 0 0 0 1 0 1 0 1 0 1 1 0 1 0 0 0 0
1 1 0 0 1 0 0 0 1 0 0 1 0 0 1 0 0 1 0 1 0 1 0 1 1 0 0 1 1 0 1 0 1 0 1 0 1 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 0 0 0 1 1
1 1 1 0 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 0 0 0 0 0 1 1 1 0 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 0 0 0 1 1 1 0 0 1 0 1 1 1 0 0 0 0
1 0 0 0 1 1 0 0 0 0 1 0 0 0 1 1 0 0 1 1 0 1 0 0 0 1 1 0 0 1 0 1 1 0 1 1 1 1 0 1

  Reveal hidden contents

Spot on! Please tell us how you approached the problem. I can think of several ways which may work, but I only checked out one of them.

Link to comment
Share on other sites

  • 0
  On 11/3/2010 at 1:40 PM, superprismatic said:

  Reveal hidden contents

Spot on! Please tell us how you approached the problem. I can think of several ways which may work, but I only checked out one of them.

Thanks for posting that puzzle. I really enjoy working on it, as I do with all your puzzles. I approach it in the following manner:

  Reveal hidden contents

I first write a function that takes in a current guess of the solution, which is a 1000-dimensional binary vector S, and a string index i, and computes how many of 22 possible relations are true with respect to i. For instance, for the first two relations, I compute to see if

S[ i ] + S[ i + 11] = S[ i + 48 ]

S[ i - 48 ] + S[ i - 48 + 11] = S

Of course, for all i, not all 22 relations can be computed since some indices may fall outside of the array. I then compute p, which is the proportion of times we get true statements out of the possible relationships for i.

Some calculations will show that for S equal to the noisy stream given in the OP, if S was not flipped, then p, assuming that we get an average of 15 valid relations, is roughly normally distributed with mean .545 and standard error .033. If S was flipped, then p is normally distributed with mean .456 and standard error .033.

At this point, I let S be equal to the original stream, iterate through S and flip the bits with low p using the following pseudo-code

This code converges in 8 iterations. It can probably converge faster if we put weights on the relationships in computing p. I am interested in your method. How did you approach this problem?

Edited by bushindo
Link to comment
Share on other sites

  • 0
  On 11/3/2010 at 5:38 PM, bushindo said:

Thanks for posting that puzzle. I really enjoy working on it, as I do with all your puzzles. I approach it in the following manner:

  Reveal hidden contents

I first write a function that takes in a current guess of the solution, which is a 1000-dimensional binary vector S, and a string index i, and computes how many of 22 possible relations are true with respect to i. For instance, for the first two relations, I compute to see if

S[ i ] + S[ i + 11] = S[ i + 48 ]

S[ i - 48 ] + S[ i - 48 + 11] = S

Of course, for all i, not all 22 relations can be computed since some indices may fall outside of the array. I then compute p, which is the proportion of times we get true statements out of the possible relationships for i.

Some calculations will show that for S equal to the noisy stream given in the OP, if S was not flipped, then p, assuming that we get an average of 15 valid relations, is roughly normally distributed with mean .545 and standard error .033. If S was flipped, then p is normally distributed with mean .456 and standard error .033.

At this point, I let S be equal to the original stream, iterate through S and flip the bits with low p using the following pseudo-code


S = original stream
loop iter from 1 to 10
loop i from 1 to 1000
compute p[i] given S
if p[i] < .456
flip S[i]
end
end
end

This code converges in 8 iterations. It can probably converge faster if we put weights on the relationships in computing p. I am interested in your method. How did you approach this problem?

  Reveal hidden contents

OK, here goes:

Looking at bit i and the first of the 11 relationships, we can make

three estimates for bit i (except when indices fall outside [1,1000]):

S[ i ] + S[ i + 11] = S[ i + 48] which is S[ i ] = S[ i + 11 ] + S[ i + 48 ]

S[ i-11] + S[ i ] = S[ i + 48 - 11] which is S[ i ] = S[ i - 11 ] + S[ i + 37 ]

S[ i - 48 ] + S[ i - 48 + 11] = S which is S[ i ] = S[ i - 48 ] + S[ i - 37 ]

So, from these equations and knowing that the garble probability, we can

get three estimates for what bit i was in the original stream.

Together with the other 10 relationships, we can get at most 33

estimates for that bit. I combined these estimates (which were

in the form of the probability that the bit was originally a 1)

by multiplying their respective odds. If the resulting odds for being

a 1 is greater than 1, I estimate that the original bit was a 1,

otherwise, I estimate it as a 0.

I know that all the probabilities are not independent of one another,

but who cares? It's my experience that this slop is not very important.

The number of the original equations which are satisfies went up.

So, I re-iterate this process until all the original equations are

satisfied. It took 8 iterations (like yours -- coincidence?).

The number of correct bits were originally 651. They grew like

this: 704, 766, 810, 855, 909, 966, 998, 1000. I should have just

counted hits (like you did) instead of doing that probability stuff.

It would have been simpler to code.

Other possible approaches:

My favorite other idea (which I have not tried) is a discreet hill-climb.

We'll try to minimize the number of times those 11 relations are not

satisfied for all possible placements of the relations in the stream.

So, just try flipping small sets of bits until our object function

decreases. Iterate on this. With a little ingenuity this could be

turned into a Genetic Algorithm.

Link to comment
Share on other sites

  • 0
  On 11/2/2010 at 11:47 PM, superprismatic said:

Yes, but I don't know how that helps solve the problem.

It does not actually. I did not know at the time :(

  Reveal hidden contents

was to estimate the number of possibilities for your input sequence hopefully get something friendlier than 2^48 I saw from the first equation.

Actually, only the first and fourth are independent, but this does not help much. Only reduces to 2^46 possibilities.

In fact, the more equations may be the better, see aproach below.

  Reveal hidden contents

  Reveal hidden contents
Iterate through string, compute for each bit: how many relations are bad / nr of relations in = degree of "badness". Get an overall maximum of the degree of badness. Flip all bits which are near to the maximum badness degree (fixed distance from the degree). Rinse, clean and repeat. Tried idea first with only a few equations and a lot of rounds. Always got myself stuck in local optimum that does not converge to a global optimum (i.e. less than say 350+10 flips. More equations = better the conversion in terms of rounds. Played a little with the no of rounds and the fixed distance to the degree, and it worked. My code's not pretty though, lazy means a lot of copy-paste and some excel pre-processed code
It gets with 529 flips to the solution, in 12 rounds. Only 349 are necessary flips, the other being flipped back as it approached the solution. Could not find another solution nowhere near this optimum.
  Reveal hidden contents

Link to comment
Share on other sites

  • 0
  On 11/3/2010 at 5:38 PM, bushindo said:

  Reveal hidden contents

Some calculations will show that for S equal to the noisy stream given in the OP, if S was not flipped, then p, assuming that we get an average of 15 valid relations, is roughly normally distributed with mean .545 and standard error .033. If S was flipped, then p is normally distributed with mean .456 and standard error .033.

This code converges in 8 iterations. It can probably converge faster if we put weights on the relationships in computing p.

  On 11/3/2010 at 6:53 PM, superprismatic said:

  Reveal hidden contents

OK, here goes:

The number of the original equations which are satisfies went up.

So, I re-iterate this process until all the original equations are

satisfied. It took 8 iterations (like yours -- coincidence?).

The number of correct bits were originally 651. They grew like

this: 704, 766, 810, 855, 909, 966, 998, 1000. I should have just

counted hits (like you did) instead of doing that probability stuff.

It would have been simpler to code.

  Reveal hidden contents

Both algorithms appear to arrive to a solution much easier than my code, converging without much trouble... :blush:

Seems that my greedy thinking was just lucky then. It initially converged in about 1000 rounds and since it flipped bits all at once without any independence check, I actually broke many relations on the way to a solution (as I watched the global "Need" variable).

Link to comment
Share on other sites

  • 0
  On 11/3/2010 at 9:18 PM, araver said:

  Reveal hidden contents

Both algorithms appear to arrive to a solution much easier than my code, converging without much trouble... :blush:

Seems that my greedy thinking was just lucky then. It initially converged in about 1000 rounds and since it flipped bits all at once without any independence check, I actually broke many relations on the way to a solution (as I watched the global "Need" variable).

  Reveal hidden contents

My response to bushindo included an idea similar to yours. I never tried it, though. I hope both of you enjoyed this problem. I really like to solve problems with algorithms that I design myself. I'll bet there are several people on Brainden like me as well. I'll try to put some more of them up here.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...