Skip to content

Instantly share code, notes, and snippets.

@compwron compwron/judge.rb
Created Jun 25, 2019

Embed
What would you like to do?
judge.rb aiming for a tie, doesn't work yet
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
You can’t perform that action at this time.