QWorder simplifies strings representing sequences of quantum gates.
pip install qworder
Define a word "HXTTXZXH" with positive sign, and cascade reduce it with
w = Word("HXYYXZXH", True) c = Cascader() print(w) print(c.cascade_word(w))
The output will be:
['HXYYXZXH', True] ['Y', True]