Created
March 1, 2019 15:08
-
-
Save mdamien/eb82e7042481c0a180f3fddb70d28504 to your computer and use it in GitHub Desktop.
liquid_democracy demo
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import Counter | |
users = [1, 2, 3, 4, 5, 6, 7, 8] | |
delegs = { | |
4: 1, | |
5: 2, | |
6: 3, | |
7: 5, | |
8: 5, | |
} | |
votes = { | |
1: 'A', | |
7: 'B', | |
5: 'C', | |
6: 'C', | |
} | |
def compute_vote(user): | |
if user in votes: | |
return votes[user] | |
if user in delegs: | |
return compute_vote(delegs[user]) | |
return 'abst' | |
result = Counter([compute_vote(user) for user in users]) | |
for choice, n, in result.most_common(): | |
print(choice, n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment