# Equation with modulus

mfb
Mentor
A classical x-y-question. We wasted 25 posts discussing what your question could mean - and it turns out that it is not even your problem. It is your attempt to solve the problem, and it is unclear if that approach can work at all.
I wrote my equation to know if when the car cross the traffic light the traffic light is green or red.
From the problem website I guess 200 is the distance and 15 is the period. What do you expect from solutions to the equation? Note that just a few specific values of x will solve it, but a large range of speeds will work for a given traffic light.

A classical x-y-question. We wasted 25 posts discussing what your question could mean - and it turns out that it is not even your problem. It is your attempt to solve the problem, and it is unclear if that approach can work at all.From the problem website I guess 200 is the distance and 15 is the period. What do you expect from solutions to the equation? Note that just a few specific values of x will solve it, but a large range of speeds will work for a given traffic light.
I thought that I can find the ideal speed with this equation where x is the speed :

$$\frac{distance}{x duration} mod 2 = 0$$

distance is the distance from the start. Distance and duration are integers.

mfb
Mentor
Why mod 2 and then equals 0?
The highest speed allowed by a single traffic light would be "as fast as the car can go".
The lowest speed to still catch the first green light is distance/duration.
What is the fastest speed to catch the second green light?
What is the lowest speed to catch the second green light?
Can you construct allowed speed intervals from that?

Why mod 2 and then equals 0?
The highest speed allowed by a single traffic light would be "as fast as the car can go".
The lowest speed to still catch the first green light is distance/duration.
What is the fastest speed to catch the second green light?
What is the lowest speed to catch the second green light?
Can you construct allowed speed intervals from that?

I want to do an interval. But I thought that I can find speeds for the interval with that. Mod 2 is here to know if the traffic light is green or red.

mfb
Mentor
Mod 2 is here to know if the traffic light is green or red.
How exactly do you expect this to work?