Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/python3
- import math
- votes = [6, 10, 25, 25, 25, 25, 25, 25, 25, 30, 50, 50, 60, 60, 65, 75, 75, 75, 80.5, 85, 85, 85, 85, 91, 100, 100, 100, 100, 100]
- runoffs = [100, 91, 85, 80.5, 75, 65, 60, 50, 30, 10, 6]
- option_a = 25
- for runoff in runoffs:
- vote_a = 0
- vote_b = 0
- option_b = runoff
- print("## ROUND ", option_a, " VS. ", option_b, " ##")
- for vote in votes:
- option_a_minus = math.fabs(vote - option_a)
- option_b_minus = math.fabs(vote - option_b)
- if option_a_minus > option_b_minus:
- vote_b += 1
- print(vote, " votes for ", option_b)
- if option_a_minus < option_b_minus:
- vote_a += 1
- print(vote, " votes for ", option_a)
- if vote_a > vote_b:
- print("@@ ", option_a, " WINS! ", vote_a, " to ", vote_b, " @@")
- elif vote_a < vote_b:
- print("@@ ", option_b, " WINS! ", vote_b, " to ", vote_a, " @@")
- option_a = runoff
- else:
- print("@@ AWKWARD TIE @@")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement