ANEO Sponsored Puzzle discussion

That depend of the way you take the problem…
In my solution I use no ceil(), no floor() and no round(), so no precision issues… :wink:
Is up to you to find how to do. :slight_smile:

1 Like

Yes, that was a confuse when I wrote this question, but in the problem I wrote “valido” always, but I dont know why I passed all test but it gives me failed the 6th and 7th tests.
“The following validators differ from the puzzle test cases to prevent hard coded solutions. This is why you can have some fails here even if all of the tests provided in the IDE have been successfully passed.”.

I dont know what’s the “hard coded solution”. Is there another way to do this with for loops?

A hard coded solution is a solution that solves only a list of given tests without dealing with the general problem.
It’s like 'if the input is …, output … ’

I suposse it, but, i dont know why my solution is a hard coded solution, I think it solves all the cases (although it costs more time)

The message says that the validators differs from the tests to avoid hard coded solutions, not that your solution is hard coded. There’s probably cases that your code doesn’t handle and that appears in validators and not in tests…

1 Like

i: 0, speed: 78, dist: 300, sec: 13.846153846154, duration: 30, modulo: 13, seconds_lasted: 0
i: 1, speed: 78, dist: 1500, sec: 69.230769230769, duration: 20, modulo: 3, seconds_lasted: 13.846153846154
i: 2, speed: 78, dist: 3000, sec: 138.46153846154, duration: 10, modulo: 1, seconds_lasted: 83.076923076923

Hello everyone! Why answer 78 is wrong in 5th test “Unsettled country road”? Expected 67.
I used bruteforce solution from 90 descending.

All lights should be green. Speed is 21.6(1) m/s.

First light is in 13.846153846154 sec from start.
Second is in 83.076923076923 sec from start.
Third is in 221,538461538 sec from start.

221,538461538 % (duration * 2) = 221,538461538 % (10 * 2) = 1. That is green, right?

First : 7415 coders solved it , so no problem with tests.

Second: i don’t understand values in your post
13.84 % 30 = 13 ok
69 % 20 = 3 not (unless you do (13.84+69.23) % 20
distances are given from start and not between lights … there is a problem

Third: your last formula … forget it because of second point …

2 Likes

Exactly! Distances are from start. Thank you!

So, for people having problems with this puzzle, what prevented me from getting the correct answer was misunderstanding what they meant by “when you enter the area all lights are green.” They mean each individual area and not the start of the road before the first light.

Each new road sets the next light to green and starts the timer for switching.

I see some people in the comments making the same mistake as me and thinking all lights start alternating at the same time.

So, I used a brute-force approach and it works as expected without any timeouts, however I get “Rain of Traffic Lights” and “Light String” (Cases 8 and 9) incorrect, though everything else is fine. Does anyone have some pointers as to what could be an issue or an edge case that could make a brute force approach fail.

My code basically goes: for every speed equal to or less than the max speed, check all lights to see if they are green when I get to them, break if that is true, continue if it is false.

What could be an issue? I don’t really have a problem with any floating point rounding or anything.

I used the exact same approach.
8 and 9 differs from the other tests using a lot of lights.

1 Like

I’m curious.
Why 1st test case max speed is 50kmh, when 3rd case max speed is 90kmh?
I guess it’s revolves around ‘speeding’ but there’s nothing specific in puzzle details…

I mean, for the first case, if we enter the area and first signal is 200m away and lights green - then, along the details, we can cross area with 90kmh (which is allowed, I guess) = 25m/s in 8 seconds. Almost twice faster than 15 seconds before light switches.

The first line in the input is the maximum speed allowed. In the first testcase it’s 50, so you can’t drive faster.

1 Like

Doesn’t make any sense to me, practically, and it would mean the development tests are working with both interpretation, but not the submission tests … I definitely find this problem poorly designed :confused:

There’s no interpretation to have.
“All traffic lights turn green at the same time as you enter the area.” mean that all the lights just passed to green when you enter the road section. After that they individually alternate from green to red and vice versa every [duration] seconds.

1 Like

Some notes about this puzzle. I got it at 100%.Code on C++. All my variables was “Double”, and 9 test didn’t pass. But in Clion all right. One guy above proposed instead “Double” use “Float” - it’s works nice.
And another remark, “green” <= “red” < “green”. It’s not obvious, but the “Warning” says exactly that.

Yeah, it doesn’t really make sense that way. All lights do start out green at the beginning of the testcase and start alternating, not when you pass the previous light. I was able to pass this puzzle with the initial interpretation.

The problem is definitely poorly designed, or at least poorly worded. But all the tests are successful for me with my interpretation. When I worked with the initial interpretation that all lights started alternating at the start of the first section, not all the test cases worked for me and trying the test cases by hand supported that not all cases were working this way.

That’s your point of view…
But since only you have it, perhaps it would be interesting to consider that your code don’t do what you think it do…

I was stating my results. Results aren’t the same thing as a point of view lol. All test cases pass for me — statement of fact. Saying how I understood the question is also not a point of view.

Also, considering that codingame runs the tests and tells you that you have passed 100% of them, I am pretty sure it does what I think it does — i.e. passes all tests.

Saying that I think the question is poorly worded is a point of view, but it seems to be one that is shared and visibly demonstrable considering we are having this discussion at all.

It seems Unlikely that something would pass all tests and be labeled as 100% correct if it did not do what I thought it did.