SHARE
TWEET

Wayside

a guest Oct 11th, 2013 79 Never
  1. #!/usr/local/bin/python3
  2. import math
  3.  
  4. 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]
  5. runoffs = [100, 91, 85, 80.5, 75, 65, 60, 50, 30, 10, 6]
  6.  
  7. option_a = 25
  8. for runoff in runoffs:
  9.         vote_a = 0
  10.         vote_b = 0
  11.         option_b = runoff
  12.         print("## ROUND ", option_a, " VS. ", option_b, " ##")
  13.         for vote in votes:
  14.                 option_a_minus = math.fabs(vote - option_a)
  15.                 option_b_minus = math.fabs(vote - option_b)
  16.                 if option_a_minus > option_b_minus:
  17.                         vote_b += 1
  18.                         print(vote, " votes for ", option_b)
  19.                 if option_a_minus < option_b_minus:
  20.                         vote_a += 1
  21.                         print(vote, " votes for ", option_a)
  22.         if vote_a > vote_b:
  23.                 print("@@ ", option_a, " WINS! ", vote_a, " to ", vote_b, " @@")
  24.         elif vote_a < vote_b:
  25.                 print("@@ ", option_b, " WINS! ", vote_b, " to ", vote_a, " @@")
  26.                 option_a = runoff
  27.         else:
  28.                 print("@@ AWKWARD TIE @@")
RAW Paste Data
Top