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 pristine, such that if any one bit in your program is flipped, it should throw an error. For example, if your program was the single byte
01100001), then all the 8 possible modified programs:
á ! A q i e c `
must throw an error. Make sure you are modifying by bytes (e.g. the
á up there is actually representing the byte \$225\$, not the actual two byte character
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 pristine, since there will be a lot of possible programs (number of bytes*8), or else a complete proof of pristineness.
- Please make sure your program is valid before you post it.
- Output needs to be either truthy/falsey (either way around is fine), or else two distinct non-error values
- Errors can be runtime, compiler, interpreter etc.