• + 0 comments
    def equalStacks(h1, h2, h3):
        x1,x2,x3=sum(h1),sum(h2),sum(h3)
        while True:
            if x1==x2 and x2==x3:
                break
            elif x1>=x2 and x1>=x3:
                val=h1[0]
                x1-=val
                del h1[0]
            elif x3>=x2 and x3>=x1:
                val=h3[0]
                x3-=val
                del h3[0]
            elif x2>=x1 and x2>=x3:
                val=h2[0]
                x2-=val
                del h2[0]
        return x1