]> projects.mako.cc - selectricity/blobdiff - lib/rubyvote/condorcet.rb
Add link woraround for the logout button
[selectricity] / lib / rubyvote / condorcet.rb
index 0cc169647b4526202347e74054f0173b5d994a69..0c6fd5647bd921e5543838b42ddc297b57ca72cd 100644 (file)
@@ -123,27 +123,18 @@ class CondorcetResult < ElectionResult
   end
   
   def victories_and_ties
-    victors = Array.new
-    victories_ties = Hash.new
+    victories_ties = {}
     candidates = @matrix.keys.sort
     
     candidates.each do |candidate|
       candidates.each do |challenger|
         next if candidate == challenger
         diff = @matrix[candidate][challenger] - @matrix[challenger][candidate]
-        if diff >= 0 
-          victors << [candidate, challenger, diff] 
+        victories_ties[candidate] = {} unless victories_ties.key?(candidate)
+        if diff >= 0
+          victories_ties[candidate][challenger] = diff
         end
       end
-    end  
-    
-    victors.each do |list|
-      if victories_ties.has_key?(list[0])
-        victories_ties[list[0]][list[1]] = list[2]       
-      else
-        victories_ties[list[0]] = Hash.new
-        victories_ties[list[0]][list[1]] = list[2]
-      end
     end
     
     return victories_ties    

Benjamin Mako Hill || Want to submit a patch?