Check if you print an additional line after the answer in those tests.

# ANEO Sponsored Puzzle discussion

**crashtestdummy**#71

Well, Iâd say the key is to keep the speed an integer value. There is no point in computing a floating point speed since the rules ask for discrete values.

It might well be that a speed of 84.34 km/h would allow you to get through all the lights while 84 or 85 km/h wouldnât.

I suppose the validation tests were especially designed to create that kind of situation.

If that can help, the number of values is relatively small.

With 1000 lights and 200 possible speed values you can easily afford a 200x1000 nested loop to match all lights against all possible speed values.

If you can answer the question âat this speed, will that light be green or red when I reach it?â youâre about done.

Thatâs how I solved it using C++. A very basic brute force algorithm.

Slower languages might have trouble with that approach though.

**night0w1**#72

Remember that Javascript automatically switches between floats and integers because of all variables are type agnostic objects. For this puzzle, I suggest trying to remove any and all need for floating points. This means Javascript never gets a chance to calculate imprecise decimal numbers. I think thatâs about as much of a hint as I can give without just telling you.

**night0w1**#73

Youâre correct C++ will have likely beat any interpreted language in speed, but as long as the validation is reasonably simple, I canât imagine any language being unable to validate an an array with only a 1000 values.

I am a little disappointed that I canât see othersâ solutions, and share mine, as with normal puzzles.

Also, on the Python3 version, the lights = {0:[y,x], âŚ} data is backwards â the indices indicated in the initial comments werenât right. It took me a while to work that one outâŚ

**Amakawa**#75

Can someone tell me why the answer of test case 2 is 36 instead of 50?

I donât really understand how we actually do the calculation here.

**AntiSquid**#76

Do it on paper step by step. It will help you visualize much better what the right answer is.

**Amakawa**#77

Alright. I have been able to come up with a solution. Though I failed at test 7 where I found the answer to be roughly 96 instead of 60. I have no idea why.

**smounzeo**#79

There is an error in some testcaess:

7 : expect 60 but 60 is a false result. I check it using excel

9 : except nothing but how should i print nothing

**PiotrZajac**#80

Had the same issue and tried your solution and it worked. Still doesnt know why:P how did you figure out that changing precision will work?

**Tancredi**#82

Made to mess with disagreeable roundings (decreasing the precision of computations just to replicate what I assume are rounding errors in the validation tests).

**X4nax**#83

Hello, I do not understand for the test N Â° 4 and 5, we have the same entries 90 3 3000 10 but the expected result and different 54 for the 4 and 67 for the 5. Could you guide me please ?

**tobakudan**#86

The answers seem to be wrong for some.

Test case 2

Inputs:

50

1

200 10

Expected output:

36

Clearly, the single light can be crossed at the max speed of 50 within 10 seconds (i.e. before it turns red), so 36 is wrong.

Test case 3

Inputs:

90

3

300 30

1500 30

3000 30

Expected output:

90

After 30 seconds we are at 90*30=2700 so by the time we cross the light at 3000 it will be red. So 90 canât be the right answer.

**zizi43**#87

Only the last test failing = 1h

Trying to figure out where the validator has a rounding mistake = 10h.

This was not fun at allâŚ

I had to hack it with a trick like this: x = x if (x%1 > 0.9999) else int(x)

**Altersaber1786**#89

I made it with python after an infinite amount off attempts

However I donât like the way I rounded the floating point numbers to pass this test. I donât think itâs correct in term of math