ANEO Sponsored Puzzle discussion


#67

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


#69

i didnt even understood the problem , someone plz explain me


#70

Hints please? I am starting to practice javascript through CG


#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.


#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.


#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.


#74

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…


#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.


#76

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


#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.


#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


#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?


#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).


#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 ?


#84

Test 4 Input:
90
3
300 10
1500 10
3000 10

Test 5 Input:
90
3
300 30
1500 20
3000 10


#85

thanks for the answer i will look at this carefully.


#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.


#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)


#88

What language ?


#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