def Collapse(polymer):
    i = 1
    while (i < len(polymer)):
        if Reacts(polymer[(i - 1)], polymer[i]):
            del polymer[(i - 1)]
            del polymer[(i - 1)]
            i = (i - 2)
        i += 1
    return polymer
def Collapse(polymer):
    i = 1
    while (i < len(polymer)):
        if Reacts(polymer[(i - 1)], polymer[i]):
            del polymer[(i - 1)]
            del polymer[(i - 1)]
            i = (i - 2)
        i += 1
    return polymer