Last active
August 29, 2015 14:21
-
-
Save kac-/4b5e55b003420c36203d to your computer and use it in GitHub Desktop.
Revisions
-
kac- revised this gist
May 12, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ Map<String, Integer> result = new HashMap<String, Integer>(); while (constituencies.size() > 0) { Iterator<List<Candidate>> ci = constituencies.iterator(); while (ci.hasNext()) { -
kac- revised this gist
May 12, 2015 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ Map<String, Integer> result = new HashMap<>(); while (constituencies.size() > 0) { Iterator<List<Candidate>> ci = constituencies.iterator(); while (ci.hasNext()) { -
kac- created this gist
May 12, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ while (constituencies.size() > 0) { Iterator<List<Candidate>> ci = constituencies.iterator(); while (ci.hasNext()) { List<Candidate> l = ci.next(); Collections.sort(l); Candidate candidate = l.get(0); if (candidate.acceptor != null && !candidate.acceptor.out) { candidate.acceptor.votes += candidate.votes; } else if (candidate.reserve != null && !candidate.reserve.out) { candidate.reserve.votes += candidate.votes; } candidate.out = true; l.remove(candidate); if (l.size() == 1) { Candidate win = l.get(0); Integer v = result.get(win.party); v = v == null ? 1 : v + 1; result.put(win.party, v); ci.remove(); } } }