In a certain European country, railroad cars consist of 9 compartments, each containing 4 seats. There are two possible numeration methods for the seats: the domestic numeration and the international numeration.
-
In the domestic numeration, the seats in the first compartment are numbered 1 through 4, the seats in the second compartment are numbered 5 through 8, and so on.
-
In the international numeration, every seat's number consists of two digits. The first digit is the number
of the compartment and the second digit is the number of the seat within that compartment. Compartments are numbered 1 through 9, and the four seats within each compartment are numbered 1, 3, 4, 6 (in the same order as in the domestic numeration).
You are given a int[] tickets containing seat numbers in an unknown numeration. Assuming that every seat number in tickets is in the same numeration, convert them into the international numeration. Return the result as a String containing a single-space separated list of converted numbers in the same order that they are given in the input. If there are several possible return values, return "AMBIGUOUS" (quotes for clarity only). If the input cannot be interpreted as a valid list of seat numbers all in the same numeration, return "BAD DATA" (quotes for clarity only).
|