Skip to content

Instantly share code, notes, and snippets.

@idlehands
Created August 10, 2016 17:55
Show Gist options
  • Save idlehands/158b15b546a57d6ba7095b5a8baff56d to your computer and use it in GitHub Desktop.
Save idlehands/158b15b546a57d6ba7095b5a8baff56d to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# by Andronik Ordian
# updated by Jeffrey Matthias
Segment = Struct.new("Segment", :start, :end)
def optimal_points(segments)
points = []
return points if segments.empty?
#write your code here
points
end
if __FILE__ == $0
number_of_segments = gets.chomp.to_i
segments = []
number_of_segments.times do
start, finish = gets.chomp.split.map(&:to_i)
segments << Segment.new(start, finish)
end
points = optimal_points(segments)
puts "#{points.size}"
puts "#{points.join(' ')}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment