Write a program/function that takes two integers in the range \$0\$ to \$255\$ inclusive, and returns whether the binary forms of the numbers are exactly one bit different.
For example, \$1\$ and \$0\$ have binary forms
00000000, which are one bit apart. Similarly, \$152\$ and \$24\$ are
000011000, so they return true.
However, your code must be radiation-hardened, such that if any one bit in your program is flipped, it should still work correctly. For example, if your program was the single byte
01100001), then all the 8 possible modified programs:
á ! A q i e c `
must still work correctly. Make sure you are modifying by bytes (e.g. the
á up there is actually representing the byte \$225\$, not the actual two byte character
With Truthy meaning they are different by one bit.
0,1 => Truthy 1,0 => Truthy 152,24 => Truthy 10,10 => Falsey 10,11 => Truthy 11,12 => Falsey 255,0 => Falsey
- Provide a testing framework that can verify that your program is properly radiation-hardened, since there will be a lot of possible programs (number of bytes*8), or else a complete proof of validity.
- Please make sure to double-check your program is valid before you post it.
- Output can to be either truthy/falsey (either way around is fine), or else as one distinct value for truthy and the rest as falsey
- This can be through any of the Standard input/output methods
Here is a helper program that can be used to produce all the variations of an inputted program.