I… havent stored it in m/s but calculated with it in m/s… just needed floor function and get the right interval when deciding if there is a green or red
Btw, is there a way how to calculate the right answer without trying all speeds till you found the one that works?
Where can you post your solution and see other’s solution?
My python code was able to pass all the test cases given, but once I submit the code it shows that the code failed validators 06 and 07. Is there anyway that I can know what my problem is through the IDE? Or is it just a bug?
I suspect you’re running into the same issue I had with long decimal places.
Simply reduce this example: Before: [50.1234567890] After: [50.123]
Had the same issues. Test cases 8 and 9 expect you to use a speed at which you would cross some of the lights .000000000001 seconds before they turn green. While it’s common practice to have a tolerance for floating-point comparison it makes little sense to me in this context.
solved the question by looping all the speed value in km/h in integer form (looping in descending order, of course)
some one asked whether there is a “non-brute force” method. Personally, i think the nature of this question is similar to those “p x np problems”, where it is easy to validate the possible solution, but rather impossible to construct a possible solution.
Yes there is. Iterate through all lights, whenever the current speed is too fast for one calculate the speed you would need to run it as soon as it turns green again, then repeat.
[no full solution, please]
Hi, I am trying to solve this puzzle. Regarding the last test, I have the impression that 89 would be a right answer, whereas 74 is expected. Could you have a look and explain me why 89 doesn’t fit?
Regarding the rest of the tests, i am getting the expected results when running my code in Visual Studio Code& Dot Net Core Framework, but results are on the site.
I passed the test but i want to know if there is a solution with time complexity < O(n^2) ?
What is n?
I solved it in O(maxSpeed * lightCount).
n = lightCount
I also have O(lightCount^2), which I think is better then maxSpeed * lightCount
lightCount <= 9999
maxSpeed <= 200
so maxSpeed * lightCount < lightCount^2
Thus my solution is faster on big inputs (assuming that I don’t have a huge constant that you don’t have).
solving with bruteforce with external loop on speed and internal loop on lights is too easy.
But I think this is not the spirit of the problem, I feel like having cheated.
I’m trying to do it with a more sophisticated method, but I got a 90% because of Validator7 that refused to pass
Solution requires answer be an integer and running this “final” integer answer again through the algorithm is necessary to ensure it passes (particularly the last one - 88.848 = 88). Running 88 through the algorithm produces the correct answer 74. Otherwise, I had no problems working with floats.
I’m new on codingGame and more generally in programming. I passed 50% of the tests for this puzzle (1, 2, 3, 4 and 9). Is there a way to know was is exactly tested by each test? It could help me understand why i didn’t pass the other 50%. I have no clues and it’s a bit frustrating. Also are the solutions to the puzzles available somewhere?
The tests in IDE are available in the IDE. (Three lines button in the test cases panel)
The validating tests (after submitting your code) are not available.
If you fail them, here’s my advice:
- check the title of the validator that fails; it can be a hint for your mistake (I didn’t check for the Aneo puzzle)
- read carefully the statement another time and skim the related forum thread; someone might have had the same issue and had it resolved.
- if you’re still stuck, I can help and give you the validator.
and welcome to CodinGame
Thanks! i could validate all the tests!
This has to be the worst excuse for a puzzle I had the displeasure of solving on this site. I reluctantly took the effort to complete it anyway since CG won’t allow me to rate it otherwise.
There is nothing educational or informative about this puzzle. You just have to recreate arbitrary choices/assumptions by the party who implemented the validators. Now we arrived at ‘use a random arrangement of float precision and integers’ and somehow along the way it also made sure double precision doesn’t agree with their incorrect answers. (You are in fact crossing lights before they turn green in the expected answers.)
This arbitrary choice also explains problems for people using languages like Python because it automatically and often implicitly uses double precision number representations which makes it frustrating to obtain a good float precision. (Since you have two unknowns: figure which step needs to be float and how precise should that float be.)
It’s kind of uncomfortable that you chose this to represent a partner business’ presence on the site as well.
This question has been maybe already posted, but I didn’t see it (I’ve read quite fast other answers ).
Python3 test 1 & 2 do not pass becacuse it expects ‘Nothing’. In other languages as Java or even Python2 this is not the case. Thank you anyway! This is a great platform !