Created
June 25, 2019 06:57
-
-
Save compwron/323e3538c2979ac192eab46e7bb267b1 to your computer and use it in GitHub Desktop.
judge.rb aiming for a tie, doesn't work yet
This file contains 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 characters
def pick_tie_jurors(potential_jurors, k) | |
potential_jurors.combination(k).map do |combo| # 2 3 | |
p_tie = combo.combination(combo.count / 2).map { |possibles| # [2] # [3] | |
# inverses = [2, 3] - [2] # bug with distinct # [3] | |
inverses = (combo - possibles).map { |i| 1 - i } # bug with distinct # [3] | |
acc = 0 | |
possibles.map { |pos| | |
inverses.map { |inv| | |
pos * inv | |
}.sum | |
}.sum | |
}.max # show which vote directions? | |
# return a | |
# p_tie = combo.first * (1 - combo.last) + combo.last * (1 - combo.first) | |
[p_tie, combo] | |
end.max_by { |chance, _combo| chance } | |
end | |
p pick_tie_jurors([0.2, 0.5, 0.8], 2) # [0.2, 0.8] | |
p pick_tie_jurors([0.1, 0.2, 0.3, 0.7, 0.8, 0.9], 4) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment