-
-
Save HP/15562bf940ecd2a7d3b5e5ee749061f4 to your computer and use it in GitHub Desktop.
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
#!~/.rbenv/shims/ruby | |
Effpeer = Struct.new(:name, :period) do | |
def available? day | |
period.to_a.include? day | |
end | |
end | |
participants = [ | |
['Timar', 1..10], | |
['polarjenta', 1..24], | |
['Eia', 1..24], | |
['ingling', 1..24], | |
['Toffskij', 13..24], | |
['Che', 1..24], | |
['Pamina', 10..20], | |
['Teofelia', 11..24], | |
['Lorien', 16..24], | |
['Fersken', 1..24], | |
['Darth', 1..24], | |
['Taien', 1..24], | |
['Polyanna', 1..24], | |
['Elise', 10..24], | |
['Inagh', 1..24], | |
['Blånn', 1..24], | |
['Enhjørning', 1..24], | |
['Maverick', 1..24], | |
['Pappalille', 20..24], | |
['Acino', 11..24], | |
['Tink', 1..24], | |
['Albertine', 1..24], | |
['Stompa', 1..10], | |
['Dali', 17..24], | |
['Skilpadda', 11..24], | |
['IOA', 1..1], | |
['007', 1..24], | |
['Tallulah', 14..24] | |
] | |
effpeers = participants.collect {|u| Effpeer.new(u[0], u[1])} | |
10.times do | |
effpeers = effpeers.shuffle | |
end | |
days = *1..24 | |
result = Hash.new | |
days.shuffle.each do |day| | |
while !result.key? day do | |
participant = effpeers[rand effpeers.size] | |
result[day] = participant if participant.available? day | |
end | |
effpeers = effpeers - [result[day]] | |
end | |
(1..24).to_a.each do |day| | |
effpeer = result[day] | |
puts "#{day}.\t #{effpeer.name}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment