Skip to content

Instantly share code, notes, and snippets.

@zspencer
Last active August 29, 2015 14:14
Show Gist options
  • Save zspencer/ec77ae8710952830deaa to your computer and use it in GitHub Desktop.
Save zspencer/ec77ae8710952830deaa to your computer and use it in GitHub Desktop.
best times for hacking
OPTIMAL_SCHEDULE_MAPPING = {
:zspencer => [
"Friday 5-7PM PST",
"Wednesday 5-7PM PST",
"Wednesday 6-8PM PST",
"Saturday 10AM-11AM PST",
"Saturday 11AM-12PM PST",
"Sunday 10AM-11AM PST",
"Sunday 11AM-12PM PST"
],
:alex => [
"Wednesday 5-7PM PST",
"Wednesday 6-8PM PST",
"Friday 5-7 PM PST",
"Saturday 10AM-12 PST"
],
:trevor => [
"Monday 5-7PM PST",
"Monday 6-8PM PST",
"Wednesday 5-7PM PST",
"Wednesday 6-8PM PST",
"Thursday 6-8PM PST",
"Thursday 5-7PM PST",
"Tuesday 6-8PM PST",
"Tuesday 5-7PM PST",
],
:mitch => [
],
:pete => [
]
}
rankings = {}
OPTIMAL_SCHEDULE_MAPPING.each_pair do |person, schedule|
schedule.each.with_index do |timeslot, index|
if rankings[timeslot]
rankings[timeslot] += index
else
rankings[timeslot] = index
end
end
end
sorted_pairs = rankings.to_a.sort { |a, b| a[1] <=> b[1] }
sorted_pairs.each do |pair|
puts "Time: #{pair[0]}, Score #{pair[1]}"
end
Time: Monday 5-7PM PST, Score 11
Time: Tuesday 6-8PM PST, Score 12
Time: Thursday 6-8PM PST, Score 14
Time: Tuesday 5-7PM PST, Score 15
Time: Thursday 5-7PM PST, Score 15
Time: Monday 6-8PM PST, Score 22
Time: Wednesday 5-7PM PST, Score 24
Time: Wednesday 6-8PM PST, Score 27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment