Programming Assignment 3 (Voting)
Ranked Voting Scheme
Write a Python program to implement the Ranked Voting scheme.
In this voting scheme, each ballot lists 1st preference, 2nd preference, etc. The
voting ballots are present in a text file with each line corresponding to a
single ballot. The candidates are listed in preference order and are separated by
commas. Here is a sample input file:
$ more v2a.dat
Red,Green
Blue
Green,Red,Blue
Blue,Green,Red
Green
The method to determine the winner proceeds by eliminating candidate(s) with lowest number of
1st choice votes (if there are ties, eliminate all). This process is repeated until a single candidate
remains. That candidate is declared the winner.
If by eliminating candidates in any one round no candidate
remains then all the candidates remaining in that round are declared the winner.
$ python3 Vote.py v2a.dat
Ballots: [['Red', 'Green'], ['Blue'], ['Green', 'Red', 'Blue'], ['Blue', 'Green', 'Red'], ['Green']]
Winner: Green
Some test data files:
v2a.dat
v2b.dat
v2c.dat