Can Two Elevators with Different Periods Meet on the Same Floor?

  • Thread starter apacz
  • Start date
  • Tags
    Gcd
In summary: Summary: In summary, the conversation discusses a problem with two elevators that only go upwards and stop on specific floors. The elevators are described by two numbers (a, r) where a is the floor they start on and r is the period of stops. The question is how to find the first common floor and period of repeating common floors. The conversation mentions using the Extended Euclidean Algorithm to solve the problem, but there may be other ways as well. The link provided explains more about Diophantine equations.
  • #1
apacz
1
0
Hello everyone,
I have such problem: there are 2 elevators which go only upwards, and stop on only particular floors, each elevator is described by 2 numbers: (a,r) where a is a number of floor on which the elevator starts and r is a number which is a period of elevator's stops. For example, if we have elevator a=1, r=3 then it stops on that floors: 1,4,7,10,13,16,19 and so on and so forth. And now my question: how to find the first common floor of those 2 elevators and the period of repeating common floors. I know that two elevators (first elevator (a1,r1), second elevator (a2,r2) ) have common floor when GCD(r1,r2)|p where p is |a1-a2| so it should be something like that:
a1+x*r1 = a2+y*r2
x*r1 + (-y)*r2 = a2 - a1
I don't know what to do know and if it is a good way of solving that problem, I though about The Extended Euclidean Algorithm which says:
ax+by=gcd(a,b)

So we could try to do something like that:
(a2-a1)/gcd(r1,r2)=k
a2-a1=gcd(r1,r2)*k
x*r1 + (-y)*r2 = gcd(r1,r2)*k
But... afair a,b in extended euclidean algorithm must be integers so we can't divide it by k.
Doest anyone know how to solve it ? Maybe there is some other way to solve it?

Regards,
apacz
 
Physics news on Phys.org
  • #3


Hi apacz, thank you for sharing your problem. This is a classic problem in number theory and can be solved using the greatest common divisor (GCD) algorithm. The GCD algorithm can help us find the greatest common divisor of two numbers, which in this case would be the period of repeating common floors for the two elevators.

To find the first common floor, we can use the fact that the first common floor will be a multiple of both a1 and a2. So, we can start by finding the GCD of a1 and a2, and then check if that GCD is a multiple of r1 and r2. If it is, then that GCD is the first common floor. If not, we can keep multiplying the GCD by the original numbers until we find a common multiple.

For example, let's say the first elevator has (a1,r1) = (1,3) and the second elevator has (a2,r2) = (2,4). The GCD of 1 and 2 is 1, so we check if 1 is a multiple of both 3 and 4. Since it is not, we multiply 1 by 1 and get 1, which is still not a multiple of 3 and 4. We can continue this process until we find a common multiple, which in this case would be 12. So, the first common floor would be 12.

I hope this helps! Let me know if you have any further questions.
 

FAQ: Can Two Elevators with Different Periods Meet on the Same Floor?

1. What is the 2 elevators problem?

The 2 elevators problem refers to a mathematical puzzle in which two elevators are located in a building with n floors. The problem asks for the minimum number of times the elevators need to stop on their way up and down in order to reach all floors.

2. What is gcd in relation to the 2 elevators problem?

gcd stands for greatest common divisor, which is a mathematical concept used to find the largest number that divides evenly into two or more numbers. In the 2 elevators problem, gcd is used to determine the minimum number of stops needed for both elevators to reach all floors.

3. How do you solve the 2 elevators problem using gcd?

To solve the 2 elevators problem using gcd, you first find the gcd of the number of floors and the number of stops for each elevator. Then, you divide the number of floors by the gcd to get the minimum number of stops for each elevator. Finally, you add the two numbers together to get the total minimum number of stops for both elevators.

4. Are there any real-world applications of the 2 elevators problem?

Yes, the 2 elevators problem has real-world applications in elevator scheduling and optimization. By using the concept of gcd, elevator systems can be designed to minimize the number of stops and improve efficiency, especially in high-rise buildings.

5. Is there a general solution for the 2 elevators problem?

Yes, there is a general solution for the 2 elevators problem. The formula for finding the minimum number of stops is n/gcd(m,n) + m/gcd(m,n), where n is the number of floors and m is the number of stops for each elevator. This formula can be applied to any number of floors and stops, making it a general solution for the problem.

Back
Top