Once again based on a real problem from work
Today we are doing something really simple. We just need to send a message from one device to another. The message is a single bit of information, either true or false. The sender can send 32 bits to the receiver. Reading a bit before the message will return randomly all 0s or all 1s. Same for reading a bit after the message. The receiver tries to read 64 bits centered on the message.
However we are in the real world, so there are a couple of sources of error.
A bit might be skipped
A bit might be duplicated
The message may be shifted
A few bits are flipped
An example of how the message transforms before reaching the receiver is shown bellow:
Your goal is to come up with two messages, and write a function that determines which one was sent. Your function will need to maintain a 95% accuracy rate on as high of a noise level as possible. The exact definition of the noise level can be seen at the bottom of the page before the hints.
Write the two messages here on two lines. You may use base 10 or 0x notation for hex. Note that the message will be truncated to 32 bits if more are given.
Write the JS function here that returns true if it receives the first message and false otherwise. You will receive a UInt8Array of length 8
This uses eval please don't paste code you don't trust
The exact noise algorithm is given bellow. Treat the message as a list of bits. For a noise value N
A single bit is dropped with probability arctan(N/100-5)/PI+0.5
A single bit is duplicated with the same probability
Each of the prefix and suffix is each independently either entirely 0s or entirely 1s (with equal probability)
The message is shifted with a normal distribution mean 0, std = 12 - 1200 / (100 + N)
N/100 bits are flipped (the same bit may be flipped twice)
Need a hint? Click below: