Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys
- states = [
- ("Austria", 10, 1.67),
- ("Belgium", 12, 2.17),
- ("Bulgaria", 10, 1.49),
- ("Cyprus", 4, 0.16),
- ("Czech Republic", 12, 2.10),
- ("Denmark", 7, 1.11),
- ("Estonia", 4, 0.27),
- ("Finland", 7, 1.07),
- ("France", 29, 12.95),
- ("Germany", 29, 16.27),
- ("Greece", 12, 2.25),
- ("Hungary", 12, 1.99),
- ("Ireland", 7, 1.07),
- ("Italy", 29, 12.07),
- ("Latvia", 4, 0.44),
- ("Lithuania", 7, 0.65),
- ("Luxembourg", 4, 0.10),
- ("Malta", 3, 0.08),
- ("Netherlands", 13, 3.31),
- ("Poland", 27, 7.6),
- ("Portugal", 12, 2.12),
- ("Romania", 14, 4.26),
- ("Slovakia", 7, 1.08),
- ("Slovenia", 4, 0.41),
- ("Spain", 27, 9.18),
- ("Sweden", 10, 1.87),
- ("United Kingdom", 29, 12.43)
- ]
- def count_votes(votes):
- v = 0;
- p = 0;
- i = 0;
- while i < 27:
- if votes & 1:
- v += states[i][1]
- p += states[i][2]
- votes >>= 1
- i += 1;
- return v, p
- def interest(state, votes):
- return ((1 << states.index(state)) & votes) != 0
- def nice(states, votes):
- return states >= 14 and votes >= 255
- def nicepop(states, votes, pop):
- return nice(states, votes) and pop >= 62
- def lisbon(states, pop, blocking):
- return (blocking < 4) or (states >= 15 and pop >= 65)
- def vote(votes):
- states = bin(votes).count("1");
- v, p = count_votes(votes)
- return nice(states, v), nicepop(states, v, p), lisbon(states, p, 27 - states)
- def round(t):
- print(t[0])
- votes = 0;
- nice_win = 0;
- nicepop_win = 0;
- lisbon_win = 0;
- while votes <= 134217727:
- nice_r, nicepop_r, lisbon_r = vote(votes)
- intr = interest(t, votes)
- nice_win += (nice_r == intr)
- nicepop_win += (nicepop_r == intr)
- lisbon_win += (lisbon_r == intr)
- votes += 1
- print("-----------------------")
- print("Nice wins: ", nice_win)
- print("Nice with population criterion wins: ", nicepop_win)
- print("Lisbon wins: ", lisbon_win)
- print("-----------------------")
- print()
- def main():
- if (len(sys.argv) == 2):
- round(states[int(sys.argv[1])])
- else:
- for t in states:
- round(t)
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement