TopCoder problem "RailroadSeatNumeration" used in SRM 329 (Division I Level One , Division II Level Two)

Problem Statement


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).



Method signature:String getInternational(int[] tickets)
(be sure your method is public)


-tickets will contain between 1 and 36 elements, inclusive.
-Each element of tickets will be between 1 and 100, inclusive.
-tickets will contain no duplicate elements.


Returns: "11"
Seat number 1 exists only in the domestic numeration, and it corresponds to seat number 11 in the international numeration.
Returns: "AMBIGUOUS"
Seat number 11 exists in both numerations, so we cannot figure out which numeration is used here.
Returns: "BAD DATA"
No seat can be numbered 45 in any numeration.
{5, 7, 6}
Returns: "21 24 23"
Remember to return tickets in the same order as in the input.
{21, 24, 23}
Returns: "AMBIGUOUS"
{8, 28}
Returns: "26 76"

Problem url:

Problem stats url:




PabloGilberto , brett1479 , Olexiy , lovro

Problem categories:

Simple Math, Simple Search, Iteration