In this Kata, you will be given two numbers, n and k and your task will be to return the k-digit array that sums to n and has the maximum possible GCD.
For example, given `n = 12, k = 3`, there are a number of possible `3-digit` arrays that sum to `12`, such as `[1,2,9], [2,3,7], [2,4,6], ...` and so on. Of all the possibilities, the one with the highest GCD is `[2,4,6]`. Therefore, `solve(12,3) = [2,4,6]`.
Note also that digits cannot be repeated within the sub-array, so `[1,1,10]` is not a possibility. Lastly, if there is no such array, return an empty array.
More examples in the test cases.
Good luck!
def solve(n,k):
    psum = (k * (k+1)) / 2
    if n >= psum:
        min_int = n // psum
        while min_int > 0:
            if n % min_int == 0:
                return populate(n,min_int,k)
            min_int -= 1
    return []

def populate(n,s,k):
    output = []
    m = n
    for i in range(1, k):
        output.append(i*s)
        m -= i*s
    output.append(m)
    return output

def solve(n,k):
    psum = (k * (k+1)) / 2
    if n >= psum:
        min_int = n // psum
        while min_int > 0:
            if n % min_int == 0:
                return populate(n,min_int,k)
            min_int -= 1
    return []

def populate(n,s,k):
    output = []
    m = n
    for i in range(1, k):
        output.append(i*s)
        m -= i*s
    output.append(m)
    return output
