'Unable to find the minimum number of vertical and horizontal cuts due to the following error

I am writing a code to find the minimum number of horizontal and vertical cuts to form a square. I am generating 'cannot unpack non-iterable NoneType object' error, does this have anything to do with the functools package? If not, what changes can I make otherwise?

import functools

@functools.lru_cache
def get_C(height, width):
    if height == width:
        return("",0)
    cold = height*width
    for tryleftlen in range(1, width//2+1):
        leftcuts, leftminimum = get_C(height, tryleftlen)
        rightcuts, rightminimum = get_C(height, width-tryleftlen)
        ctry = 1+leftminimum +rightminimum
        if ctry < cold:
            minimumcut = 'V{0}x{1} --> {0}x{2} {0}x{3}\n'.format(height,width,tryleftlen,width-tryleftlen)
            minimumcut += leftcuts + rightcuts
            cold = ctry
        for trybotlength in range(1, height//2+1):
            topcuts, topminimum = get_C(height-trybotlength, width)
            botcuts, botminimum = get_C(trybotlength, width)
            ctry = 1+ botminimum + topminimum
            if ctry < cold:
                minimumcut = 'H{0}x{1}-->{2}x{1} {3}x{1}\n'.format(height,width,trybotlength.height-trybotlength)
                minimumcut += botcuts + topcuts
                cold = ctry 
        return (minimumcut, cold)
    
if __name__ == '__main__':
    C = get_C(6,7)
    C = get_C(12,13)
    print(C[0])



Solution 1:[1]

oops, it was a small syntax error and nothing to do with import functools. at this line:

 minimumcut = 'H {0}x{1} --> {2}x{1} {3}x{1}\n'.format(height,width,trybotlength,height-trybotlength)

Thank you.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sss_coder