Skip to content

Instantly share code, notes, and snippets.

@kac-
Last active August 29, 2015 14:21
Show Gist options
  • Select an option

  • Save kac-/4b5e55b003420c36203d to your computer and use it in GitHub Desktop.

Select an option

Save kac-/4b5e55b003420c36203d to your computer and use it in GitHub Desktop.

Revisions

  1. kac- revised this gist May 12, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion jow_przekazywanie_part.java
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    Map<String, Integer> result = new HashMap<>();
    Map<String, Integer> result = new HashMap<String, Integer>();
    while (constituencies.size() > 0) {
    Iterator<List<Candidate>> ci = constituencies.iterator();
    while (ci.hasNext()) {
  2. kac- revised this gist May 12, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions jow_przekazywanie_part.java
    Original 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()) {
  3. kac- created this gist May 12, 2015.
    23 changes: 23 additions & 0 deletions jow_przekazywanie_part.java
    Original 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();
    }
    }
    }