ANEO Sponsored Puzzle discussion

well, from third attempt I hacked through it: the problem is that condition “you can’t cross light on the second it turns red” does not define precision of time, i.e. if you reach light at e.g. time=14.9999998s tests could count it as 15s. Maybe it is just implementation problem of the tests.
In fact, it seems that actual challenge is not (only) to solve the task, but to get over the non precise requirements :wink:

1 Like

No, the challenge is to find how to solve it without rouding issues so you don’t accuse the game instead of accusing your solution.

1 Like

Thanks. I didn’t read carefully and got only 2 tests right because I thought the distance to next light was in the same unit as the speed.

I’m confused, I can’t solve the second testcase. I have tried doing unit conversions, which just give me the exact same result. I exported some variables:
Distance: 200
Speed Limit: 50
Arrival Time: 4
Duration: 10
Ideal Speed: 50
It says expected was 36km/h. But if the Duration was 10 seconds, and I get there in 4, how would 36 be considered the answer?

4 seconds to travel 200 meters.

If I’m not mistaken, that’s 50 meters per second. So 3 km / minute. So 180km / hour

That’s fast :smiley:

I have the same answer.

Hi, I am new in this site. I want working with this site but i cannot becouse i am not understanding. please help me. thenks.

You are given:
Speed - X Killometer per Hour
Distance - Meters
Duration - Seconds
So for example 10Km/H is 2.7778 ms so we will travel 200 meters in 71 Seconds…
Always read what are you given, or you will stuck with wrong data.

so my program includes this specific calculation: 1.2/6.0/(1/180). When i punch it into a calculator it turns out to be 36 (which means my program works). However on codingame (I’ve tried on another puzzle), it outputs infinity instead and now I’m stuck on the light string test while having passed all but another test. Is this a problem on my side?

Hello! Need your help. Who knows what example 10 test?

With the expression (1/180) you are dividing two integers, and the result will also be an integer. (1/180) will evaluate to an integer value 0.

Replace it with (1.0/180.0) and it will probably work.

how can i ask my question
i have a doubt in this puzzle
if speed is already given what is needed to be done

i don’t understand anything

the puzzle says to output the maximum speed but the outputs are the same or less than the riginal speed pls explain

The goal is to find the maximum speed (off speeding) that will allow you to cross all the traffic lights to green.

At maximum speed, you’ll probably pass a traffic light while it’s red. That’s why you need to slow down so you pass all traffic lights to green.

Dear all,

I passed all the tests except the last one with 100 lamps.
In this last case for the supposedly “winner speed” given in the solution my method gives only 86 green lamps out of 100. I wonder why?
I convert the initial int value of distance into double type km and the duration in double type hour value.
My method in Java:
The “outer” loop, which is already given, is that of the lamps.
I create an array speed[] which represents all the int speeds from 1 to max. speed (all the values of this array are 0 at the beginning, only the indexes “show” the speed, not their value), and with the “inner” loop I go through all the speeds for each lamp. If the lamp is green for the speed “z” then speed[z] increases with 1.
Whether a lamp is green upon the arrival of the car, I calculate like this.

  1. If speed X duration ≥ distance, then its ok, green.
  2. z is an even integer increasing in a loop (2, 4, 6, etc). If z X speed X duration < distance and distance < (z+1) X speed X duration, also then its green.

At the end I search for the biggest value in speed[] starting from max speed going backward to the lowest.
Where can there be a mistake?

I am just about to begin solving this challenge. At first I thought I understood the problem but printing out some test cases got me very confused. Perhaps I am a little thick today, I am finding it hard to understand the problem even though I am a native english speaker.

In test case 1, distance to the traffic light is 200m and the light switches every 15 sec. The answer is 50 km/hr because anything less than this it will be unable to cross the light before it tuns red (by the way, shouldn’t it be 48 km/hr?).

But in test case 2, distance to traffic light remains the same but the period of light switching reduces to 10 sec. Shouldn’t the speed then be greater than 50km/hr? How is it the answer is 36? Kindly help.

Because the maximum allowed speed for test case 2 = 50 => can not cross the light in 1st duration (green) => coss the light in [2k,(2k+1)] * duration
speed = 36km/h = 10m/s => After 10s green + 10s red => 10 *20 = 200 = distance. But i think 20th second is still in red duration. I passed this test but when i submit it failed
sorry for my english

You don’t have to pass the light before it turns red. You have to pass the light when it is green.

In other words, it is allowed for the light to turn red, as long as it is green again when you pass it.

1 Like

aah, I get it now. Thanks very much for clearing that up. I went back to read the problem statement again with this knowledge and it still wasn’t clear. :stuck_out_tongue: