[Question]
  [
Given two strings of letters, transfer the capitalization pattern of each string onto the other one. Fewest bytes wins.
```
Input:   CodeGolf xxPPCGxx  
Output:  coDEGOlf XxppCgxx
```
* Both strings will be equal-length and nonempty, with only letters `a..z` and `A..Z`.
* You may output the two resulting strings in either order relative to the inputs.
* You may represent a pair of strings as one string with a non-letter single-character separator for input and/or output.
* You may represent a string as a list of characters or one-character strings, but not as a sequence of code point values unless these are simply strings in your language.
* Your input and output may represent strings differently.
**Test cases:**
```
CodeGolf xxPPCGxx -> coDEGOlf XxppCgxx
lower UPPER -> LOWER upper
MiXeD lower -> mixed LoWeR
A A -> A A
ABcd EfGh -> AbCd EFgh
```
  
[Answer]
# [Java (JDK 10)](http://jdk.java.net/), 66 bytes
```
a->b->{for(int i=a.length,t;i-->0;b[i]^=t)a[i]^=t=(a[i]^b[i])&32;}
```
[Try it online!](https://tio.run/##ZZBda8IwFIbv/RWHgqMdbdDtbl0LzjmvBJkMBqWDGFONq0lJTv1A/O0u/ZgOdxFOzvuevHmSNd3SYL34PotNoTTC2vakRJGT@7DzT8tKyVAoWZksp8bAhAoJxw5AUc5zwcAgRVu2SixgYz13hlrIZZIC1Uvj1aMAb23OM1tRnaT@UElTbrhu@ziGDKIzDeJ5EB8zpV0hEURESc7lElc@hiII4l44T0T6FaFHmxq59aZSvbvHh/B0DuvrLgzIDRqIWgoAZ6gWfKzyDPb76XQ43u8d/9fK1Y5r@JhOR@9XcSI@@SvU1lUcwOBP88IWMMrGK6dWTg1B9YaGomZ4aki8C8iV0NJVHjFFLtB1wPHCdqb5GzvDqhcAJr2UoBpadaA1Pbieb7X@jWYBANqAjNCiyA8usyc9QhnjBdqmn16umB0M8g1RJZLCAmHmOl0DXdOVjg@S71rOJuFGsTFtzqlTrdP5Bw "Java (JDK 10) – Try It Online")
## Explanations
```
a->b->{                           // Curried lambda
 for(int i=a.length,t;i-->0;      //  Descending loop on i,
                                  //  Declare t
     b[i]^=t                      //   Apply the case difference to b[i]
   )
  a[i]^=t=(a[i]^b[i])&32;         //   Assign the case difference of the two letters to t, and apply it to a[i].
}
```
[Answer]
# [C (gcc)](https://gcc.gnu.org/), ~~86~~ ~~58~~ ~~55~~ 53 bytes
* Saved twenty-eight bytes thanks to [Cows quack](https://codegolf.stackexchange.com/users/41805/cows-quack).
* Saved three bytes.
* Saved two bytes thanks to [Olivier Grégoire](https://codegolf.stackexchange.com/users/16236/olivier-gr%c3%a9goire).
```
c(a,s,e)char*a,*s;{for(;*s++^=e=(*s^*a)&32;)*a++^=e;}
```
[Try it online!](https://tio.run/##TY5da8IwGIWv568IhY0kvt5sVyVzsFXXmw2LMpTOKTGmH6BtaTpWWvrba9L6sRDenDznHBIxCoVoW4E5KJBERDynHKhidZDmmFE1HG7Gcoyp2lBOHp4eGaG8Y6xpC6yggq2CbdU3FdAKqAZ0W7HaILT4tm37B/zuYCrL46QI8AIUuV58qAgTmvmEnZGF9LpXeq8TNHq5yOebXCcWIAWoArQA5APSryL9D9YMjjxOMKkHdwW2nHQv3fQQ6LBVlp7nuGVptEgnU3fW81WZZU6oOWFd55D@ydwYX543nRvxMVv24jfLtHXOfcYrOTH0WjjGpdx3hXQp55fcqyH/x4W/iS48DdyoM3ZOf38Po1vGEL67TU2017Qn "C (gcc) – Try It Online")
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 9 bytes
```
O&32^/^OỌ
```
[Try it online!](https://tio.run/##y0rNyan8/99fzdgoTj/O/@Hunv8Pd295uGPTo6Y1h9uBhDcQR/7/75yfkuqen5OmUFEREODsXlHBlZNfnlqkEBoQ4BrE5ZsZkeqiABbhclRw5HJ0Sk5RcE1zzwAA "Jelly – Try It Online")
### How it works
```
O&32^/^OỌ  Main link. Argument: [s, t] (pair of strings)
O          Ordinal; replace each character with its code point.
 &32       Perform bitwise AND with 32, yielding 32 for lowercase letters, 0 for
           uppercase ones.
    ^/     Reduce by XOR, yielding 32 for letter pairs with different 
           capitalizations, 0 for letter pair with matching capitalizations.
      ^O   XOR the result with each of the code points.
        Ọ  Unordinal; replace each code point with its character.
```
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), ~~13~~ 12 bytes
```
⊖⊖819⌶¨⍨∊∘⎕a
```
[Try it online!](https://tio.run/##LYu9bsJAEAb7PAXdQkGRLqEzxrhxhIWEoL3Yd8bKoTsZUC5C6SLEnyMoEqVNh@ihoORR9kXMmkPa4tPMLNOyHn8wqZJ6JNl4nEZFIXC@xdUv3dPjM25Olz3me1yscPGH3z@sKCYUzDA/4vI/oykwPzdAvQGuv0CwVAIB0tnnQxXnO3BVzH0lBVTAmDB0fWOgNilNpFqe37mZgdHaTcjYH6neeUa4F4Ze914HnT7tCky1Jme7l3TAW8Rsb7tRanhMLFB93i27/ACOU0o77KfTjMrIE/7w/ue8ujfSToZwBQ "APL (Dyalog Classic) – Try It Online")
input and output is a 2×N character matrix
`⎕a` is the uppercase English alphabet `'ABC...Z'`
`∊∘⎕a` returns a boolean matrix indicating which letters in the input are uppercase
`819⌶` converts its right argument to uppercase or lowercase depending on its boolean left argument ("819" is leetspeak for "BIG")
`819⌶¨⍨` does that for each (`¨`) character, swapping (`⍨`) the arguments
`⊖` means reverse vertically; one `⊖` acts as the left argument to `819⌶` and the other is the final action
[Answer]
# [Pyth](https://pyth.readthedocs.io), 10 bytes
```
rVV_mmrIk1
```
[Try it here!](https://pyth.herokuapp.com/?code=rVV_mmrIk1&input=%5B%22CodeGolf%22%2C%22xxPPCGxx%22%5D&debug=0)
### Explanation & neat Pyth tricks used
* `rVV_mmrIk1` — Full program. Input is taken from STDIN as a list of two strings, and the output is written to STDOUT as a list of two lists of characters.
* `mm` — For each character in each of the strings:
	+ `Ik` — Check if it is invariant under...
	+ `r...1` — ... Converting to uppercase. Yields **True** for uppercase characters and **False** for lowercase ones.
* `_` — Reverse that list.
* `VV` — And double-vectorize the following function over the two lists:
	+ `r` — Convert to uppercase if the value is `True` (aka `1`), else convert to lowercase.
This submission abuses the fact that `r0` and `r1` are the lowercase and uppercase functions in Pyth, and we use truth values (the values obtained by checking if each character is uppercase, reversed) yielding `True` for uppercase and `False` for lowercase. The fact that booleans are subclasses of integers in Python is very handy for the approach this answer is using. Porting Dennis and Jonathan's Jelly approaches both resulted in more than 18 bytes, so I am quite happy with the Pyth-specific tricks used here.
[Answer]
# [MATL](https://github.com/lmendo/MATL), 11 bytes
```
kG91<P32*-c
```
[Try it online!](https://tio.run/##y00syfn/P9vd0tAmwNhISzf5//9odef8lFT3/Jw0dWsF9YqKgABn94oK9VgA) Or [verify all test cases](https://tio.run/##y00syflvaqWUGeH1P9vL0tAmwNhISzf5v7qurvr/aHXn/JRU9/ycNHVrBfWKioAAZ/eKCvVYrmj1nPzy1CKQaGhAgGsQWMg3MyLVBSQEkQMJOYK4jhCmU3IKiOea5p6hHgsA).
### Explanation
```
k      % Implicit input: 2-row char matrix. Convert to lower-case
G      % Push input again 
91<    % Less than 91?, element-wise. Gives 1 for upper-case
P      % Flip vertically
32*    % Multiply by 32, element-wise
-      % Subtract, element-wise
c      % Convert to char. Implicit display
```
[Answer]
# [Haskell](https://www.haskell.org/), 78 bytes
```
import Data.Char
c x|isUpper x=toUpper|1<2=toLower
(!)=zipWith c
x#y=(y!x,x!y)
```
[Try it online!](https://tio.run/##VYqxCoMwFAD3fMUzdlAohXZuJgsuGVyKc9AUH42@EFP6LP57Grr1poO7yaxP61xKOHsKEW4mmlMzmSAG4B3Xu/c2AKtIP9vP10t2TW8bRFXU6oO@xzjBILjcVLUVfORiq9NscAEFIwnI@IBLhAPIhkbbknvIUjJ3XdMyy/9Dv3SO1JNMXw "Haskell – Try It Online")
[Answer]
# x86-64 machine code, 14 bytes
Callable from C (x86-64 SysV calling convention) with this prototype:
```
void casexchg(char *rdi, char *rsi);  // modify both strings in place
```
An explicit-length version with length in `rcx` is the same size. `void casexchg(char *rdi, char *rsi, int dummy, size_t len);`
---
This uses the same bit-exchange algo as the C and Java answers: **If both letters are the same case, neither needs to change. If they're opposite case, they both need to change.**
Use XOR to diff the case bit of the two strings. `mask = (a XOR b) AND 0x20` is 0 for same or 0x20 for differing. **`a ^= mask; b ^= mask` caseflip both letters iff they were opposite case.** (Because the ASCII letter codes for upper and lower differ only in bit 5.)
NASM listing (from `nasm -felf64 -l/dev/stdout`). Use `cut -b 26- <casexchg.lst >casexchg.lst` to turn this back into something you can assemble.
```
   addr    machine
 6         code          global casexchg
 7         bytes         casexchg:
 8                       .loop:
 9 00000000 AC               lodsb                ; al=[rsi] ; rsi++
10 00000001 3207             xor   al, [rdi]
11 00000003 2420             and   al, 0x20       ; 0 if their cases were the same: no flipping needed
12                       
13 00000005 3007             xor   [rdi], al      ; caseflip both iff their cases were opposite
14 00000007 3046FF           xor   [rsi-1], al
15                       
16 0000000A AE               scasb                ; cmp al,[rdi] / inc rdi
17                           ; AL=0 or 0x20.
18                           ; At the terminating 0 in both strings, AL will be 0 so JNE will fall through.
19                           ; 0x20 is ASCII space, which isn't allowed, so AL=0x20 won't cause early exit
20 0000000B 75F3             jne  .loop
21                       ;    loop  .loop            ; caller passes explict length in RCX
22                       
23 0000000D C3               ret
  size = 0xe bytes = 14
24 0000000E 0E           db $ - casexchg_bitdiff
```
The slow `loop` instruction is also 2 bytes, same as a short `jcc`. `scasb` is still the best way to increment `rdi` with a one-byte instruction. I guess we could `xor al, [rdi]` / `stosb`. That would be the same size but probably faster for the `loop` case (memory src + store is cheaper than memory dst + reload). And would still set ZF appropriately for the implicit-length case!
[Try it online! with a \_start that calls it on argv[1], argv[2] and uses sys\_write on the result](https://tio.run/##jVNRa9swEH73r7i3JcQpcTZGSehDCaN0jFK6l0EbjGyfHQ1FEpKaKL8@O8l262TZqB5k63T36bvv7pi1uC3EYSqZ3R6PjVAFE1Ayi77cNHnBXcXrOjk3LJIroZReJEBLqMoW8c8rQzsTKTybiq@jjcmqs838fAbtWsIMeA1ug9zE1yzs0WAwgGVbXIBUUAuuNZcNSMQKq2TwRIRPCbWHCxjBHwrlNgR9AVtprSx3eAJj@TSLQC26Jf8CztYSuCyBXkza0@2PmxlQfMjnqre5yN2h2XLJXGBNGcqWjnWGDDalSNhzIaBAurUKvj98aw01o81tjHptNj1klItbuP25ur8Hq1mJKew3vKT8rPzkiLRQe6zSgBQ4Bf@9Cjcle7UIyIw4AHruIuJviQCxbMmyLZvSneE025KA0YBmNmiHXgteOhAomyCthKfVr1Ytg67vmNw6ZlzSftq22KpddKp4aAerJ9nXdcRnptk9Z@uky5PUIexRZx0PY8GUPoVpNigZUFpko62joCmtt7ItQwTcwLQFhSnMo5tUrseL5wrLt/PHyA6dbO80/zJwmncZCWTR6zo4lX6SrTtdLdthJ@Mkg5rSEYwaJgYFzePnbPCG72Igl11mQnRPXUkjc10NbcXBYez4ial87PqZZy19rZGm9EWG6mpBjQYqDhB1ad/RypzghxpkIXgJef7wlO9NP1n2YLtk@n6Kd6Ms7bVMgwjj5J@S/p/0G@sX@TejDzGY9wyW78rHKRm22UmXDd@Yf778SqzwweYBKW9okvVoNj4eV6rCOyXqo/ePj6s77/8A "Assembly (nasm, x64, Linux) – Try It Online")
[Answer]
# [k](https://en.wikipedia.org/wiki/K_(programming_language)), 14 bytes
```
{`c$l+|x-l:_x}
```
[Try it online!](https://tio.run/##y9bNz/7/P82qOiFZJUe7pkI3xyq@ovZ/mrqGhpJzfkqqe35OmpK1UkVFQICze0WFkiaXhlJOfnlqEVAwNCDANQgs4psZkeoCFIHIAEV0lByVrEEESNbRKTkFKOma5p6hpKn5HwA "K (oK) – Try It Online") Input/output is a list of two strings.
[Answer]
# [J](http://jsoftware.com/), 36 31 27 bytes
-9 bytes thanks to FrownyFrog!
```
(XOR"$32*[:~:/97>])&.(3&u:)
```
[Try it online!](https://tio.run/##y/qfVmyrp2CgYKVg8F8jwj9IScXYSCvaqs5K39LcLlZTTU/DWK3USvO/JpeSnoJ6mq2euoKOQq2VQloxF1dqcka@QpqCunN@Sqp7fk6auo6VekVFQICze0WFOkRWXR2uKie/PLUIpCQ0IMA1CFPeNzMi1QUkD1GIIe8IknPEIu6UnAKSck1zz1D/DwA "J – Try It Online")
The previous solution was:
# [J](http://jsoftware.com/), 36 31 bytes
-5 bytes thanks to FrownyFrog! 
```
|:@(XOR 32*0~:/@|:97>])&.(3&u:)
```
[Try it online!](https://tio.run/##y/qfVmyrp2CgYKVg8L/GykEjwj9IwdhIy6DOSt@hxsrS3C5WU01Pw1it1ErzvyaXkp6CepqtnrqCjkKtlUJaMRdXanJGvkKagrpzfkqqe35OmrqOnnpFRUCAs3tFhTpEVl0drionvzy1CKQkNCDANQhT3jczItUFJA9RiCHvCJTTAZKYEk7JKSB9rmnuGer/AQ "J – Try It Online")
## How it works:
```
                          (3&u:)  converts the strings to code points
   (                    )&.       then do the following and convert back to chars
                    97>]          check if they are uppercase letters 
             0~:/@|:              transpose and check if the two values are different
          32*                     multiply by 32 (32 if different, 0 otherwise)
      XOR                         xor the code point values with 32 or 0
 |:@                              and transpose
```
[Answer]
# [R](https://www.r-project.org/), ~~118 94 75~~ 72 bytes
```
m=sapply(scan(,""),utf8ToInt);w=m>96;apply(m-32*(w-w[,2:1]),2,intToUtf8)
```
[Try it online!](https://tio.run/##jY1PC4IwAMXvfooxL1vMQ0Z/xS5W0ikPBUF0WMuFMLeRE@enX4YZHTs8ePAev9/T@UxttulBcHC2WicPaz1/V0tmCiWpAJUS9buC@RTcWpNXns/jLp8HoqSMK6q1aLtaG744qr00mDRxuV7OcL@UwSQcoSZoLiRcja@YhKSQ5qhO3R93MMQQTNQ9T5XgkEBrsyxJrYUYuy@9YlQiAiH@sUS9JfrD4gY@GOjuBQ "R – Try It Online")
~~There must be a much golfier way.~~ -43 bytes thanks to Giuseppe who pointed me to [the MATL solution by Luis Mendo.](https://codegolf.stackexchange.com/a/166014/80010)
TIO link contains a function solution for the same byte count.
```
m=sapply(a<-scan(,""),utf8ToInt)    # Turns input into a matrix of bytecode (2 columns)
w=m>96                              # Predicate : which chars are lower?
apply(m-32*(w-w[,2:1]),2,intToUtf8) # -32*w turns the string to UPPER
                                    # +32*w[,2:1] swaps capitalization
                                    # intToUtf8 turns bytecode to strings
```
Bonus: The output is a named vector whose names are the original input strings!
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `ṡ`, 4 bytes
```
•??•
```
[Try it Online!](https://vyxal.pythonanywhere.com/#WyLhuaEiLCIiLCLigKI/P+KAoiIsIiIsIkNvZGVHb2xmXG54eFBQQ0d4eCJd)
Explanation:
```
•    # A with the capitalization of B
 ??  # Get both input strings (order ends up reversed)
   • # A with the capitalization of B
     # "ṡ" flag - Print entire stack, separated by spaces
```
[Answer]
# [Python 3](https://docs.python.org/3/), 83 bytes
```
lambda a,b:(g(a,b),g(b,a))
g=lambda*a:[chr(ord(x)&95|(y>'Z')<<5)for x,y in zip(*a)]
```
[Try it online!](https://tio.run/##Lc9NC4JAEAbgc/6KPTUzsbfwkGRQJp4CCYLo47C2rgrmyiK0Rv/d3Ow0M88Lw0zbd6VuloMKb0MtnpkUTPAswALHQrzAjAsirwincCGC66M0qI1ES/OV/8F@Axeg9donpQ2zvGdVw95ViwtB98HZuMnZFSHSMk90rYAzsDZNo8RaIM4Qav3KjeNTmsbHyQ7VOd87m8Kfbd28/fe7h3RjrJIS6B54s9ZUTecu5xBugKvfEzR8AQ "Python 3 – Try It Online")
-3 bytes thanks to Mr. Xcoder  
-3 bytes thanks to Chas Brown
[Answer]
# [Haskell](https://www.haskell.org/), 78 bytes
```
c!d=([c..'z']++[';'..])!!sum[32|(c>'Z')/=(d>'Z')]
(#)=zipWith(!)
s%t=(s#t,t#s)
```
[Try it online!](https://tio.run/##XcpPC4IwGMfxu69izmQbhkEdY4GZeAokiCLxINvEkf9wi0R67xbrpM/px/P5lrl6iqqaJmZzilPm@2hEmeelaI98PyO2rV51utt@MDugByIbirkZmYUdQkfZ3aQusU0s5WqKlaPX2lFkqnPZAAp4a4Hfdb1sNFgBGLZcxG1VQOACOAxJEsbDAOdN1b5Fb4JrkkSXhZ7lXZyM/ru5BkaC5ffIuIGoiEs4fQE "Haskell – Try It Online")
[Answer]
# QBasic, 133 bytes
```
INPUT a$,b$
FOR i=1TO LEN(a$)
c=ASC(MID$(a$,i,1))
d=ASC(MID$(b$,i,1))
s=32AND(c XOR d)
?CHR$(c XOR s);
r$=r$+CHR$(d XOR s)
NEXT
?
?r$
```
Takes the two strings comma-separated and outputs the results newline-separated. Uses the bit-fiddling algorithm from [Dennis's Jelly answer](https://codegolf.stackexchange.com/a/166021/16766). Other than that, the main golf trick here is that the first result string is printed directly, one character at a time, which is a little shorter than saving both result strings in variables and printing them outside the loop.
[Answer]
# JavaScript, ~~77~~ ~~74~~ 73 bytes
```
W=>W.map((w,x)=>w.map((c,i)=>W[+!x][i][`to${c>{}?'Low':'Upp'}erCase`]()))
```
```
f=
W=>W.map((w,x)=>w.map((c,i)=>W[+!x][i][`to${c>{}?'Low':'Upp'}erCase`]()))
console.log(
    f([[...'CodeGolf'],[...'xxPPCGxx']])
)
```
Takes an array of char arrays, outputs an array of char arrays.
-1 byte ([@Arnauld](https://codegolf.stackexchange.com/questions/166012/exchange-capitalization/166028?noredirect=1#comment401609_166028)): `c>'Z'` → `c>{}`
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 13 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
=Œu=/ị"Ɱż"Œs$
```
**[Try it online!](https://tio.run/##ATUAyv9qZWxsef//PcWSdT0v4buLIuKxrsW8IsWScyT/4bu0w4dZ//9Db2RlR29sZgp4eFBQQ0d4eA "Jelly – Try It Online")**
Also 13: [`=ŒuṚ×32ạŒlO$Ọ`](https://tio.run/##ATcAyP9qZWxsef//PcWSdeG5msOXMzLhuqHFkmxPJOG7jP/hu7TDh1n//0NvZGVHb2xmCnh4UFBDR3h4 "Jelly – Try It Online") (or `=ŒuṚæ«5ạŒlO$Ọ`)
[Answer]
# [Retina](https://github.com/m-ender/retina/wiki/The-Language), 75 bytes
```
^
¶
+`¶(([A-Z])|(.))(.*)¶(([A-Z])|(.))
$#6*$u$1$#7*$l$1¶$4$#2*$u$5$#3*$l$5¶
```
[Try it online!](https://tio.run/##K0otycxLNPz/P47r0DYu7YRD2zQ0oh11o2I1azT0NDU19LQ00YS4VJTNtFRKVQxVlM21VHJUDA9tUzFRUTYCiZmqKBuDxEwPbfv/3zk/JdU9PyeNq6IiIMDZvaICAA "Retina – Try It Online") Explanation: The newlines are used as markers to determine how much of the string has been processed. The regex tries to match against uppercase letters or failing that any characters. If an uppercase letter was matched then the other character is uppercased otherwise it is lowercased and vice versa, while the newlines are advanced to the next character.
[Answer]
# [Python 3](https://docs.python.org/3/), ~~76~~ 75 bytes
```
lambda a,b:''.join(chr(ord(x)&95|ord(y)&32)for x,y in zip(a+' '+b,b+'a'+a))
```
[Try it online!](https://tio.run/##LY5BC4IwFMfP9Sl28m04OiQdEgzMxFMwgiCoDps6XNgmQ2hG391cdvv9f@/Pe68b@sboaJTJbWz5U1QccSpigNXDKI3LxmJjK@xIsN18PA0kiNZEGoscHZDS6K06zENAEAoqQuAQckJGX5gW@cIVQ2aqujCtBIrAOcaywjkgFGFozau2Xp8Zy0@zO6pLffBuHv5c6nP6531Z@ZjLogFyj5eLzird4@kehWQHVHqcnvgC "Python 3 – Try It Online")
Outputs the result as one string with a single-character separator.
Thx to [Jonathon Allan](https://codegolf.stackexchange.com/users/53748/jonathan-allan) for 1 byte.
[Answer]
# [Crystal](https://crystal-lang.org), 108 bytes
```
def f(a,b)r=s=""
a.zip(b){|x,y|r+="`"<x<"{"?y.downcase: y.upcase
s+="`"<y<"{"?x.downcase: x.upcase}
{s,r}end
```
[Try it online!](https://tio.run/##TY9dC4IwGIXv/RUvg2CjsR8QSZSJV4EEQRBBy00SJGVTfJf6282@uzvnOc/NSYyzlcyHQekUUir5mRnf@oR4Utyykp5Z2yF3nZn65ETmOCctWTihiuaaSKtn4ERdPpJnX4Z7Gvhn4NvovdZy0@urGg4ewKShQaF0VOQpIMZxECEy/hryotEGdnEcbj9ok@31Gp7DBy1h@Y2rREGYRpcRHIWWyQVa6ChycKyDsq7seA6FLfOsooSwkf8Kg364Aw "Crystal – Try It Online")
### How it works?
```
def f(a, b)                       # Strings as list of characters
r = s = ""                        # Strings buffers initialization
a.zip(b) do |x, y|                # Join two arrays to paired tuples and iterate
r+="`"<x<"{"?y.downcase: y.upcase # Check if character is downcase using triple
s+="`"<y<"{"?x.downcase: x.upcase # comparison and ascii table. Then apply it to
end                               # the other character using String methods
{s, r}                            # Return two new strings using a tuple
end                               # PS: Tuples are inmutable structures in Crystal
```
[Answer]
# [Assembly (nasm, x64, Linux)](http://www.nasm.us/), 25 bytes (123 bytes source)
[Hex bytes:](https://defuse.ca/online-x86-assembler.htm)
```
0x88, 0xE6, 0x30, 0xC6, 0x80, 0xE6, 0x20, 0x88
0xF2, 0x66, 0x31, 0xD0, 0x88, 0x26, 0xAA, 0xAC
0x8A, 0x26, 0x8A, 0x07, 0x08, 0xE4, 0x75, 0xE8, 0xC3
```
The function entry point is at `a`, with the strings passed in using `RDI` and `RSI`.
```
b:MOV DH,AH
XOR DH,AL
AND DH,32
MOV DL,DH
XOR AX,DX
MOV [RSI],AH
STOSB
LODSB
a:MOV AH,[RSI]
MOV AL,[RDI]
OR AH,AH
JNZ b
RET
```
[Try it online!](https://tio.run/##dU5PT8MgFL@/T8FdNLaaHXqjsLRdWKnQad3SGJrV07Ymtgf89Ah0VhPjAXjv9xc9jv25O33eXvR4tmpN60KU6G7qzQQZFynhCL2Nk/6YAOY3Abqt0NOLkAwdpKpaHMOGo@Nw6QG24hlJVWBP3ESrdgbYFYgfW6CEc6SvStLgaJFE/7mbH7fapQFwKlCvyof9iVK/2haN/16yKFf30AgZWt35Vtku8QKWY5IH3k8cSMn89BAHO@OYzazLYU3AXF3RepOqhUqBC@ZuHcJIjgMbdIS7hbnFu0PLptyjDuS6ttbS4dhnw@ndGlNVNDPmCw "Assembly (nasm, x64, Linux) – Try It Online")
[Answer]
# TI-Basic, 225 bytes
```
Prompt Str1,Str2
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ→Str3
"seq(inString(Str3,sub(Ans,I,1),I,1,length(Ans→u
Str1
u→F
Str2
augment(u,ʟF→S
augment(ʟF,Ans→F
".
For(I,1,dim(ʟS
Ans+sub(Str3,remainder(ʟF(I)-1,26)+1+26(ʟS(I)>26),1
End
Disp sub(Ans,2,length(Str1
sub(Ans,2+length(Str2),length(Str2
```
-1 byte if the `i` is replaced with the imaginary number `i`.  
+3 bytes by replacing `remainder(ʟF(I)-1,26)` with `26fPart((ʟF(I)-1)/26)` if the calculator does not support `remainder(`.
Outputs are displayed, separated by a newline.
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 17 bytes
```
Ｅθ⭆ι⎇№α§§θ¬κμ↥λ↧λ
```
[Try it online!](https://tio.run/##S85ILErOT8z5/z@gKDOvRMM3sUCjUEchuATISwdxMnUUQlKL8hKLKjWc80uBKhJ1FBxLPPNSUis0YDRQg19@iUa2pqaOQi6ICC0oSC1KTixO1cgB8nzyy@E8ELD@/z86Wsk5PyXVPT8nTUlHqaIiIMDZvaJCKTb2v25ZDgA "Charcoal – Try It Online") Link is to verbose version of code. Takes input as an array of two strings. Explanation:
```
 θ                  Input array
Ｅ                   Map over strings
   ι                Current string
  ⭆                 Map over characters
         θ          Input array
           κ        Outer loop index
          ¬         Logical Not
        §           Index into array
            μ       Inner loop index
       §            Index into array
      α             Uppercase characters
     №              Count number of matches
              λ λ   Current character
             ↥      Uppercase
               ↧    Lowercase
    ⎇               Ternary
                    Implicitly print
```
[Answer]
## F#, 120 bytes
Bugger.
```
open System
let g=Seq.fold2(fun a x y->a+string(x|>if y>'Z'then Char.ToLower else Char.ToUpper))""
let b f s=g f s,g s f
```
[Try it online!](https://tio.run/##NU5Na8JAFLznVwwLYkKrFM8m0BbppYeC9qJ4iOa9TSDubve9VAP972kUchmYYb5YFmcfaRh8IIdtL0qXpCWFzbf0s2TfVquUO4cSN/SLonwSjY2z6e2vaBh9Md/PtR6j73UZlzv/6a8UQa3QpHyHQDHLjHnUnsCQ3N7x2ULAw2G9cRr7L984LY4P06VsxsFof5EnuAu@09Ap8jFuXt/OlYHZ8EdtEoTxjLKDmQlmYpCyTPYMqbhqIglehn8)
The function `g` takes the two strings as parameters. `Seq.fold2` applies a function with an accumulator (`a`) to each element (`x` and `y`) in the strings. Initially `a` is an empty string, and it adds the converted character to it in each iteration.
`b` is the main function. It first converts `f` with respect to `s`, and then converts `s` with respect to `f`. It then returns a tuple with both values.
[Answer]
# [Prolog (SWI)](http://www.swi-prolog.org), 121 bytes
```
[H|T]-[I|U]-[J|V]-[K|W]:-((H>96,I>96;H<92,I<92),J=H,K=I;H>96,J is H-32,K is I+32;J is H+32,K is I-32),T-U-V-W.
_-_-[]-[].
```
[Try it online!](https://tio.run/##Xc1da4MwFMbx@36KUChEeo4XFgat64YvxTcGsmo7cKLQaheQZmghXvjd3dkKbuzmIfn9A/lsZSMv2Ckxjpk/JDlmwZDShsOBNhqO@QY595/WDxDQmP7j2oCARoNw60O0DcyfGDLRMR9XBkTfp2C5Msy7LSejqkGCKR7wqM8KLDCjP3J9VHwPibbBPSZooQ2su7XieilO8lx13AFL@0cu2ESqFbeq5vOFYgv1fp1D5oCba/rsGZnipUNPPdnUJZR9H8eO1/flFBupqpZKGse7119@EW@VS3zPE1tE1p@rfTqT7Grvg3D8Ag "Prolog (SWI) – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), ~~74~~ 69 bytes
```
->a,b{a.zip(b).map{|x|x.one?{|y|y>?_}?x.map(&:swapcase):x}.transpose}
```
[Try it online!](https://tio.run/##LY/RaoMwGEbv@xQhg1GH8wEKqzibedNREUYLIiPGpDqsCYmlvzM@u4tdL79zzs2nr@Uwi7f5dUv9cqTBb6PWpRdcqBotWAhkx8PRDnbYht9TCItYP2/MjSpGDfc2MAW9pp1R0vBpznMcy4onshXYxwBpGicAuPDRE5M7khxagU6gVHwGWOW4lTeuXfiVpiS7V/vDkWToqhTXzn82J75z/r9b/KUBXqG9PPLM@ci56M4jFC37nVUOEZHUuHCwjCtEPs71qgg4ZfVoe6uQyF/6xw1WU2284rF@ZNN50/wH "Ruby – Try It Online")
Input and output are arrays of chars, so the footer does back and forth transformations from strings.
I'm not yet sure whether this is a good approach to the problem, but this challenge definitely looks like a nice use scenario for `swapcase` method.
[Answer]
## [PHP 4.1.2](https://secure.php.net/releases/#4.1.2), 40 bytes
Replace the pair of quotation marks with byte A0 (in ISO-8859-1 or Windows-1252, this is NBSP) to get the byte count shown, then run from a web browser (or from the command line), providing the strings as the query string arguments (or environment variables) `a` and `b`.
```
<?=$a^$c=($a^$b)&str_pad("",2e5),_,$b^$c;
```
In this version of PHP, [register\_globals](https://secure.php.net/manual/en/security.globals.php) is on by default, so the strings will automatically be assigned to the variables `$a` and `$b`. Increase the value `2e5` (200000) if necessary.
## PHP 7.1+, 58 bytes
Run on the command line, using `php -r 'code here' string1 string2`:
```
[,$a,$b]=$argv;echo("$b $a"^$a.=" $b")&str_pad("",3e5)^$a;
```
The value `3e5` (300000) is chosen to exceed (MAX\_ARG\_STRLEN \* 2 + 1) on most Linux systems (specifically, x86 and other architectures for which PAGE\_SIZE is 4096, and MAX\_ARG\_STRLEN is thus 131072), to avoid problems with any possible input string. Increase if necessary.
[Try it online!](https://tio.run/##DcnNCkBAEADgV9E0iVoucpKTg@vehWZZPyWzLWmf3vBdP7c5@b3s7p3PSzIvnUJSaPoaya9PZaeNE0ATIcGAlNcQoYE0vm4/OpoTAFXYMv2rkoZn2/KxSAhaN20IHw "PHP – Try It Online")
[Answer]
# [Stax](https://github.com/tomtheisen/stax), 10 [bytes](https://github.com/tomtheisen/stax/blob/master/docs/packed.md#packed-stax)
```
▌Ö↑o╓→ì]yç
```
[Run and debug it](https://staxlang.xyz/#p=dd99186fd61a8d5d7987&i=[%22CodeGolf%22+%22xxPPCGxx%22]%0A[%22lower%22+%22UPPER%22]%0A[%22MiXeD%22+%22lower%22]%0A[%22A%22+%22A%22]%0A[%22ABcd%22+%22EfGh%22]&a=1&m=2)
Here's an ungolfed representation of the same program to show how it works.
```
        Example
        ["Ab", "cd"]                    
:)      [["Ab", "cd"], ["cd", "Ab"]]    Get all rotations of input
m       ["cd", "Ab"]                    For each, run the rest of program; print result
  M     ["cA", "db"]                    Transpose matrix
  {     "cA"                            Begin block for mapping to result
    B   "A" 99                          "Pop" first element from string array; leave the rest
    96> "A" 1                           Is the character code > 96?
    :c  "a"                             Set case of string; 0 -> upper,  1 -> lower
  m     "ab"                            Perform the map using the block
```
[Run this one](https://staxlang.xyz/#c=+++++++%09Example%0A+++++++%09[%22Ab%22,+%22cd%22]++++++++++++++++%09%0A%3A%29+++++%09[[%22Ab%22,+%22cd%22],+[%22cd%22,+%22Ab%22]]%09Get+all+rotations+of+input%0Am++++++%09[%22cd%22,+%22Ab%22]++++++++++++++++%09For+each,+run+the+rest+of+program%3B+print+result%0A++M++++%09[%22cA%22,+%22db%22]++++++++++++++++%09Transpose+matrix%0A++%7B++++%09%22cA%22++++++++++++++++++++++++%09Begin+block+for+mapping+to+result%0A++++B++%09%22A%22+99++++++++++++++++++++++%09%22Pop%22+first+element+from+string+array%3B+leave+the+rest%0A++++96%3E%09%22A%22+1+++++++++++++++++++++++%09Is+the+character+code+%3E+96%3F%0A++++%3Ac+%09%22a%22+++++++++++++++++++++++++%09Set+case+of+string%3B+0+-%3E+upper,++1+-%3E+lower%0A++m++++%09%22ab%22++++++++++++++++++++++++%09Perform+the+map+using+the+block&i=[%22Ab%22+%22cd%22]&a=1&m=2)
]