ANEO Sponsored Puzzle discussion


First and foremost, The problem is really interesting and keep on innovating.

Although, I was able to pass only 7 test cases, I’m curious to know the algorithm.
So, can you please tell me the way you have constructed.

Keep Innovating

Thank you

Here’s my code; I someone can help me to figure out the bug, please!

// the program below works fine 
// for all test cases except 
// Test Cases: 6,9,10
// Reason: for 6; output: 48 but answer:49
// Reason: for 9; output: 0 but answer:6
// Reason: for 10; output: 88 but answer: 74

import sys
import math

//max_speed_original km/h
max_speed_o = int(input())
light_count = int(input())

// max_speed m/s
max_speed = max_speed_o * 5/18 

dur = []  //duration
dist = [] //distance

// store the values in a list
for i in range(light_count):
    distance, duration = [int(j) for j in input().split()]

// min time for the closest light
t_min_i = dist[0]/max_speed

// approx int val
t = math.floor(t_min_i)

while True:
    isGreen = False
    #iterate through each
    for i in range(light_count):
        // using point slope method to find the intercept
        if int((dist[i]/dist[0]*t)//dur[i]) % 2 == 0:
            isGreen = True
            isGreen = False

    if isGreen:break
    t += 1
if isGreen:
    //s = speed
    s = (dist[0]/t)
    // check if speed > max_speed m/s
    s = max_speed if s>max_speed else s
    //print('Floor km/h:',math.floor(s* (18/5)))
    s = math.floor(s* (18/5))
    // check if speed > max_speed km/h
    s = max_speed_o if s>max_speed_o else s
//-----------End -----------


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:


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.


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