diff --git a/app.py b/app.py index 167c47b..2ba09e5 100644 --- a/app.py +++ b/app.py @@ -354,11 +354,17 @@ def runoff(ballots): candidates = {} for ballot in ballots: for r in ballot: - count[r.id] = [0] * len(ballot) + if r.id not in count or len(count[r.id]) < len(ballot): + log.debug("count[%d] <- %d elements", r.id, len(ballot)) + count[r.id] = [0] * len(ballot) candidates[r.id] = r for ballot in ballots: for pos, r in enumerate(ballot): + log.debug("count = %s", count) + log.debug("r.id = %s", r.id) + log.debug("pos = %s", pos) count[r.id][pos] += 1 + log.debug("count[%d][%d]) = %d", r.id, pos, count[r.id][pos]) result = sorted(count.keys(), key=lambda i: count[i]) log.debug("result of this round:") for r in result: