Understanding the inputs

This is probably going to sound stupid, but I’m having trouble wrapping my head around the way information is given for a lot of the tasks.

This puzzle as an example: https://www.codingame.com/ide/puzzle/aneo

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.

1 Like

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 :slight_smile:

You are welcome. Practise more you will discover more variety ways to store and organize data to meet different processing needs.

1 Like