[Question]
  [
Write three different programs such that when any one program is provided as input to one of the other two, you get the source of the remaining program as output. More explicitly, given programs \$A\$, \$B\$, and \$C\$, where \$f(g)\$ denotes the output obtained from inputting the text of program \$g\$ into program \$f\$, ***all*** of the following must hold:
* \$ A(B) = C \$
* \$ A(C) = B \$
* \$ B(A) = C \$
* \$ B(C) = A \$
* \$ C(A) = B \$
* \$ C(B) = A \$
# Rules and Scoring
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest program length total, in bytes wins.
* Standard quine rules apply.
* Each program must be at least one byte different from the other two
* Each program can be in any language. Any number of them may share languages or each may use a different language.
* Use any convenient IO format as long as each program uses a consistent convention.
	+ Functions are allowed, as this counts as "any convenient IO".
* The result of feeding a program its own source code is undefined
* The result of feeding anything other than program text of either of the other two programs is undefined.
  
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 5 + 5 + 5 = 15 bytes
```
CxCz1
```
```
CxCz2
```
```
CxCx3
```
Try
[A(B)](https://tio.run/##K6gsyfj/37nCucoQQhkBAA "Pyth – Try It Online"),
[A(C)](https://tio.run/##K6gsyfj/37nCucoQQhkDAA "Pyth – Try It Online"),
[B(A)](https://tio.run/##K6gsyfj/37nCucoIQhkCAA "Pyth – Try It Online"),
[B(C)](https://tio.run/##K6gsyfj/37nCucoIQhkDAA "Pyth – Try It Online"),
[C(A)](https://tio.run/##K6gsyfj/37nCucoYQhkCAA "Pyth – Try It Online"),
[C(B)](https://tio.run/##K6gsyfj/37nCucoYQhkBAA "Pyth – Try It Online")
online!
## Explanation
```
CxCz_
  Cz    # convert input from base-256 to int
 x  _   # xor 1, 2 or 3 based on program
C       # convert from int to base-256
```
[Answer]
# C, ~~243~~ ~~240~~ ~~180~~ ~~132~~ 57 bytes
```
f(int*v){ v[4]^=1;}
```
```
f(int*v){ v[4]^=2;}
```
```
f(int*v){ v[4]^=3;}
```
Try it online: [A](https://tio.run/##S9ZNT07@/z9NIzOvRKtMs1qhLNokNs7W0Lr2f3JGYpFCcX5pUXJqdKytEroSI@taJWsuLqCgQm5iZp6GZjWXQpoGRL2mNZdCQWlJMYJb@x8A) [B](https://tio.run/##S9ZNT07@/z9NIzOvRKtMs1qhLNokNs7WyLr2f3JGYpFCcX5pUXJqdKytEroSY@taJWsuLqCgQm5iZp6GZjWXQpoGRL2mNZdCQWlJMYJb@x8A) [C](https://tio.run/##S9ZNT07@/z9NIzOvRKtMs1qhLNokNs7W2Lr2f3JGYpFCcX5pUXJqdKytEroSQ@taJWsuLqCgQm5iZp6GZjWXQpoGRL2mNZdCQWlJMYJb@x8A)
The input program can be passed as a `char*` to the function `f`, and is implicitly converted to an `int*`.
-60 bytes thanks to @Neil  
-48 bytes thanks to @Bubbler  
-72 bytes thanks to @AZTECCO
[Answer]
# [brainfuck](https://github.com/TryItOnline/brainfuck), 33+34+35=102 bytes
Perhaps one of a few answers that has the length of the 3 programs not equal. (\*)
```
+␀>>,<,[<+>,]<-----[+>>.<<].,[.,]
++␀>>,<,[<+>,]<-----[+>>.<<].,[.,]
+++␀>>,<,[<+>,]<-----[+>>.<<].,[.,]
```
[Try it online!](https://tio.run/##SypKzMxLK03O/v9fm8HOTsdGJ9pG204n1kYXBKK17ez0bGxi9XSi9XRigUoIqgEA "brainfuck – Try It Online")
The ␀ (`␀`) represents a null character.
Alternatives:
* `+␀>,>,[<<+>>,]<<-----[+>.<].,[.,]`
* `-␀>,>,[<<->>,]<<+++++[->.<].,[.,]`
(\*): The only one at the time of posting. BF is the only used language that doesn't have integer literal.
---
Explanation:
```
+             Set a cell (call this cell 1) to X (depends on the current program, may be 1, 2 or 3)
<NUL>         No operation
>,            Read the first byte of the input (must be a "+") and store it in cell 2
>,[<<+>>,]    Increment cell 1 by (-1+(the number of remaining "+" in the input until the <NUL>))
                (use cell 3 as temporary storage)
<<-----       Decrement cell 1 by 5
[+>.<]        Print (-(that many)) (cell 2) (must be +)
.             Print a NUL byte
,[.,]         Copies the rest of the input to the output
```
[Answer]
## JavaScript + Python 3 + Bash, 938 bytes
### JavaScript, 465 bytes
```
a=3-2-1//True;a=str(a);alert,eval,prompt=print,exec,input;String=JSON=__builtins__;JSON.stringify=repr;JSON.fromCharCode=chr
s=String.fromCharCode;j=JSON.stringify;r="t='tr '+s(48)+s(49)+' '+s(49)+s(48)";eval(r);d="alert([t,'a=3-2-'+a+'//True;a=str(a);alert,eval,prompt=print,exec,input;String=JSON=__builtins__;JSON.stringify=repr;JSON.fromCharCode=chr\\ns=String.fromCharCode;j=JSON.stringify;r='+j(r)+';eval(r);d='+j(d)+';eval(d)'][+(prompt()[2]<s(33))])";eval(d)
```
### Python 3, 465 bytes
```
a=3-2-0//True;a=str(a);alert,eval,prompt=print,exec,input;String=JSON=__builtins__;JSON.stringify=repr;JSON.fromCharCode=chr
s=String.fromCharCode;j=JSON.stringify;r="t='tr '+s(48)+s(49)+' '+s(49)+s(48)";eval(r);d="alert([t,'a=3-2-'+a+'//True;a=str(a);alert,eval,prompt=print,exec,input;String=JSON=__builtins__;JSON.stringify=repr;JSON.fromCharCode=chr\\ns=String.fromCharCode;j=JSON.stringify;r='+j(r)+';eval(r);d='+j(d)+';eval(d)'][+(prompt()[2]<s(33))])";eval(d)
```
### Bash, 8 bytes
```
tr 01 10
```
## TIO links
[Javascript(Bash)](https://tio.run/##xZCxTsMwEIZ3nqLKYltOaNMwtDI3dWOAoWxpFJnYpY5Cap2dCJ4@OLVAdGPrctJ9J/36v2vlKF2Dxvps3EyThCJbZ/ly@YqDFhKcRyqZkJ1Gn@pRdqnF84f1YNH0gXzqJjW9HbzY@0De4Wn/8gx1/TaYzpve1bWYyb27XM3xC1BbjOwYknYnibuz0tCc8M5BDLm6iBauEwRC4oF4XBDu6MOGzXPLOIn7lkWaiLkuRSYUJJf@tPQpiYKES05uInk49P/WJLwN/Tn5YzIj9YsUI1XJaWxLWbmuHh0tCsaqH33Fpil8apUv8tU3 "JavaScript (V8) – Try It Online")
[Javascript(Python)](https://tio.run/##7ZGxTsMwFEV3vgJlsZ@cUGgYWpk3dWOAoWxpFJnYpY5Caj07EXx9SWoV0Y2tEmKx5POkq3t0GzUoX5N1IRsWh4PCPJtnd7PZC/VGKvSBuAKpWkMhNYNqU0f7dxfQke1G8mHq1HauD3IdRvKGj@vnJ6yq1962wXa@quREbvzxarefSMZRZNsxabVTtNprg/WOrjzGkLOLbPA8QRImAVmgayY8v1/A9C5BsPhfQqSJnOpyAqkxOfbnRUhZFGRCCXYRyc2m@7UmE83YX7AfJhPS30gDKwvBY1sOxbx88DzPAcqTvobTprf/m/6ZTb8A "JavaScript (V8) – Try It Online")
[Python(Bash)](https://tio.run/##xZCxTsMwEIZ3nqLKYltOadowUJmbujHQoWxpFJnaJa6CY52dij59cGqB6MbGctJ9J/36v3OX0Pa2HEcJ5Xw1LxaLVxy0kOADUsmE7DSGXJ9llzvsP1wAh8ZG8qkPubFuCGIXInmH5932BZrmbTBdMNY3jZjIvb9ezfECqB0mdoxJm1biplcaDi3eeUghNxdxgtsEgZAFIAFnhHv68MimuWacpH3NEs3EVJciEwqya39ahZwkQcIlJ/8iud/bP2sSfor9OfllMiH1gxQjdcVpaktZtaqfPC1LxupvfcXGMX6qWM6WxRc "Python 3 – Try It Online")
[Python(Javascript)](https://tio.run/##7ZGxTsMwFEX3fgXKYltOKTQMVOZN3RhgKFsaRaZ2iavgWM8viH59SWoV0Y2tEmKx5POkq3t0w56azheHg4ZiOp/ezGYv2FulIRJyLZRuLVJuP3SbB@zeA0FA5wfyaTe586EntaKBvMHj6vkJ6vq1dy05H@tajeQ6Hq9uuwe0ARPbDknLRuOyMxY2DU4ipJCzi9rBeYJCyAgY4RWTkd/di/FdCMnSfyESzdRYl6NQBrJjf15SzpIgk1qyi0iu1/7Xmkzuhv6S/TAZkflGRrCqlDy15aKcVw@RF4UQ1UnfiNOmt/@b/plNJ18 "Python 3 – Try It Online")
[Bash(Javascript)](https://tio.run/##xY@9bsIwFEZ3ngJlsa8cfkI6FLl3YuvQDnQLUWSwaYxCsK6dqn36NMFqVbZuLJZ8rvTpnL3ydd8Hmi6zabbse4X5bDXLFos36oxU6ANxBVI1hkJqPlSTOrqcXUBHth3IpzmktnVdkNswkHd83r6@YFXtO9sE2/qqkiOZ@@vVHr@QjKPIjsPSpla0uWiDh5omHuPIzUWe8HZBEiYB2eDMhOcPjzC@axAs/tcQaSJHXU4gNSZXf16ElMVAJpRgd4nc7dp/ZzJxGvwF@1MyIv2LNLCyEDzacihW5ZPneQ5Q/uRrmHwD "Bash – Try It Online")
[Bash(Python)](https://tio.run/##xY8xb8IwEEZ3fgXKYp8cIJAORe5NbB3agW4higw2jVEI1tmp2l@fJlitytaNxZLfSZ/e2ytf932gabacLrO@V5jPVrNssXijzkiFPhBXIFVjKKTmQzWpo8vZBXRk24F8mkNqW9cFuQ0Decfn7esLVtW@s02wra8qOZK5v17t8QvJOIrsOCxtakWbizZ4qGniMY7cXOQJbxckYRKQDc5MeP7wCOO7BsHifw2RJnLU5QRSY3L150VIWQxkQgl2l8jdrv13JhOnwV@wPyUj0r9IAysLwaMth2JVPnme5wDlT76GyTc "Bash – Try It Online")
For some reason, TIO doesn't understand Javascript's `alert` function, but you can try it in your browser console.
## Explanation:
The JavaScript and Python codes are 1 byte apart. The only difference is that the JS code starts with `a=3-2-1` where the Python code has `a=3-2-0`. This is a polyglot pseudo-quine. The output is *almost* identical to the source code, but if the source code has a `1` in that statement, the output has a `0`, and vice versa. This is because the pseudo-quine puts the current value of `a` into the string that describes how `a` is initialized.
In other words, the JavaScript code constructs the Python code and vice versa, and it's completely arbitrary which one is considered JavaScript and which is considered Python. Both programs are valid in either language.
Here's the JS/Python code without the quine construction, and with spaces and line breaks to make it more readable:
```
a=3-2-1//True; a=str(a); alert,eval,prompt=print,exec,input; String=JSON=__builtins__; JSON.stringify=repr; JSON.fromCharCode=chr
s=String.fromCharCode; 
j=JSON.stringify; 
r="t='tr '+s(48)+s(49)+' '+s(49)+s(48)"; 
eval(r); 
d="alert([t, <pseudo-quine>][+(prompt()[2]<s(33))])";
eval(d)
```
The JavaScript version ignores all the redefinitions after `//` on the top line, and redefines the verbose `String.fromCharCode` and `JSON.stringify` functions to single characters. It then constructs the string `tr 01 10` and the pseudo-quine and puts both in a list. To access the list, it checks whether the third character in the input is less than `!` and casts the result to an integer with `+(bool)`. If the input is `tr 01 10` (or anything else with a space as the third character), this check is true and it prints the pseudo-quine. If the input is the Python code, this condition is false, and it prints `tr 01 10`.
The Python logic is identical, but it renames some functions and creates dummy `JSON` and `String` namespaces for compatibility with JavaScript. It also casts `a` to a string so Python won't complain about concatenation. The redefinitions are possible because `//` is a comment in JavaScript, but floor division in Python. `a//True` is the same as `a//1`, but I'm avoiding the use of `1` and `0` everywhere except the first statement.
Finally, `tr 01 10` simply changes `0` to `1` and vice versa. This has the same effect as running the JS/Python code with the other version as input.
I initially chose Python and Javascript because they have a lot of overlapping syntax and `//` made it easy to add compatibility logic, but I ended up having to redefine more functions than I expected. There's probably a better pair of languages for this approach (maybe Python and Ruby?). I guess I could have cheated by using Python 2 and 3 as my "different languages", but that's hardly the most interesting approach :)
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 42 bytes
```
≔0η⭆θ⎇⊖κι⁻⁻³ηι
≔1η⭆θ⎇⊖κι⁻⁻³ηι
≔2η⭆θ⎇⊖κι⁻⁻³ηι
```
[Try it online!](https://tio.run/##S85ILErOT8z5//9R5xSDc9sfrW07t@NRX/ujrmnndp3b@ahxNxAd2nxu@7mdYCWGeJUAAA "Charcoal – Try It Online") Link shows `A` passed `B` and printing `C`. Explanation:
```
≔0η
```
Store either `0`, `1` or `2` in a variable as appropriate.
```
⭆θ
```
Map over the parameter.
```
⎇⊖κι
```
Leave all characters except the second unchanged.
```
⁻⁻³ηι
```
Subtract the variable and the second character from 3.
[Answer]
# [APL (Dyalog Unicode)](https://www.dyalog.com/), 30 [bytes](https://github.com/abrudz/SBCS)
```
(⍕3-0+⍎)@5
(⍕3-1+⍎)@5
(⍕3-2+⍎)@5
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///X@NR71RjXQPtR719mg6mXBCuISrXCMr9n/aobYI6qg51rnSEoCFcMAMhCNOt/j/jUedCoFhfmmY6F4ydrpkGNAEmngFnZwDF0@BqMuDsDM10AA "APL (Dyalog Unicode) – Try It Online")
Three functions that change the 5th character (from the left, 1-based) from the input string. Link shows that all six requirements (`f(g)≡h` etc.) are satisfied.
```
(⍕3-n+⍎)@5  ⍝ All functions share the same format
(      )@5  ⍝ Apply to the 5th character only...
      ⍎       ⍝ Eval the character; m←0 or 1 or 2
  3-n+        ⍝ 3-(n+m)
 ⍕            ⍝ Stringify the above
```
[Answer]
# JavaScript (ES6), 75 bytes (3 x 25)
Uses the same approach as most other answers.
```
// f1
s=>s.replace(/\d/,x=>x^1)
// f2
s=>s.replace(/\d/,x=>x^2)
// f3
s=>s.replace(/\d/,x=>x^3)
```
[Try it online!](https://tio.run/##fc5BCsMgEIXhvSdxoDXorM0lsg0FMU5IESeolNzeZJ0S19/74X3dzxWft72@Ey@hkbat2LGoHPbofJDDvAyvw47HR0MjY8WDGhCEj4oghOdUOAYVeZWkJRlVeap5S6sEgD/GDptr0edejf0a79faCQ "JavaScript (Node.js) – Try It Online")
[Answer]
**[Python 3](https://www.python.org/downloads/release/python-380/), 3\*51 = 153 bytes [Try it online!](https://tio.run/##K6gsycjPM7YoKPr/v8I2M6@gtERD07qgKDOvRKNCryi1ICcxOVWjIlrXJFanuKRIAywO4mnGGWlqapKsyRioCQA "Python 3.8 (pre-release) – Try It Online")**
```
x=input();print(x.replace(x[-4],str(int(x[-4])^1)))
x=input();print(x.replace(x[-4],str(int(x[-4])^2)))
x=input();print(x.replace(x[-4],str(int(x[-4])^3)))
```
Adapted @aidan0626 answer, got the same length
---
Although, this would return the actual function if in/out would be functions instead of programs.
```
def a(x):return b if x==c else c
def b(x):return c if x==a else a
def c(x):return a if x==b else b
```
works for inputs like c(c(c(b(a(c(a)))))) -> b
[Answer]
# [Japt](https://github.com/ETHproductions/japt), 3\*3 = 9 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
Uses the convenient I/O format of an array of characters.
```
o^1
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=1.4.6&header=cQ&code=b14x&input=Im9eMiIKLVA)
[Answer]
# [J](http://jsoftware.com/), 72 51 bytes
```
0&(3-+)&.".@{.,}.
1&(3-+)&.".@{.,}.
2&(3-+)&.".@{.,}.
```
[Try it online!](https://tio.run/##y/r/30BNw1hXW1NNT0nPoVpPp1aPyxBDxAhd5H@irR6mxiRbPUy9ybZ6GNq5uIqBBqhjmKDOVQw0Q90QizjQGHUjTHGu1OSMfIXiZAVdK4VEheIkKD8Jyk@G8hNB/CQEPxnKT0RWn4zgJ0L5Sf8B "J – Try It Online")
*-21 bytes thanks to Bubbler!*
## original
# [J](http://jsoftware.com/), 72 bytes
```
a=.(0{3":@-0+8".@{])`8:`]}~
b=.(0{3":@-1+8".@{])`8:`]}~
c=.(0{3":@-2+8".@{])`8:`]}~
```
[Try it online!](https://tio.run/##dcxBCoAgEIXhvaeQNhZRpG1CCLpI0MwQRJsWLqOubgUDitLy53u83XsY27I7@8JOTVcPRTudc7UMdpmvW2AwnRoFM4l54d5X9XerhMOIdc4UsclYrLQd0pFsrATpkBu5iRu@xtDEDfGeQgM3@gc "J – Try It Online")
*Heavily inspired by [Bubbler's clever answer](https://codegolf.stackexchange.com/a/209761/15469).*
*Note: -11 off stated TIO score for the `a=.`, `b=.`, `c=.` pieces, and line breaks*
[Answer]
# [Raku](https://github.com/nxadm/rakudo-pkg), 11+11+11=~~45~~ 33 bytes
```
{S{\d}+^=1}
{S{\d}+^=2}
{S{\d}+^=3}
```
[Try it online!](https://tio.run/##K0gtyjH7n1upoJamYKvwvzq4OialVjvO1qj2f3FipUKaRnpqiSZC2LAWAA)
Xors the first digit in the input with the current program's index.
[Answer]
# [Japt](https://github.com/ETHproductions/japt) v2.0a0, 6 + 6 + 6 = 18 [bytes](https://en.wikipedia.org/wiki/ISO/IEC_8859-1)
```
d\d_^1
```
```
d\d_^2
```
```
d\d_^3
```
[Try it](https://petershaggynoble.github.io/Japt-Interpreter/?v=2.0a0&code=ZFxkX14x&input=ImRcZF9eMiI)
## Explanation
```
d\d_^?
d       // Replace occurrences
 \d     // of a digit
   _^?  // with the digit xor 1, 2 or 3 based on program
```
[Answer]
# [PHP](https://php.net/), 30 \* 3 = 90 bytes
```
$argn[9]=1^$argn[9];echo$argn;
$argn[9]=2^$argn[9];echo$argn;
$argn[9]=3^$argn[9];echo$argn;
```
[Try it online!](https://tio.run/##lY/BCoJAEIbv@xSLLGiHWNJTbhK7g0EgEaknLYiI7LIu1fO3mSIouFq3Geb7Zv5RhdKrtSoUul6KElvb3T5N8CGM0yjxc2kxTc6Pm8yWx2Bxakv2ZeuGaUo5IhwH2B4HbYYQpQIR0WNdMwuIQI/1TGwTPZe55FGEgcdh7Fv1Du6IGarBahMBhlu0Go/nbWzo2OJPWzi8Y/Nh2zXbMJ3caMMvtz2zLab/HrT1eLR3qV73Uj71fPMB "PHP – Try It Online")
Uses the XOR approach, because he's the space sheriff
[Answer]
# [Python 2](https://docs.python.org/2/), ~~186~~ 153 bytes
-33 bytes thanks to @Neil
```
x=raw_input();print x.replace(x[48],`int(x[48])^1`)
x=raw_input();print x.replace(x[48],`int(x[48])^2`)
x=raw_input();print x.replace(x[48],`int(x[48])^3`)
```
[Example](https://tio.run/##K6gsycjPM/r/v8K2KLE8PjOvoLREQ9O6oCgzr0ShQq8otSAnMTlVoyLaxCJWJwEoCGFqxhkmaJKuyThBEwA)
Takes input from the user using `raw_input()` and changes the number after the `^` symbol and prints it out
[Answer]
# [Befunge-98](https://esolangs.org/wiki/Funge-98), 3 \* ~~15~~ 14 = ~~45~~ 42 bytes
*-1 \* 3 bytes thanks to @Jo King!*
```
0'c\~+-#;,#@~;
1'c\~+-#;,#@~;
2'c\~+-#;,#@~;
```
[Try it online!](https://tio.run/##S0pNK81LT9W1tNAtqAQz//83Uk@OqdPWVbbWUXaos/7/3wCFDwA)
Uses the subtraction method.
### Explanation
```
X'c\~+-#;,#@~;
X               # Push X (the number of the program, either 0, 1, or 2)
 'c             # Push 99
   \            # Swap 99 and X
    ~           # Get the first character of the input (which is 48+Y, where Y is the number of the second program)
     +          # Add (the stack now looks like [99, 48+X+Y])
      -         # Subtract 48+X+Y from 99, leaving 51-X-Y
       #;       # (skipped)
                # (begin loop)
         ,      # First iteration: Output 51-X-Y, the first character of the third program
          #@    # (skipped)
            ~   # Get the next character of the input
        ;    ;  # Jump to the start of the loop
         ,      # Output the character unchanged
                # (repeat)
            ~   # On EOF, reverse direction
           @    # End the program
 
```
[Answer]
# [Lua](https://www.lua.org/), 64\*3=192 bytes
```
print(((...):gsub('%d',load"return ('').char((...):byte()~1)")))
```
[Try it online!](https://tio.run/##pVJda4MwFH2ev@LSUWLACuqbw4e@DAZjFPooUqKmTohJyQeslO6vuxjTCn0a24t6zkmO9557mSEjEw1hIKkK5q@j4Y3uBYeT7Lk@KG3qMI5jHDwRpajU4fPFwisUBSSWtBehAMsElLfe4iRFN7GXshydSxg6i7xT1gytWxQxQdqVpNpIDiFCOG4@ifSn6rOmIf5O8ApjPFbVS1CWwd99UucT/NsnW3yuwWNYmiodTn1LMkRAZGcGynUE9OtEG03bg83JMG0D22zgQ2iagyY1ozAYpaERXJOeA2EMOiZqwhQYRVuoz3AWRoJ3vs9gKtf9TpVeqiLgPfOPy6TbAUyvaB6kRctArxj727dKK1uZjwbtZkdYt0snDtyagbkZy@WwVgjnRyEH8pv@I3D7UswrUj6oFRDeAtpt93sEQgJ63b69I5v5tFqBiziJII0gw3eUWcIjKySLljot8ShzWrqg6TAefwA "Lua – Try It Online") (includes test cases)
Other two programs:
```
print(((...):gsub('%d',load"return ('').char((...):byte()~2)")))
print(((...):gsub('%d',load"return ('').char((...):byte()~3)")))
```
Use xor like many other programs
[Answer]
# [Python 2](https://docs.python.org/2/), 123 bytes
```
lambda x:x.replace(x[-4],`int(x[-4])^1`)#
lambda x:x.replace(x[-4],`int(x[-4])^2`)#
lambda x:x.replace(x[-4],`int(x[-4])^3`)#
```
[Try it online!](https://tio.run/##jY9BbsMgEEX3nALRRUCikZJ2FckLZo7huA5tLdUScZGNKvf07gRkQ6susoLPPD3@@O/w8TkcF9NOYdQc0oG3g1dcCLE4e319t3w@zfux886@dXKuH58bfemHkK7q5XBRD@wu8ng3@UTkQg32k3d9cP3QTVLVh1PDmKGm1JIaXq2X3Zd1mtf/rNAoYlsgzsj4rihijJgig9ZQBmlShjiGbYxxjOsYowxXGfMjFeaC7Irez0FoTv9pvjuHXbzyqkpVMooFihnFGxq9m5ZabSz1XNlY@Y8WCi1kLSSt@aXFQotZi0kLpRaLxTAvhmmxqF1@AA "Python 2 – Try It Online")
Note that the comment at the end is required since otherwise the index will have to be either `-3` or `37` instead of `-4` which will mess things up when replacing 3
]