# I'm symmetric, not palindromic!

## Background

Inspired by I'm a palindrome. Are you?, where it is presented the shocking fact that “()() is not a palindrome, but ())(”, I asked myself what instead is ()() and the answer is simply: it is a string with a vertical symmetry axis!

Write a program or function that takes a string S (or the appropriate equivalent in your language) as input, checks for symmetry along the vertical axis, and returns a truthy or falsy value accordingly. You can use any reasonable means to take the input and provide the output.

### Reflectional symmetry

Reflectional symmetry around a vertical axis (or left-right symmetry) means that if you put a mirror vertically at the exact center of the string, the reflected image of the first half of the string is identical to the second half of the string.

For example, the following strings are reflectional symmetric around a vertical axis:

()()
()()()
[A + A]
WOW ! WOW
OH-AH_wx'xw_HA-HO
(<<[[[T*T]]]>>)
(:)
)-(
())(()
qpqp

while the following are not:

())(
((B))
11
+-*+-
WOW ! wow
(;)
qppq

### Rules of the contest

• Your program or function will receive only printable ASCII characters. You can include or not the empty string, (which is symmetric, of course!) as legal input, which is better for you.

• The ASCII characters that can be considered symmetric with respect to the vertical axes are the following (note the initial space, and the difference between uppercase and lowercase letters):

!"'+*-.:=AHIMOTUVWXY^_ovwx|

The ASCII characters that can be considered “mirrored” and their corresponding characters are:

()<>[]{}qpbd/\

Note that, since they are mirrored, you can have both () as well as )(, /\ and \/, etc.

All the other ASCII printable characters must be considered asymmetric and without a mirrored corresponding character.

• This is a challenge: the shorter your program is, measured in bytes, the better, in any programming language.

• Kudos to people that will produce a symmetric program!

Note: this question is not a duplicate of "Convenient Palindrome”, that requires to check for palindromic strings in which parentheses are flipped. This question is different for two reasons:

1) it is a restriction of the other question for what concerns non-parentheses characters, since only symmetric characters can appear in reverse order.

2) Since it is based on the concept of symmetry, and not on a concept of “convenient palindrome”, mirrored characters can appear in both order, i.e. [] and ][, and this makes the program to solve it different from programs that solve the other problem.

• Just for anybody wondering, Charcoal doesn't reflect letters. :( – totallyhuman Sep 9 '17 at 15:15
• I disagree with the dupeyness, as the dupe target does not reflect letters and this does. – Stephen Sep 9 '17 at 17:02
• Sorry, I missed the examples, my mistake – jrtapsell Sep 9 '17 at 18:29
• Why isn't 8 considered "symmetric"? – Scott Milner Sep 9 '17 at 19:36
• @FunkyComputerMan It's not essentially the same as the dupe target at all. First and foremost this has no source code restriction. – Jonathan Allan Sep 11 '17 at 18:17

## JavaScript (ES6), 130125 113 bytes

f=
s=>s==[...s].reverse(s=()<>[]{}qpbd/\\).map(c=>s[s.indexOf(c)^1]||/[- !"'+*.:=AHIMOT-Y^_ovwx|]/.exec(c)).join
<input oninput=o.textContent=f(this.value)><pre id=o>

Edit: Saved 5 bytes thanks to @Arnauld. Saved a further 11 bytes thanks to @YairRand.

• Could you use a regexp instead of includes()? Such as /[- !"'+*.:=AHIMO^_ovwx|T-Y]/.test(c). – Arnauld Sep 9 '17 at 20:00
• @Arnauld Indeed, that range is very helpful, thanks! – Neil Sep 9 '17 at 20:16
• You can golf [...s].reverse().map(...) to: s::[].map().reverse() if you are ok with using new ES-next features. link – Downgoat Sep 12 '17 at 3:03
• @Downgoat Do you have a link to the spec of that feature? – Neil Sep 12 '17 at 7:47
• @Neil here – Downgoat Sep 12 '17 at 21:46

# Jelly, 69 62 bytes

“(<[{qb/“ !"'+*-.:=AHIMOTUVWXY^_ovwx|“)>]}pd\”,Ṛ$F©f@ð®œs2¤yU⁼ Try it online! All test cases -7 bytes thanks to @JonathanAllan How it Works “(<[{qb/“ !"'+*-.:=AHIMOTUVWXY^_ovwx|“)>]}pd\”,Ṛ$F©f@ð®œs2¤yU⁼  main link

“(<[{qb/“ !"'+*-.:=AHIMOTUVWXY^_ovwx|“)>]}pd\”  The literal list of strings  ['(<[{qb/', ' !"\'+*-.:=AHIMOTUVWXY^_ovwx|', ')>]}pd\\']
$Last two links (if not part of an LCC) as a monad Ṛ Reverse array Does not vectorize. , Pair; return [x, y]. © Copy link result to register (® atom to retrieve). F Flatten list. f Filter; remove the elements from x that are not in y. @ Swaps operands. ð Start a new dyadic chain ¤ Nilad followed by links as a nilad. 2 The literal integer 2 ® Restore; retrieve the value of the register. Initially 0. œs Split x into y chunks of similar lengths. y Translate the elements of y according to the mapping in x. U Upend; reverse an array. ⁼ Equals. Does not vectorize. • Save six bytes using a filter: ¢FiÐ€;1Ạðaµ¢yU⁼ -> ¢Ff@ð¢yU⁼ – Jonathan Allan Sep 9 '17 at 16:30 • Save another by using the register (all on one line now): ...}pd\”,Ṛ$Fœs©2Ff@ð®yU⁼ – Jonathan Allan Sep 9 '17 at 16:37

Try it online!

# Scala, 140 bytes

s.zip(s.reverse).forall(c=>(" !\"'+*-.:=AHIMOTUVWXY^_ovwx|".flatMap(x=>x+""+x)+"()<>[]{}qpbd/\\\\/dbpq}{][><)(").indexOf(c._1+""+c._2)%2==0)

Try it online!