You belong to a council which oversees the destruction of corrupted worlds. When the council assembles, a single vote is taken. The ballot lists all nominated worlds. One is ultimately destroyed each time the council meets.
Due to a bug in user12345's code, the council recently flooded and then sent pirate zombies to the wrong planet. We need a more reliable system for counting votes.
A vote is described by a series of integers on a single line. The first integer is
m, and the worlds nominated for destruction are uniquely numbered from 1 to
m. The remaining integers each represent the world each council member voted on.
Somehow, without any collusion, one world always receives more than half of the vote. This always occurs, regardless of how many worlds are present.
Given an input, write a program that outputs the world elected for destruction.
Remember, the first
3 is the number of worlds,
m. It is not a vote.
3 1 1 2 3 1 3 1 1 3
The majority of the council voted for planet 1, so we output that.
- The exact number of votes is not given
- The number of votes is between 1 and 100 (inclusive)
- Each vote is between 1 and m (inclusive)
- Every vote contains a majority
- Input must be provided through stdin, read from a file, or accepted as a sole argument to the program
The answer with the fewest characters wins!