0 out of 464 challenges solved

Sum of Per-Digit Difference

Write a Python function `digit_distance_nums(n1, n2)` that calculates the sum of the absolute differences of corresponding digits between two integers `n1` and `n2`.

#### Example Usage:
```python [main.nopy]
print(digit_distance_nums(123, 256))  # Output: 7
print(digit_distance_nums(1, 2))      # Output: 1
print(digit_distance_nums(23, 56))    # Output: 6
```

#### Explanation:
- For `123` and `256`: The differences are `|1-2|=1`, `|2-5|=3`, `|3-6|=3`. Sum = `1+3+3=7`.
- For `1` and `2`: The difference is `|1-2|=1`. Sum = `1`.
- For `23` and `56`: The differences are `|2-5|=3`, `|3-6|=3`. Sum = `3+3=6`.

#### Constraints:
1. The function should take two integers `n1` and `n2` as input.
2. If the integers have different lengths, pad the shorter number with leading zeros.
3. Return the sum of the absolute differences of each digit.
def digit_distance_nums(n1, n2):
    """
    Calculate the sum of the absolute differences of corresponding digits between two integers.

    Args:
        n1 (int): The first integer.
        n2 (int): The second integer.

    Returns:
        int: The sum of the absolute differences of corresponding digits.
    """
    # Convert numbers to strings
    # Pad the shorter number with leading zeros
    # Calculate the absolute differences of corresponding digits
    # Return the sum of the differences
    pass