You've been called to implement an image detection routine for the ASCII dice roller. Write a program or function so that each time two ASCII dice are rolled, you return the total value shown. To make things trickier, sometimes defective ASCII dice get into the system which have the spots in the wrong positions. That's a possible indicator of fraud, so we need to call a supervisor if that happens.
Input
Lines of text (array of arrays, single string with newlines, stdin, etc) representing two dice side by side in this format:
--- ---
|o o| |o |
|o o| | |
|o o| | o|
--- ---
Each die is 5x5 characters, with 3 -
on the top and bottom, 3 |
on each side, and spaces in the corners and filling the middle. The spots are o
characters. There is one space between the two dice.
Each die may be rotated. (This only visibly affects the 6, 2 and 3.)
You can assume the structure of the two dice (the |
and -
and spaces) is correct, and that each face will contain only spaces and o
. There may be any number of spots on each face from 0 to 9.
The correct layouts of spots on each die face are as follows:
---
|o o|
|o o|
|o o|
---
---
|ooo|
| |
|ooo|
---
---
|o o|
| o |
|o o|
---
---
|o o|
| |
|o o|
---
---
|o |
| o |
| o|
---
---
| o|
| o |
|o |
---
---
|o |
| |
| o|
---
---
| o|
| |
|o |
---
---
| |
| o |
| |
---
Output
If the spots on both faces matches a correct layout (including rotations), return the sum of the two values (8 in the example above). Otherwise, return anything other than a number between 2 and 12. It is acceptable for your program to throw an exception or crash (but not hang) or produce no output in this case.
Scoring
Code golf. Standard rules apply.
Sample data
--- ---
| o| |o |
| | | |
|o | | o|
--- ---
=> 4
--- ---
| o | |o |
| | | |
| o | | o|
--- ---
=> 0
--- ---
|o o| | |
| o | | o |
|o o| | |
--- ---
=> 6
--- ---
| o| | |
| o | | o |
|o o| | |
--- ---
=> 0
--- ---
| | | |
| | | o |
| | | |
--- ---
=> 0
--- ---
|ooo| |o |
| | | o |
|ooo| | o|
--- ---
=> 9
--- ---
|o o| | o|
| o | | o |
|o o| |o |
--- ---
=> 8
--- ---
|ooo| |o |
| | | o |
|o o| | o|
--- ---
=> 0