[Solved] How to generate a 12 digit number, but all the digits summed together must equal 55?


Print them recursively:

def gen_num(trailing, depth, left):
    if depth < 11:
        for i in range(max(0,min(10, left))):
            gen_num(trailing*10+i, depth+1, left-i)
    elif depth == 11:
        if left < 10:
            print trailing*10+left

for i in range(1,10):
    gen_num(i, 1, 55-i)

solved How to generate a 12 digit number, but all the digits summed together must equal 55?