I find already my way and solve it
Good puzzle, but i think, this should be mentioned in puzzle , during specific second when light switches from red to green, your vehicle is allowed to move, but when light switches from green to red your vehicle can’t move ahead…
e.g suppose lightDuration is 10 seconds…
so at 10th second, light switches from green to red, so vehicle can’t move ahead,
but at 20th second, light switches from red to green, so your vehicle can move ahead…
sorry, for my bad english…
Hi. In test case number 5, my program gets 79 km/h or 21.8 m/s. why is this the wrong answer?
first light: 300m 30s: 300 / 21.8 = 14s
second light: 1500m 20s: (1500 + 300) / 21.8 = 83s. green light in the following intervals:
0-19, 40-59, 80-99.
third light: 3000m 10s: (3000 + 1500 + 300) / 21.8 = 220s. green light in the following intervals:
0-9, 20-29, 40-49, 60-69, 80-89, 100-109, 120-129, 140-149, 160-169, 180-189, 200-209, 220-229
How are you doing that? I have ugly 1e-5 error comparison.
I did this test in PhP, and I run into some problem when trying my modulo ^^’
German traffic don’t pass ( i’m supposed to find 60 when I have 20 on max speed), but it’s due to my code giving me (60/15) % 2 =1 ! 4%2 should give me 0, damn it…
I also tried bit wise, ($tmpModulo&1)===0, but I have the same problem.
I’m honestly lost as to why this doesn’t work… Also tried intdiv, fmod functions too, by the way…
Thank you kindly to anyone understanding my mistake ^^"