how do i split an integer N into two non-empty parts by cutting it between any pair of consecutive digits. such that pair of integers A, B is created [closed]

Expected input:

n = 1234

Expected output:

A = 1
B = 234

or

A = 12
B = 34

or
A = 123
B = 4

I am trying to find the minimum absolute difference between these pairs.

Answer

In general the arithmetic way of cutting an integer is with integer division and modulo arithmetic:

def cut(n: int, places: int):
    d = 10 ** places
    return divmod(n, d)  # equivalent to (n // d, n % d)

A, B = cut(1234, 1)