It tells me that I’m provided with the speed and the lightCount. Each light has a duration and distance. How do I go about accessing the duration and distance parameters?
I’ve got a decent idea of the logic and how to solve the problem, I’m just not so sure about the actual inputs. I’m using Ruby at the moment
Isn’t it already provided by the auto-generated code?
speed = gets.to_i
light_count = gets.to_i
// create an array
light_count.times do
distance, duration = gets.split(" ").collect {|x| x.to_i}
// put distance and duration into array
end
// access data in array
If you are not sure how to access data given in a loop, see the above comments.
Thanks! I realised I definitely AM an idiot. For some reason I thought they were doing something fancy and it was already in an array of some kind, instead of me actually having to do that bit.
Always knew there would be an obvious solution. Thanks for explaining it