Pastie now auto-senses if line-wrap is a bad or good idea. Feedback?
## mark a section (Learn more)
participants = ['pashira', 'martishka', 'life_is_mistery', 'avinamor', 'megvaer'] weights = { 'pashira' => 1.0, 'martishka' => 1.0, 'life_is_mistery' => 1.0, 'avinamor' => 1.0, 'megvaer' =>1.0} votes = {} votes['pashira'] = ['life_is_mistery', 'megvaer'] votes['martishka'] = ['life_is_mistery'] votes['life_is_mistery'] = ['avinamor'] votes['avinamor'] = ['megvaer'] votes['megvaer'] = ['avinamor'] def fact(n) if n>0 n*fact(n-1) else 1 end end quantity = participants.size number = fact(quantity) number.times do |iterator| swap = iterator%quantity participants[participants.size] = participants[ swap ] participants = participants[0..swap-1].to_a + participants[swap+1..quantity].to_a participants.each do |who| whom = votes[who] weight_delta = weights[who]/(whom.size+1) whom.each do |person| weights[person] += weight_delta end end end puts weights.sort_by { |key, value| value }.reverse
This paste will be private.
From the Design Piracy series on my blog: