[Question]
  [
Let's start by re-defining a **reflection** of a character in a 2-d array of characters:
> 
> Given a square 2-d array of characters with distinct lowercase alphabetical letters, define a reflection of a letter in the matrix as swapping it with the character directly across from it through the center of the square.
> 
> 
> 
Thus, a reflection of the letter `c` in 
```
abcde
fghij
klmno
pqrst
uvwxy
```
would result in the configuration
```
abwde
fghij
klmno
pqrst
uvcxy
```
because the `c` and the `w` have been switched.
Some more examples (with the same original configuration as above):
> 
> Reflecting the character `e` would form 
> 
> 
> 
```
 abcdu
 fghij
 klmno
 pqrst
 evwxy
```
> 
> Reflecting the character `m` would make 
> 
> 
> 
```
 abcde
 fghij
 klmno
 pqrst
 uvwxy
```
> 
> Reflecting the character `b` would form 
> 
> 
> 
```
 axcde
 fghij
 klmno
 pqrst
 uvwby
```
## The Challenge
Given a 2-d array of characters with distinct lowercase letters, go through each character in a given string and "reflect" it in the matrix.
*Clarifications: The letters in the string are from `a-z`, the letters are unique, and the array is at least 1x1 and at most 5x5 (obviously, as there are only 26 characters in the English alphabet.)* The characters in the string are guaranteed to be in the 2-d array. The string is at most 100 characters long.
## Input
An string `s`, an integer `N`, and then a `NxN` array of characters.
## Example
Input: 
```
ac
2
ab
cd
```
Output:
```
dc
ba
```
\*Reason: First, reflect the `a` with the `d`. Then, reflect the `c` with the `b` because `c` is the second letter in the input string.
---
## Scoring
* Output can be given by [any convenient method](http://meta.codegolf.stackexchange.com/q/2447/42963).
* Either a full program or a function are acceptable. If a function, you can return the output rather than printing it.
* [Standard loopholes](http://meta.codegolf.stackexchange.com/q/1061/42963) are forbidden.
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so all usual golfing rules apply, and the shortest code (in bytes) wins.
## Current Winner
```
<style>body { text-align: left !important} #answer-list { padding: 10px; width: 290px; float: left; } #language-list { padding: 10px; width: 290px; float: left; } table thead { font-weight: bold; } table td { padding: 5px; }</style><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="language-list"> <h2>Shortest Solution by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr> </thead> <tbody id="languages"> </tbody> </table> </div> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr> </thead> <tbody id="answers"> </tbody> </table> </div> <table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr> </tbody> </table><script>var QUESTION_ID = 163084; var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe"; var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk"; var OVERRIDE_USER = 12012; var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page; function answersUrl(index) { return "https://api.stackexchange.com/2.2/questions/" + QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER; } function commentUrl(index, answers) { return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER; } function getAnswers() { jQuery.ajax({ url: answersUrl(answer_page++), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { answers.push.apply(answers, data.items); answers_hash = []; answer_ids = []; data.items.forEach(function(a) { a.comments = []; var id = +a.share_link.match(/\d+/); answer_ids.push(id); answers_hash[id] = a; }); if (!data.has_more) more_answers = false; comment_page = 1; getComments(); } }); } function getComments() { jQuery.ajax({ url: commentUrl(comment_page++, answer_ids), method: "get", dataType: "jsonp", crossDomain: true, success: function (data) { data.items.forEach(function(c) { if (c.owner.user_id === OVERRIDE_USER) answers_hash[c.post_id].comments.push(c); }); if (data.has_more) getComments(); else if (more_answers) getAnswers(); else process(); } }); } getAnswers(); var SCORE_REG = /<h\d>\s*([^\n,<]*(?:<(?:[^\n>]*>[^\n<]*<\/[^\n>]*>)[^\n,<]*)*),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/; var OVERRIDE_REG = /^Override\s*header:\s*/i; function getAuthorName(a) { return a.owner.display_name; } function process() { var valid = []; answers.forEach(function(a) { var body = a.body; a.comments.forEach(function(c) { if(OVERRIDE_REG.test(c.body)) body = '<h1>' + c.body.replace(OVERRIDE_REG, '') + '</h1>'; }); var match = body.match(SCORE_REG); if (match) valid.push({ user: getAuthorName(a), size: +match[2], language: match[1], link: a.share_link, }); else console.log(body); }); valid.sort(function (a, b) { var aB = a.size, bB = b.size; return aB - bB }); var languages = {}; var place = 1; var lastSize = null; var lastPlace = 1; valid.forEach(function (a) { if (a.size != lastSize) lastPlace = place; lastSize = a.size; ++place; var answer = jQuery("#answer-template").html(); answer = answer.replace("{{PLACE}}", lastPlace + ".") .replace("{{NAME}}", a.user) .replace("{{LANGUAGE}}", a.language) .replace("{{SIZE}}", a.size) .replace("{{LINK}}", a.link); answer = jQuery(answer); jQuery("#answers").append(answer); var lang = a.language; lang = jQuery('<a>'+lang+'</a>').text(); languages[lang] = languages[lang] || {lang: a.language, lang_raw: lang.toLowerCase(), user: a.user, size: a.size, link: a.link}; }); var langs = []; for (var lang in languages) if (languages.hasOwnProperty(lang)) langs.push(languages[lang]); langs.sort(function (a, b) { if (a.lang_raw > b.lang_raw) return 1; if (a.lang_raw < b.lang_raw) return -1; return 0; }); for (var i = 0; i < langs.length; ++i) { var language = jQuery("#language-template").html(); var lang = langs[i]; language = language.replace("{{LANGUAGE}}", lang.lang) .replace("{{NAME}}", lang.user) .replace("{{SIZE}}", lang.size) .replace("{{LINK}}", lang.link); language = jQuery(language); jQuery("#languages").append(language); } }</script>
```
  
[Answer]
# [Python 2](https://docs.python.org/2/), 76 bytes
```
lambda s,a:[a[[i,~i][(s.count(c)+s.count(a[~i]))%2]]for i,c in enumerate(a)]
```
[Try it online!](https://tio.run/##PYk7DgIhFAD7PQWNASKx2NLEkyDFgwUXXR7IR93Gq6MmaqaZzKS1zhHH7g7HvkDQE5AiYC9BSi@eXklWdiY2rMzw7U9Bvg/nm1EpFzPxwhCPxGILNkO1DLjqKXusxDEK5gMVFLSZKB@G/zE26G@37jT782UJGNM1l9pu98dKeX8B "Python 2 – Try It Online")
Takes input:
* `s`: string
* `N`: ignored
* `a`: joined string of chars
Returns a flat list of chars
---
If I *have* to take the array as a list:
# [Python 2](https://docs.python.org/2/), ~~111~~ ~~108~~ ~~107~~ 104 bytes
```
lambda s,n,a:[[x[sum(map(s.count,x))%2]for i in range(n)for x in[[a[j][i],a[~j][~i]]]]for j in range(n)]
```
[Try it online!](https://tio.run/##Tc7LCsIwEAXQvV@RjUwLg4uCG8EvGbOYvjTVpLUPrRt/veZSERM4XGZuIN1rvLQhW@rjabmpz0s1AwfWg8gsw@QTr10y7Ip2CiPPabrNbN32xhkXTK/hXCUhxWCOAxGVxoqzrPKO4e1sPNg2/3W7dL0Lo6kT0gKXOGMRUmLKybJQnFBJ1qabza9aVD4n3n@LJjYjBShBFR8aoRr5DC7AgWZdXZFvwIMA2nXVId9BDwYwrqsJ@QGeYAYvfG35AA "Python 2 – Try It Online")
Takes input:
* `s`: string
* `n`: int
* `a`: 2D lists of chars
Returns a 2D list of chars
[Answer]
# [Octave](https://www.gnu.org/software/octave/), ~~85~~ ~~68~~ 66 bytes
Using `eval`, with a loop inside it saved a lot of bytes! I got the inspiration from [this answer](https://codegolf.stackexchange.com/a/163111/31516) by [Luis Mendo](https://codegolf.stackexchange.com/users/36398/luis-mendo)!
```
@(c,N,A)eval"for C=c,A(flip(k))=A(k=[x=find(A==C),N^2+1-x]);end,A"
```
[Try it online!](https://tio.run/##DcXdCsIgGADQV4ndqPQlFHQ1Pkh2vxcYC8yfMp2utZY9vXluTlKr3EyxyDkvF6qgB8HMJkNj07LrUIGgNriZesZQUI9DRuuipgKxY9BfT/vjIY@sNVGDaIqlRGoCZxiIvCltSEvs/eGedR@mmOrza3mv9c/2zT8ysvIH "Octave – Try It Online")
### Explanation:
```
f=@(c,N,A)          % Anonymous function that takes the three input variables
eval"...          % Evaluate the string and run it:
 for C=c,          % Loop over the character list 'c'
  .. x=find(A==C)   % Find the index where the character C is in A, and store it as 'x'
  .. k=[x,N^2+1-x]  % Create a vector with the index of C, and the index of its reflection
   A(flip(k))=A(k)  % Swap the elements in these positions
  end               % End loop
  A"                % Display the new 'A'
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~15~~ 14 bytes
```
FW;Ṛi,C$¥¦/ṁḷY
```
[Try it online!](https://tio.run/##AS8A0P9qZWxsef//Rlc74bmaaSxDJMKlwqYv4bmB4bi3Wf///1snYWInCiwnY2QnXf9hYw "Jelly – Try It Online")
Full program.
Explanation:
```
FW;Ṛi,C$¥¦/ṁḷY       Main link. Input: ['ab','cd'] (left), 'ac' (right).
FW                   **F**latten and **W**rap it in a list. Current value = ['abcd'].
  ;                  Concatenate it with right argument. ['abcd','a','c']
          /          Reduce from left:
   Ṛ     ¦             Apply **Ṛ**everse at...
    i   ¥              the index (of right argument in left argument)...
     ,C$               and its complement index.
```
The last operation needs more explanation. Denote f = `Ṛi,C$¥¦`, then for value `['abcd','a','c']` it computes `('abcd' f 'a') f 'c'`, which expands to:
```
Ṛi,C$¥¦    Function **f**. Assume left argument = 'abcd' and right argument = 'a'
Ṛ          First, compute the reverse. Get 'dcba'.
 i   ¥     To compute the indices to apply to, first the index of 'a' in 'abcd'
             is ('abcd' i 'a') = 1. (first index)
  ,C$      Then pair with (1 C) = 0. (last index)
      ¦    Apply 'dcba' to 'abcd' at indices 0 and 1:
              a**bc**d
              **d**cb**a**
              ^1 ^0
              ====
              dbca
```
[Answer]
# [R](https://www.r-project.org/), ~~74~~ 61 bytes
-13 bytes thanks to Giuseppe.
```
function(s,n,m){for(x in s)m[v]=rev(m[v<-(i=x==m)|rev(i)]);m}
```
[Try it online!](https://tio.run/##FY69UsMwEAZ7PUVG1d3MR7pU5FqegI5JISsSFlhycpJ/MsCzG6fb2W1WtyhbnIpvaSxUUZD5J45K6yGVQ@X8MV9Ew0w7nF8oySqS@fdpEl/4Nf9tkaYypNqoNq23ITWyPuTOwlpmnODqMbumaSUN7nr0daYm1btCS@@aWHWLZfR7CypvjO6h4yLvzMahg8cVwUR8okfCl/nGgLxvjuaGOxQVzUyYsWDFw2z/ "R – Try It Online")
Inputs a vector of characters to search as `s`, size of the matrix as `n` and matrix itself as `m`. If it is absolutely necessary to take the first argument as *string*, that would pretty much spoil the fun.
[Answer]
# Java 10, ~~126~~ ~~123~~ ~~116~~ 114 bytes
```
(s,n,m)->{for(var c:s)for(int N=n*n,i,j;N-->0;)if(m[i=N/n][j=N%n]==c){m[i][j]=m[n+~i][n+~j];m[n+~i][n+~j]=c;N=0;}}
```
Modifies the input character-matrix instead of returning a new one to save bytes.
[Try it online.](https://tio.run/##fVPLbsIwELz3K1aRqtjFpJyJjFT13KgSR5SDMQYcYie1HShC6a9T59EKKKmURN4de3ZmvcnYno2z1e7Mc2YtvDGpTw8AUjth1owLSJoQYF/IFXDEt8wsUrCk2QGaQJfwKYVjv7H2r3@sY05ySEADhTOyRBOFx7PTujBozwzwqcXNuiFJqH7SRJIsTsbj2STGco3UQtLkWaeLjCaPOqWU45PP@TilaqFHX37pv1kaX0WUxwmdxHV9jjsdZbXMvY5eTutBeYdo7ozUG6@a4c6eE9ahgC0DAlocfl11IFzkTiELSbgMa3IH4h5ahXWL1G0/fpi5UEPcvipfiSByxatHXoxhR4R/2IP1ZiuzIXCXK10MgeWHsW4IrPaHz@MNeCH7@hrbvrU@ur41139x750RHXFkb6qBinKhN25L@vEAmB@tEyoqKheVnsvlGtlRMA16uDTCueN7g6B/jgyJvDz@R2EzcP38sqnCfSvusGf@n4gqJ/OoNdK46owjhvvK9fkb)
**Explanation:**
```
(s,n,m)->{     // Method with the three parameters and no return-type
  for(var c:s) //  Loop over the characters given:
    for(int N=n*n,i,j;N-->0;)
               //   Inner loop over the cells of the matrix:
      if(m[i=N/n][j=N%n]==c){
               //    If the current character and matrix-value are equals:
        m[i][j]=m[n+~i][n+~j];m[n+~i][n+~j]=c;
               //     Swap the values in the matrix at indices [i, j] and [n-i-1, n-j-1]
        N=0;}} //     And stop the inner loop (go to next iteration of the outer loop)
```
[Answer]
# [Java (JDK)](http://jdk.java.net/), ~~95~~ 93 bytes
```
(x,s,N)->{for(var c:s)for(int i=-1;++i<N;){var t=x[i];if(t==c){x[i]=x[N+~i];x[N+~i]=t;i=N;}}}
```
[Try it online!](https://tio.run/##dVJdb5swFH02v@KqUiUohLbr2yjTqk2T9jBWrY9RHlxjiBkxmW2yRhH96/TahqTqOgnJ5vqc@3HObeiOLpry97jtH1vBgLVUa/hBhQwOAfn8rZfMiE7S9rs0XFWU8YBMUG2owUPMD/CLVy1nJiDIJLtOlKB8JGRrqpYroAlMN51YHhRRFpAhIG9zOvIGmwgfjBKytlxV68intkwJOdiWaq7SHW17/rMKLWR5tbI5HaYUG0RJuABpQ3MTSmHUYa9Xqem@YPhOKboPHRG/y0u4x6oGC1s03WNsawMIwyIqAfkK@pVXQh6h88ioGXRbrqjpFOImaQBLj@FTopMiWnw6VJ0Kd1QB@6gje7dNi3xxncWxuC2y6GAfTf60FKtMVKHJcxYd7B@GivgZo9OZm0zkRTYMw0jIqbWp6qk53vINl0YDlSVs5xkV132LthGVzoa5KZ1GH95olFhZ3fjvSOKsnOXToP/0VPFZw3csPqY4eeMXQ05Wv7ZC8r9HO1At8HKhl1cZHrdoMog4RqJjniCNhzQe0niIx5CHvTZ8k3a9SV0vVXh2zuDMzq6WdnMExND4lbLTOWX/YbXS787glf/P8xAM43gz0kdW8qpei5Gymq9fAA "Java (JDK) – Try It Online")
# [Java (JDK)](http://jdk.java.net/), 131 bytes
```
(x,s,n)->{for(var c:s)for(int i=~0;++i<n*n;){int a=i/n,b=i%n;var t=x[a][b];if(t==c){x[a][b]=x[n+~a][n+~b];x[n+~a][n+~b]=t;break;}}}
```
# [Java (JDK)](http://jdk.java.net/), ~~138~~ 135 bytes
```
(x,s,n)->s.forEach(c->{for(int i=~0,a=i/n,b=i%n;++i<n*n;){var t=x[a][b];if(t==(char)c){x[a][b]=x[n+~a][n+~b];x[n+~a][n+~b]=t;break;}}})
```
# [Java (JDK)](http://jdk.java.net/), 112 bytes
```
(x,s,N)->{for(var c:s)for(var v:x.entrySet())if(v.getValue()==N-x.get(c))x.put(v.getKey(),x.put(c,N-x.get(c)));}
```
[Try it online!](https://tio.run/##jVTBbtswDD3LX0H0JK@O216bplixYVuxtRtWYJcgB8VWErm25EmKm6zIt2eUZMduu27zIbYo8vGRfEzBGjYq8vu9qGqlLRR4TtdWlOkXIe95/omZ1Q2rx1FUr@elyCArmTFww4SMHiNycgJXWrMtaL4oeWaFkiCk5XrBMh6Rtx/W0htZed1bWyRjmcXXwR2@B4yIIDBplMg7VPqEy8XXeYHGBBzkkutLYAkE23QGJnGIcBuPI7KLiKf4XouGa8hU/iK7T1NhNfTOaiGXiMD00sSBBMZ@5NaiHa2uzIVWFeLXa2RJXJ5cVDDxIdPTWVpyubQr6nKTf3CuWI2Bkj/AU8fLEB2So6F2yRtWrrlB20JpoC6vwODTMb4uHAX8OD5GzoQgbIrsaMcoWzF9ZamIsS0d8KFX7tK0LFqjjzvrK5n1ZN6peuvIuCiW4dAMWAVz3k2J567zCpg8TOMVxs@T9PQ9o6mYdT09G1TQM7mWwgpWil/9YAb6UzXXzCqNvq2iQMNkTzeJSW7j0eUjUqINQz2cm7j7bs43KZdWb@@4pXEsFrRJl9z@cI2n8WRyO9q4M83ieOMb7K8/8y2Nk2DIkoFPPN7tCXnZOxzPf0nD@f9NHq2LS3xVlhSPg/a0VffN4SWvsDgnIJ12O9VCJEEFiVfyCM5eiAQhkEmXMCiRxqlVfvHpQDuIMHPhgI9fDomBbvYxCtmuUvNTW4pOA6rfcOc8UQfjVoKZwPkV5ciDVNx6PkFodaAeXJl9cBGCixBctDoL927wHM5d4uHwvQMJv8MMmdKam1rJ/LCTqPh2pviIBVA@UA1MnIr1VMIbJH8MxayFJndbY3mVqrVNa4cewrya0O8IjnyLyPMSsTiYa87uoz9glDJIY@f@93b7PZtnOV8sV2LPsiVf/QY "Java (JDK) – Try It Online")
# [Java (JDK)](http://jdk.java.net/), 70 bytes
```
(x,X,s,N)->{for(var c:s)x.put(X.get(N-x.get(c)),x.put(c,N-x.get(c)));}
```
[Try it online!](https://tio.run/##hVNNbxoxED17f8UoJ29jNsm1JKhVqrZRm7RqpCpSxMEsBrxZ7K1tCGnEb6fjj2WhIS0H7B3PPL95flPxJe9V44eNnDfaOKjwu1g4WRdfpXoQ48/czq5508@yZjGqZQllza2Fay5V9pyRkxN4bwx/AiMmtSid1AqkcsJMeCky8u7jQoUgr6@6aEKyjjtctunwI2JkBIHJUstxi0r3uJx/G1UYZOAhp8IMYMVgPyOdMIipA7hrt/dDsMzfCTd5PyPrjIQmPhi5FAZKPX7BLxCZY7/01hmppojAzdTmkSbWfhLOYRyjXoiJ0XPEbxbYByln3GC@E/MGZYKLUHl/OiycvsSjIB31PIhnpDCB4iZHed2ssL@Mo6m0qIWaullI/U@rc94gjhKPf2kyoAeqX0hpxPL63wCxaQw0vuklrxfCYmyiTSAPEotP@7icY0NvQOH2@BjVCnIRZFegNlSyVpV7OQy4JF4dTrsjfKtwut7e3MotajEXyllwuvVJp/j2MEl@dkDyrSF8jU0tp2Bbn3Qfdo1fcrt/PbegQ9FrKgT4BLQVIxC12CDmtVD41d1zpaSTvJa/O2vtzJhuhOFOG8xNUwNorw1dsTtm2U3eGzwjFbrk6Om3Nl8FVe@KqXD0prcKa5nnLMZLthPL@@sNIR2PBN@xaNnisSnaAY1vx7z5WGyYxdeHHpzt2OY7TlDA8lp7p6J6AfY1B@27ZxchaaIfPZOuuIrFVSyuktok/O2WY2H3hhIVNWNhQlaA8soJeJvmocAs83SLCuURjsgJUOE1@@kHgOZwcREalnAMVcp5jgu5fbJo6EIvXNH462PhF4E@xOwjOIr@x9/ICP6QPrzjSXaAdUjKDuDWirazss7Wmw0flWMxmc4k7oTkfwA "Java (JDK) – Try It Online")
All of these code snippets function in essentially the same way since only difference between them is the type of the variable x. The first has it set as `char[]`, the second as `char[][]` and the third as `List<Object>`. The fourth and fifth are quite unique solutions, and so I'll go over the specific details of them last. As somewhat of a side note, the first of these three entries inputs the total quantity of elements in the initial array (i.e., `N = n * n`).
Here's how the first three entries work:
```
(array, reflect, size) -> {            // Initializes lambda expression
    for (char c: reflect)              // Loops through soon-to-be reflected characters
        for (int i = 0; i < size; i++) // Loops through elements in array
            if (array[i] == c)         // Checks if this element should be reflected
            {
                var temp = array[i];   // Reflects elements
                array[i] = array[size - 1 - i];
                array[size - 1 - i] = temp;
                break;                 // Goes on to reflect next character
            }
};
```
I feel like these entries can be further golfed with use of nested functions and lambda expressions, but I have been unable to do so thus far. I instead went on to create the fourth entry, as shown below in all of its golfed glory:
```
(x,s,N)->{
    for(var c:s)
        for(var v:x.entrySet())
            if(v.getValue()==N-x.get(c))
                x.put(v.getKey(),x.put(c,N-x.get(c)));
}
```
The fifth is quite similar. These particular lambda expressions are unique, in the sense that `s` is an `Object[]` and N is one less than the total quantity of elements in the initial array. But most importantly, `x` is a `LinkedHashMap<Object, Integer>`. Well, what's so special about all of that? The idea behind changing all of these things was to allow for a short for loop going over the elements of `s`, thus ridding the program of tightly packing for loops with ugly garbage. It essentially simplified things for the code and I. Unfortunately, doing so would mean indexing the initial array to find the index of each element, contradicting its intended purpose.
It was at that moment that I realized that replacing the array input with some `Map` subclass would allow me to use the elements to be reflected as a way to index the elements in the array directly. So I did the only logical solution: map half of the array elements to their corresponding pairs to simplify reflection. Didn't work, big surprise. But I didn't give up and mapped each element to its corresponding array index and the idea was looking good. Next problem: given an element in the array, finding its reflective pair couldn't be done without more for loops, if statements and precious bytes altogether. But a more immediate problem came from this, too: printing the array. In retrospect, it would've been possible to instead input a copy of the array and use the original's elements to get the key-value pairs, but I found a better solution: the `LinkedHashMap`. This class contains the nested class `Entry`, which allows for much simpler key-value pairing, which just so happened to be at the root of both problems.
So now that I've gone over why I made these changes and how the base of this setup should work, I'll use what we've learned to give the code some more context:
```
(x,s,N)->{ // Initializing lambda expression
    for(var c:s) // Looping over elements to be reflected
        for(var v:x.entrySet()) // Looping over key-value pairs...
            if(v.getValue()==N-x.get(c)) // ...until element opposite current is found
                x.put(v.getKey(),x.put(c,N-x.get(c))); // Swapping elements
}
```
You should note that the line involving the actual reflection has a nested `put` method, because it returns the key that was changed, thus removing an extra variable initialization for the swapping process.
But what about my *fifth* entry? Am I taking this simple challenge too seriously? **Yes!** This solution has a very low byte count, because it's the same as the fourth, but with an extra input: `X`. Unlike `x`, which is the array converted to a `LinkedHashMap<Object, Integer>`, `X` is the reverse: a `LinkedHashMap<Integer, Object>`. This allows us to skip searching for any element's index and instead just look it up in `X`, thus removing a lot of code.
As a final side note, the only entries that allow more characters to be reflected than there are in the initial array are the fourth and fifth. Will this be the end?
Thanks to **@KevinCruijssen** for the inspiration and for saving two bytes from my first entry.
[Answer]
# C, ~~84~~ ~~86~~ 83 bytes
+2 bytes to use a temporary variable instead of chained XOR when swapping variables, allowing for the central letter to be swapped with itself
-3 bytes thanks to [ceilingcat](https://codegolf.stackexchange.com/users/52904/ceilingcat).
```
f(s,n,a,i,j,t)char*s,*a,*i;{for(;*s;*i=t)i=index(a,*s++),t=a[j=a-i+n*n-1],a[j]=*i;}
```
[Try it online!](https://tio.run/##TZDdTsMwDIWvm6ewioba1EUMJG668CJbL7L0zxF4qAkIaeqzF6dDiIvIx@eTfay4enRuvSN2b59dD4cQO7o8TK/qvzUTj@KtQxGQ0SKhx1i6yc46oLaoqbkOl7lodGg0mViSIe7670JQqKoSo7FHb2xNFWuu9y1K2xoZW1biCO@WuEjCzqND2BZr0V@luqosAUYgBN@oLEEIx6eXFsGmIl5wloci34UT7zp5IUcICPcyZUvhv3dvUs4kMPDYAMEBWIocCBKzIX9D/oa8IAHZh3xATAEuT6EEGhgq8G3a@EdPnKd@Uct6Hnv1rOzZdf0wTvQD "C (gcc) – Try It Online")
Un-golfed:
```
f(s,n,a,i,j,t)
    char*s,*a,*i;
{
    for(;*s;*i=t) { //Loop while end of s hasn't been reached
        i=index(a,*s++); //i = pointer to char in a with value *s, then get next char s
        t=a[j=a-i+n*n-1]; //j = index of char in a which is opposite i, then swap i and a[j]
        a[j]=*i;
    }
}
```
[Answer]
# [Python 3](https://docs.python.org/3/), ~~122~~ 111 bytes
```
lambda l,n,A:[[[A[a][b],A[~b][~a]][sum(map(l.count,[A[a][b],A[~b][~a]]))%2]for b in range(n)]for a in range(n)]
```
[Try it online!](https://tio.run/##bY69CoMwFEZ3n@IuJQkEh7oVHHyO2ww3ajQlXsUfsIuvnvoDhUK3w/nO8A3vue05iy5/xkCdrQiCZl08ELFAMmiNLnCzBjcyBqelkx0NMqRlv/Cs/zRK3e7G9SNY8AwjcVNLVqehHxNXyAGDn2YpyJZC6Yur2n25ab1QJkmO1O2Z0JBpWFUyjJ73/ckiffWez1Pi4mNXKn4A "Python 3 – Try It Online")
Returns a 2D array of chars.
[Answer]
# [Retina 0.8.2](https://github.com/m-ender/retina/wiki/The-Language/a950ad7d925ec9316e3e2fb2cf5d49fd15d23e3d), 96 bytes
```
+`^(.)(.*¶(.|¶)*)((.)((.|¶)*))?\1(?(4)|(((.|¶)*)(.))?)((?<-3>.|¶)*$(?(3).))
$2$11$9$1$6$5$12
1A`
```
[Try it online!](https://tio.run/##K0otycxL/P9fOyFOQ09TQ0/r0DYNvZpD2zS1NDVAAjCOpn2MoYa9holmjQZcDCivaQ9UYm@ja2wHEVMBqjHWBIpzqRipGBqqWKoYqpipmKoYGnEZOib8/5@amJzBlZiUzJWSmsaVnpEJAA "Retina 0.8.2 – Try It Online") Takes the string `s` and the array of characters as a newline-delimited string without the integer `N`. Explanation: Each character `c` of `s` is processed in turn. The regex matches two positions equidistant from the ends of the array, of which one is `c` and the other is its mirror `m`. These characters are swapped and `c` is removed from `s`.
```
+`
```
Processes each character of `s` in turn.
```
^(.)
```
`$1` captures `c`.
```
(.*¶(.|¶)*)
```
`$3` captures a stack of characters in the array prefixing one of `c` or `m`. `$2` captures the rest of `s` plus all of these characters.
```
((.)((.|¶)*))?
```
If `m` precedes `c`, `$4` has a value, `$5` captures `m` and `$6` captures the characters between `m` and `c`. `$7` captures `$6` as a stack but its value is not used.
```
\1
```
`c` is now matched in the array itself.
```
(?(4)|(((.|¶)*)(.))?)
```
If `m` wasn't already matched, then `$8` optionally captures a value, in which case `$9` captures the characters from `c` to `m`, `$10` captures `$9` as a stack which is unused and `$11` captures `m`. The value is optional in case `c` and `m` are the same character.
```
((?<-3>.|¶)*$(?(3).))
```
`$12` captures the characters suffixing the other of `c` and `m`. A balancing group is used to ensure `$12` is as long as `$3` was deep, i.e. the prefix and suffix are the same length.
```
$2$11$9$1$6$5$12
```
The pieces are then put back together - first the rest of `s` and the prefix of the array, then if `c` preceeded `m` then `m` then the middle, then `c`, then if `m` preceeded `c` then the middle then `m`, then the suffix.
```
1A`
```
Now that `s` is empty it is deleted.
[Answer]
# JavaScript, 85 bytes
Takes string `S` and an array `A` as joined string.
```
([...S],[...A])=>S.map(c=>[A[j],A[i]]=[A[i=A.indexOf(c)],A[j=A.length+~i]])&&A.join``
```
```
f=
([...S],[...A])=>S.map(c=>[A[j],A[i]]=[A[i=A.indexOf(c)],A[j=A.length+~i]])&&A.join``
console.log(
  f('abcd','ac')
)
```
[Answer]
# [Perl 5](https://www.perl.org/) `-lpF`, 97 bytes
```
$i=0|<>;$_=join'',<>;s/\W//g;for$k(@F){/$k/g;$t=substr$_,-pos,1;eval"y/$t$k/$k$t/"}s%.{$i}%$&$/%g
```
[Try it online!](https://tio.run/##DcoxDoIwFADQvccgH9EEKAxMiHFic3YxIaCApZXW/oIQ5OpWxpc8VWuRWAssi77HUwpF1knWe56/AentSmmbNlID35/zw0KBbwaT4VCh0VD4gZLox2k9lsKZKZgtAAdDnRXdcAG2urAD6rbWTowkpKzuj5o07ZN1hItXL4l6azRkGD/T/JPKMNmjDS5JGMWRDYTK/w "Perl 5 – Try It Online")
]