hexa | {
"GaetanLepage": 188,
"JulienMalka": 262,
"K900": 332,
"Scrumplex": 215,
"aanderse": 180,
"adamcstephens": 251,
"cafkafk": 275,
"crertel": 115,
"djacu": 131,
"drupol": 209,
"getchoo": 206,
"jopejoe1": 237,
"leona-ya": 290,
"mschwaig": 181,
"niklaskorz": 287,
"nim65s": 179,
"nyabinary": 231,
"philiptaron": 246,
"pinpox": 190,
"pluiedev": 292,
"rhendric": 261,
"samueldr": 244,
"tomberek": 141,
"tomodachi94": 173
}
| 13:17:07 |
hexa | #!/usr/bin/env python3
from collections import defaultdict
import json
votes = []
candidates = []
with open("./opavote-ballots-5.blt") as fd:
for line in fd.readlines():
line = line.strip()
if line.startswith("1") and line.endswith("0"):
vote = line.split()
vote.pop(0)
vote.pop()
votes.append(vote)
if line.startswith('"'):
candidate = line.strip().strip('"')
candidates.append(candidate)
candidates.pop()
approvals = defaultdict(int)
for vote in votes:
approval = vote[:12]
for candidate in approval:
approvals[int(candidate)] += 1
result = {}
for slot, name in enumerate(candidates, 1):
print(slot, name)
result[name] = approvals[slot]
print(json.dumps(result, indent=2))
| 13:17:38 |