Skip to content

Code to provide the result of an alternative vote election (Note, this is just for fun, not for real elections)

Notifications You must be signed in to change notification settings

robne1982/AlternativeVote

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Very basic code to calculate the results of an AV vote.

Input

Please supply a csv file that looks like

VoteChoice PersonA PersonB PersonC
DonaldTrump 2 3
Obama 1 1
GeorgeBush 3 2
DavidCameron 4 2
TonyBlair 5 1

At the moment you need to save this somewhere and then change the hardcoded file path on line 4 the python code.

Usage

Run the python code. Output is written to the console.

Output

============================================================================================
Before round 1 there are 5 candidates 
 and we have 3 goats voting
============================================================================================
============================================================================================
 ROUND 1
 --------------------------------
The votes are 
DonaldTrump : 0
Obama : 2
GeorgeBush : 0
DavidCameron : 0
TonyBlair : 1
 --------------------------------
Therefore there are 3 removals
DonaldTrump
GeorgeBush
DavidCameron
 --------------------------------
The new vote list is as follows
['Obama', 1, '', '1']
['TonyBlair', '5', 1, '']
 --------------------------------
============================================================================================
 ROUND 2
 --------------------------------
The votes are 
Obama : 2
TonyBlair : 1
 --------------------------------
Therefore there are 1 removals
TonyBlair
 --------------------------------
The new vote list is as follows
['Obama', 1, '', '1']
 --------------------------------
============================================================================================
 The winner is declared : Obama
============================================================================================

Things to note

  • Voters are referred to as goats
  • Losing choice ties are all removed simultaneously
  • Dead heats are possible

About

Code to provide the result of an alternative vote election (Note, this is just for fun, not for real elections)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages