Problem G
Eye of Sauron
Little Elrond is obsessed with the Lord of the Rings series. Between lectures he likes to doodle the central tower of the great fortress Barad-dûr in the margins of his notebook. Afterward, he always double checks his drawings to ensure they are accurate: with the Eye of Sauron located in the very center of the tower. If any are incorrect, he makes sure to fix them.
You are to write a program that reads a representation of his tower, and ensures that the drawing is correct, with a properly centered eye.
Input
Input consists of a single string of length ${n}$, where $4\leq n \leq 100$. Input strings will consist only of three types of characters: vertical bars, open parentheses, and closing parentheses. Input strings contain one or more vertical bars followed by a set of matching parentheses (the “eye”), followed by one or more vertical bars. For a drawing to be “correct”, the number of vertical bars on either side of the “eye” must match. Input will always contain a pair of correctly matched parentheses, with no characters between them. No other characters will appear in the string.
Output
On a single line print the word “correct” if the drawing is accurate or the word “fix” if there is an error that needs addressing.
Sample Input 1 | Sample Output 1 |
---|---|
|()|| |
fix |
Sample Input 2 | Sample Output 2 |
---|---|
||||()|||| |
correct |
Sample Input 3 | Sample Output 3 |
---|---|
|()| |
correct |
Sample Input 4 | Sample Output 4 |
---|---|
|||()| |
fix |