[Question]
  [
As you most probably now, there are 2339 solutions to pentomino puzzle in a 6x10 grid. There are different labeling schemes for the 12 pentominoes, two of them are shown on the image below:
[![enter image description here](https://i.stack.imgur.com/pjRVg.png)](https://i.stack.imgur.com/pjRVg.png)
Image credit: Wikipedia
For the purposes of the current task we will say that a normalized pentomino solution is a solution that uses the second labeling scheme (Conway’s). 
Example:
```
O O O O O S S S Z Z
P P R R S S W W Z V
P P P R R W W Z Z V
U U X R T W Y V V V
U X X X T Y Y Y Y Q
U U X T T T Q Q Q Q
```
The piece with 5 squares in a row is denoted with letters `O`, according to the scheme. The same is true for all pieces.
## Task:
Given a solution to the 6x10 pentomino in which the pieces are labeled with a random sheme, normalize it so that all pieces are labeled in Conway’s labeling scheme. You need to recognize the pieces and mark each square of a particular piece with the symbol of the piece.
## Input:
The solution to be normalized, in any format that is convenient for you, for example:
* A multiline string
* A list of strings
* A list of lists of characters
and so on
## Output:
The same solution (all the pieces positions and orientation preserved), but each piece labeled according to Conway’s labeling scheme. 
Note: The output MUST be PRINTED as a 6x10 grid of characters. Leading and trailing newlines and spaces are permitted. You can also print a space between the characters (but not empty lines), as in the example above.
## Test cases:
1.
Input:
```
6623338888
6222344478
66A234BB70
1AAA94B770
11A99BB700
1199555550
```
Output:
```
UURTTTQQQQ
URRRTVVVSQ
UUXRTVZZSY
PXXXWVZSSY
PPXWWZZSYY
PPWWOOOOOY
```
2.
Input:
```
45ookkkk00
455ooogk00
4a55gggdd0
4aaa3gnnd.
4am333ndd.
mmmm3nn...
```
Output:
```
OWSSQQQQPP
OWWSSSRQPP
OTWWRRRUUP
OTTTXRZZUV
OTYXXXZUUV
YYYYXZZVVV
```
## Winning criteria:
The shortest solution in bytes in each language wins. Don’t be discouraged by the golfing languages. Explanations of the algorithms and implementations are welcome.
  
[Answer]
# [APL (Dyalog Classic)](https://www.dyalog.com/), ~~54~~ ~~53~~ 50 bytes
```
⍴⍴{'OXRYTPZQUWSV'[⌊5÷⍨⍋⍋,{×/+⌿↑|(⊢-+/÷≢)⍸⍵}¨⍵=⊂⍵]}
```
[Try it online!](https://tio.run/##Lc/PTsIwHAfwu0/hrRBkwP7hTDyMF9jY2rWr8bCwsBDGZoCLQS7GkIDM6MF4lpMPINF4MZE36YvM3za@6f58@mvaX4ObuBneBnEaNQdxMJuNBrl4eh2lYvXczofwFtknjAWymONjm/cJdT10JbYb7fAlsg@RPcI4WxzeWg2x/RWrl7ua2OyajRaU17u6yL5Ftl/@wcL9pdjcw@d6medz2HkB/2L9DscBpvAMRfZzgdIxEo8PaBiMYgQTsGi6PKnBxkjXZUVRziHoFOmyLCuqqnZL6Cag1@u2AR3TNA21163QMQ2jKFQwDK1IG9XnxY6EOBjjPgSqxHEc7HmeW4IwAOeuD7AZY9TjbgWbUVoUKlBqFfFR1aOqpekYUp6naqA0OiLQtCiKwrBCEChRkoRSiQncKwlLTCBKkkiSdOzRoq5bdGjbULUoyHWOwJRCz4RUwJg5nBOvhA8tc1LChzDO4WboHw "APL (Dyalog Classic) – Try It Online")
Compute an invariant for each pentomino in the input: measure (∆x,∆y) from each of its squares to its centre of gravity, take abs(∆x) and abs(∆y), sum the x components and separately the y components, and multiply the two sums. This gives 12 distinct results. Then, find the index of each pentomino's invariant in the sorted collection of all invariants. Replace 0 with `'O'`, 1 with `'X'`, 2 with `'R'`, etc.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 37 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
ŒĠZÆmạƊ€ḅı§AỤỤị“æṂ⁾+’Œ?¤+78Ọ,@FQṢƊyⱮY
```
A full program taking a list of strings (because we must print - otherwise remove the trailing `Y` and you have a monad taking a list of lists of numbers or characters which returns a list of lists of characters).
**[Try it online!](https://tio.run/##y0rNyan8///opCMLog635T7ctfBY16OmNQ93tB7ZeGi548PdS8Co@1HDnMPLHu5setS4T/tRw8yjk@wPLdE2t3i4u0fHwS3w4c5Fx7oqH21cF/n///9oJRPT/PxsIDAwUOLSAfKA3Px0GC/R1DQ9PT0lBcpLTDROz8tL0YPwco2NjfNSILxcIDDOy9PT01OKBQA "Jelly – Try It Online")**
### How?
I believe this works using the same categorisation of pentominos as [ngn's APL solution](https://codegolf.stackexchange.com/a/173909/53748), albeit in a slightly different way (I also don't know APL so I'm not that sure how similar the method is beyond the categorisation).
(Note that `“æṂ⁾+’Œ?¤+78Ọ` is only a one-byte save over `“XRPTZWUYSVQO”`!)
```
ŒĠZÆmạƊ€ḅı§AỤỤị“æṂ⁾+’Œ?¤+78Ọ,@FQṢƊyⱮY - Main Link: list of lists of characters L
ŒĠ                                    - group multidimensional indices by value
      Ɗ€                              - last three links as a monad for €ach i.e. f(x):
  Z                                   -   transpose x
   Æm                                 -   mean (vectorises) (i.e. the average of the coordinates)
     ạ                                -   absolute difference with x (vectorises) (i.e. [dx, dy])
         ı                            - square root of -1 (i)
        ḅ                             - convert from base (vectorises) (i.e a list of (i*dx+dy)s)
          §                           - sum each
           A                          - absolute value (i.e. norm of the complex number)
            Ụ                         - grade up (sort indices by value)
             Ụ                        - grade up (...getting the order from the result of A back,
                                      -              but now with one through to 12)
                       ¤              - nilad followed by links as a nilad:
               “æṂ⁾+’                 -   base 250 literal = 370660794
                     Œ?               -   permutation@lex-index = [10,4,2,6,12,9,7,11,5,8,3,1]
              ị                       - index into
                        +78           - add seventy-eight
                           Ọ          - cast to characters (character(1+78)='O', etc...)
                                 Ɗ    - last three links as a monad (i.e. f(L)):
                              F       -   flatten
                               Q      -   de-duplicate
                                Ṣ     -    sort
                            ,@        - pair (with sw@pped @rguments) (giving a list of 2 lists)
                                   Ɱ  - Ɱap across L with:
                                  y   -   translate i.e. swap the letters as per the the pair)
                                    Y - join with new lines
                                      - implicit print
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 103 bytes
```
""<>Riffle[(t=#)/.Thread[SortBy[Union@@t,Tr@Kurtosis@Position[t,#]&]->Characters@"UPSWZVRTQXYO"],"\n"]&
```
Takes input as a list of lists of characters.
[Try it online!](https://tio.run/##dc1Ni8IwEIDhu78iTEEUoi6ot1WCe9yDXa0fa8wh2GrDblNIx4NIf3uttqT16/LAhHknkcQwiCSqncxcozTyDOBzPFP7/X/AWzhy2r2uF5pA@nweG5yc@EKrWDOG1DPs@2gwTlTC3FzM3zlSRzRFZ/wVSiN3GJiEwcKdrzbLmfez/p2CoLDVIJoZYeR8hgFQAsMrseXvBR8FKSX15kqD1Nsbh/eZvGuLzUN55Tb4lqesom9bbfHLK93HLLJFhb7/qmyicj0/Q@xQL3SxXJGmIrsA "Wolfram Language (Mathematica) – Try It Online")
The main idea here is that for each character in the input, we find the coordinates where it occurs, take the kurtosis and sum its coordinates. This gives us an invariant for each piece.
(The kurtosis is some mostly-irrelevant operator from statistics - the key is that it's invariant under translation, while reflection and rotation might switch the order of coordinates at most. We sum the coordinates, so the invariant never changes.)
Anyway, apart from the weird invariant, this solution is similar to the others: we sort the characters and the pieces by each invariant, then replace each character by the corresponding character of `"UPSWZVRTQXYO"`: the pieces, sorted by kurtosis sum.
Finally, `""<>Riffle[...,"\n"]` is the print-as-a-grid code.
[Answer]
# [Python 2](https://docs.python.org/2/), 191 bytes
```
def y(o):print"".join(['XPRTWZUYSVQO\n'[[w for v,w in sorted([sum(abs(u-sum(t)/5)for t in[[complex(r%11,r/11)for r,q in enumerate(o)if q==p]]for u in t),p]for p in o)].index(x)/5]for x in o])
```
[Try it online!](https://tio.run/##HY3LbsMgFET3@QqEVAUkh8Ql3kTKN/T9JF7QgiltuRCMG/vrXfCszty5mglT@vJwPc9Kd2ginh5CtJAwZt/eAhHr19v7x5f3p7eH57ubE6yFuKDOR/RXXZAF1PuYtCKiHxyRHz0ZNoUS3Ta0fKX8I8Snd@FXjyRe1XUVt3W9ZLE6lwYNg9NRJp23bYfOx2No25IPJU20CosLxXnaMgsqV415YbmPy72l80QwxvvG@5@s3W61bzJ7s6BsGmOMUgWl5AZAsYyOcw4qo8viAIyxVS6h8z8 "Python 2 – Try It Online")
Takes a multi-line string with a trailing newline and does six nested list comprehensions.
**Ungolfed Version**
```
def pentomino_normalizer(input_string):
    # input_string is a multi-line string with a trailing newline
    results = []  # For saving the results of the for loop
    for current_char in input_string:
        # current_char = p in the golfed version
        # The python data type complex stores a real and a imaginary value and
        # is used for storing the x and y coordinates.
        # In the end, the positions list contains a complex number for every
        # occurence of current_char in the string
        # positions_list = t in the golfed version
        positions_list = [complex(i % 11, i / 11) for i, c
                          in enumerate(input_string) if c == current_char]
        # average_pos is the midpoint of all occurences of current_char, 
        # to get rid of translations
        average_pos = sum(positions_list)/5
        # Calculates a value for each tile that is invariant under 
        # translations and rotations,
        # simply the sum of all the distances between the midpoint
        # and the positions
        invariant = sum(abs(pos - average_pos) for pos in positions_list)
        # Saves the invariant value to a list
        results.append(invariant, current_char)
    # This new list contains the characters occuring in the string, sorted
    # by the invariant value. Because this was done with each char in the 
    # input string, this lists contains every value five times and also 
    # contains six newlines
    # at the end of the list
    sorted_results = [w for v, w in sorted(results)]
    # This code snippet maps each char from the input string to its according
    # output and prints to stdout
    chars = ['XPRTWZUYSVQO\n'[sorted_results.index(c)/5] for c in input_string]
    print "".join(chars)
```
]