05AB1E, 11 bytes
;3ss{Ƶ}]\\^
Try it online or verify all test cases.
The core program without the restricted-source would have been 2 bytes:
;^
Try it online or verify all test cases.
Explanation:
Explanation of the core program:
; # Halve the (implicit) input
^ # Implicitly truncate it to an integer, and bitwise-XOR it with the
# (implicit) input
# (after which the result is output implicitly)
The idea is to add no-ops between them without changing the functionality. I started by creating a generator to get all 05AB1E character-pairs that differ by a single bit. Before the ^
, only \
and V
seemed reasonable candidates (\
discards the top of the stack; and V
pops the top of the stack and saves it in variable Y
). From there it was kinda trial-and-error to see what characters I could use. Because the ;
and ^
differ by 4 bits, at least that many no-op bytes in between are necessary. Although I have the feeling the byte-count can still be improved a bit perhaps, 9 bytes to change 4 specific bits without changing the functionality of the core program isn't too bad I guess.
Explanation of the new program:
; # Halve the (implicit) input-integer
# No-ops:
3 # Push 3
s # Swap the two values on the stack
s # Swap them back
{ # Sort the digit(s) of 3
Ƶ} # Push compressed integer 226
] # Close all open if-statements and loops
\ # Discard the top of the stack (the 226)
\ # Discard the top again (the 3)
^ # Implicitly truncate the halved input to an integer, and bitwise-XOR
# it with the (implicit) input
# (after which the result is output implicitly)
(See this 05AB1E tip (section How to compress large integers?) to understand why Ƶ}
is 226
.)
The bytes in 05AB1E's codepage of ;3ss{Ƶ}]\\^
are:
; 00111011
v
3 00110011
v
s 01110011
s 01110011
v
{ 01111011
v
Ƶ 01111111
v
} 01111101
v
] 01011101
v
\ 01011100
\ 01011100
v
^ 01011110