Jelly, 4 bytes
HL\^
A monadic Link that accepts an integer and yields a list of one integer. ...Or a full program that accepts an integer and prints the result.
The code's bytes only change by one bit each time, as required:
Byte | Hex | Binary |
---|---|---|
H |
48 | 01001000 |
L |
4C | 01001100 |
\ |
5C | 01011100 |
^ |
5E | 01011110 |
How?
The shortest code that starts with H
(halve) and ends with ^
(XOR the input) for which the code in between has no adverse effect while fulfilling the source-code restriction of only changing by at most one bit from byte to byte.
HL\^ - Link: integer, N
H - halve N -> N/2
\ - cumulative reduce with:
L - length -> [N/2]
^ - (floor to integer) XOR (N) -> [floor(N/2) XOR N]
Note
:2
(integer divide by two) seems like a reasonable start as the bytes already only differ by one bit, but the next available bytes (Ø"036:rḶ
) don't really help us advance.