0 out of 464 challenges solved

Integer Equation Solver

Write a Python function `find_solution(a, b, n)` that takes three integers `a`, `b`, and `n` as input. The function should return a tuple `(x, y)` of integers such that:

\[ a \cdot x + b \cdot y = n \]

If no such integers exist, the function should return `None`.

#### Examples
```python [main.nopy]
find_solution(2, 3, 7)  # Output: (2, 1)
find_solution(4, 2, 7)  # Output: None
find_solution(1, 13, 17)  # Output: (4, 1)
```

#### Constraints
- `a`, `b`, and `n` are integers.
- The function should find at least one valid solution if it exists.
- If multiple solutions exist, returning any one of them is acceptable.
def find_solution(a, b, n):
    """
    Find integers x and y such that a * x + b * y = n.

    Args:
        a (int): Coefficient of x.
        b (int): Coefficient of y.
        n (int): Target value.

    Returns:
        tuple: A tuple (x, y) if a solution exists, otherwise None.
    """
    # Iterate to find a solution
    # Placeholder for implementation
    pass