The Rorschach test is a psychological test that was introduced in 1921 by the Swiss psychologist Hermann Rorschach. An inkblot is made on one side of a card, and then mirrored on the other half by folding the card.

rorschachtest
The first of ten cards used in the Rorschach test. The cards themselves are just one component of the test, whose focus is on the analysis of the perception of the cards.

A subjects' perceptions of the inkblots are recorded and then analyzed using psychological interpretation, complex algorithms, or both. Some psychologists use this test to examine a person's personality characteristics and emotional functioning. It has been employed to detect underlying thought disorder, especially in cases where patients are reluctant to describe their thinking processes openly.

Assignment

Write a program that generates cards that can be used in the Rorschach test. This is done by transforming a given text pattern — representing an inkblot — into a pattern that is formed from the original pattern with a mirrored version of the pattern to its right. Click here to switch between a display of the left half of the pattern, and the complete pattern whose the right half is formed as the mirror image of the left half.

++...+..+++.
....++......
.+.#####+###
...#@#@#.#@#
.+.#####.##@
....+.+...##
.....+......
....+.....##
....+..+..#@
......###.##
+...++#@#.+.
....#####...
....#@#....+
++..###.+...
+.....+.....

Write a function rorschach that takes the location (str) of a text file as its argument. This file must contain a text pattern, formatted as a sequence of lines that each contain the same number of characters. The function must also have a second optional parameter that takes the location (str) of a second text file. The transformed version of the pattern that results after mirroring the given pattern must be written to the second file. In case the function is called without a second argument, the function must print the mirrored version of the pattern to output.

Example

In the following interactive session we assume that the text file pattern.txt1 is located in the current directory. Click on the name of the files to see the given pattern and the transformed pattern.

>>> rorschach('pattern.txt2')
++...+..+++..+++..+...++
....++............++....
.+.#####+######+#####.+.
...#@#@#.#@##@#.#@#@#...
.+.#####.##@@##.#####.+.
....+.+...####...+.+....
.....+............+.....
....+.....####.....+....
....+..+..#@@#..+..+....
......###.####.###......
+...++#@#.+..+.#@#++...+
....#####......#####....
....#@#....++....#@#....
++..###.+......+.###..++
+.....+..........+.....+
>>> rorschach('pattern.txt3', 'rorschach.txt4')

Epilogue

Pareidolia5 is the experience of "seeing" something in a stimulus that's simply vague and random. You've felt it if you've ever seen images of animals or faces in clouds, or the man in the moon, or heard messages when records are played in reverse. It's the basis for the Rorschach inkblot test6.

pareidolia
Portrait of Elisabeth II, queen of the United Kingdom and the other Commonwealth realms.

This is a portrait of Elizabeth II7 as it appeared on the 1954 series Canadian dollar bill. So many people thought they saw the face of the devil in the queen's hair that the bills were eventually withdrawn from circulation. There's nothing there — the portrait was adapted from a photograph.