Requirements
- Implement a function with inputs
(x1, x2, y1, y2)that returnsYesorNo. - The start position is
(x1, y1)and the target is(x2, y2). - Each move must be either
(x, y) -> (x + y, y)or(x, y) -> (x, x + y). - Determine whether the target can be reached using repeated allowed moves.
Notes
- Preserve the supplied argument order, which lists the two x-coordinates before the two y-coordinates.
- Coordinate bounds, positivity assumptions, and whether a zero-move match is allowed are not specified; clarify those boundary conditions.
- For strictly positive coordinates with a zero-move match permitted, work backward from the target. The larger coordinate must have been increased, so reduce it modulo the smaller while both target coordinates remain strictly above their corresponding start coordinates.
- When one coordinate reaches its start value, accept only if the other target coordinate is at least its start value and their difference is divisible by the fixed positive coordinate. Otherwise reject. This also checks equal start and target positions without a subtraction loop.
- The modulo reduction takes O(log M) time for M = max(x2, y2) and O(1) auxiliary space under unit-cost integer arithmetic. Do not apply this argument to zero or negative coordinates without first establishing their rules.
Preparation
- In 20 minutes, implement the positive-coordinate version and wrap it with the stated argument order and Yes/No output literals.
- In 15 minutes, compare it with bounded forward search on small positive grids, covering identical endpoints, targets below a start coordinate, and a final divisibility failure.

