ANEO Sponsored Puzzle discussion

Same reasoning as my last reply.

Look at the light with distance = 13574 and duration = 5sec.
With a speed of 88 you need 3.6 * 13574 / 88 sec to reach it, which is ~555sec.
Since the light starts green and switches every 5sec, you reach it after 111 switches, which means it’s red.

1 Like

Hey,

I got a problem here, I just passed all the tests except number 7, I can’t figure out why it is working with every other test, and not with this one.

Can someone help me?

My answer is 97 for this one…

Thx!

I should create a bot to auto reply to this thread :upside_down_face:

Look at the light with distance = 3000 and duration = 10sec.
With a speed of 97 you need 3.6 * 3000 / 97 sec to reach it, which is ~111sec.
Since the light starts green and switches every 10 sec, you reach it after 11 switches, which means it’s red.

1 Like

Yeah thanks, I guessed that the car reaches a red light, that was pretty obvious, the problem is that I can’t understand why my code is working for every other case and not for this one. Is it a particular case? Is there something special to take care of in this case? :slight_smile:

Just have your program print any value you compute for that light, and compare them to the correct ones. That should tell you where things are going wrong, and also probably why.

Hey, I suceeded the puzzle by using a more higher floatting precision degree, but I think there’s a way to do it with only integers.

I searched 3 days, but I think I miss something. If somebody has time and the will to give me a little course, (in private :slight_smile: ) I would appreciate to learn how to do, or at least, trying to do it with some clues :wink:

Thanks for the help btw,
Bye!

This program fails on the second test case. What am I doing wrong?

Code deleted by moderator.
Please avoid to share complete codes even if not totally functional.

The speeds are given in km/h, but the distances are given in meters. You can’t simply divide one by the other and expect a duration in seconds.

Puzzle was nice but floating was tricky :smile:

Hi,
Thanks for the Puzzle.
I have 100% at the tests in C but when I submit it… the test 2 and 3 don’t pass.

As those test are really easy compare to the few last one, I can’t figure out what is happening differently. I am a bit lost right now if you could give me a hint, it would be nice :slight_smile:

Thanks
PS (already tried to adapt entry variables sizes and limit, setting default values…).

Well all tests ok, but the 2nd validation case is still uncorrect why? any clue? --> only 90% on the validation…

I liked the challenge.

But German highways don’t have traffic lights :wink:

1 Like

When I faced this puzzle I was somehow worried due to the many comments abound roundings, floats, precission, errors, etc…

But if you give it a thought it is so simple. Just need a couple of while/fors… someone called it brut force, but the speed being integer I think it sounds more than it really is. The 9th test is the longest and in Java takes less than 25 miliseconds. Maximum complexity (down to speed 1) is O(maxspeed*lights). All in all below 40 lines of code including the imports, inputs, etc and with clean “airy” code.

Enjoy it!

1 Like

all of the testcases are working for me and I cant think why it wouldn’t work but when I submit, the German Highway case doesn’t work for me and I also cant see what is the input in this case and I have no idea how to fix it.

1 Like

I have the same issue than @noamon

I’ve got the same issue, I suppose it came from the “float precision” but not pretty sure…

You are right, there is something to do with the number 60 but when the script calculets it it gets 59.9999999, you can cheak the rounded result along with the normal result like i did, and it fixed that isue in the tests, but when i submit it dosnt work and i have no idea why

Do traffic lights turn green at the time I get into their zone, or do they work by their durations from t=0?
Because I made a code that assumes they do their rounds from t=0 and it works only for like half of the cases, but when I changed it like they turn green when I get into their zone, the other half worked.

I finally got 100% ! The idea is while one of a light return false to the condition “it’s green”, then decrement the speed by 1. Whereas my previous code I was calculating the new speed with a array of speeds possibilities for each light.

2 Likes

Hello,
Can you tell me does this puzzle work for Python ? I have created a solution but it doesn’t work when it should. for the 5 test case speed 78 should be also a correct answer (i checked with calculator :slight_smile: ) but it says that the speed should be lower. I would appriciate any response. Thank you.