Slide 32
Slide 32 text
͍ํ
require 'irv'
irv = Irv.new(['とんかつ', 'カレー', '生ハム'])
p irv.candidates
# => ["とんかつ", "カレー", "生ハム"]
ballots = []
7.times do
ballots << irv.issue_ballot
end
ballots[0].fill!(['とんかつ', 'カレー'])
ballots[1].fill!(['とんかつ', 'カレー'])
ballots[2].fill!(['カレー', 'とんかつ', '生ハム'])
ballots[3].fill!(['カレー', 'とんかつ'])
ballots[4].fill!(['生ハム', 'カレー', 'とんかつ'])
ballots[5].fill!(['生ハム', 'とんかつ', 'カレー'])
ballots[6].fill!(['生ハム', 'とんかつ'])
ballots.each { |ballot| irv.poll!(ballot) }
p irv.winner
# => "とんかつ"