Very slick solution!
Maybe most already know... But, parsing the polymer string as a string and using str.replace twice as you do is still much faster than using polymer as a list and using a list-comprehension to remove units (35% slower).
print(min(react(text.replace(p, '').replace(p.upper(), '')) for p in possibilities))
text = list(text)
print(min(react([unit for unit in text if unit not in (p, p.upper())]) for p in possibilities))
We’re a place where coders share, stay up-to-date and grow their careers.
We strive for transparency and don't collect excess data.