def trigger_reactions(polymer: str) -> str:
    """
    Triggers the polymer reactions and returns the polymer with all the
    reactions applied.

    The algorithm works by iterating through the polymer and comparing the
    current unit against the next unit. If the next unit is the same as
    the current one but differ in capitalization then they are removed from
    the string and the algorithm starts again but this time one unit earlier
    than the current position.
    """
    i = 0
    while i < len(polymer) - 1:
        if polymer[i].lower() == polymer[i + 1].lower():
            if ((polymer[i].isupper() and polymer[i + 1].islower()) or
                    (polymer[i].islower() and polymer[i + 1].isupper())):
                    polymer = polymer[:i] + polymer[i + 2:]
                    i -= 1
                    continue
        i += 1

    return polymer