(init: str, c: str = '')
| 1 | import aoc |
| 2 | |
| 3 | def react(init: str, c: str = '') -> int: |
| 4 | s = [x for x in init if x.lower() != c] |
| 5 | for i in range(len(s)-1, -1, -1): |
| 6 | if i+1 < len(s) and s[i] != s[i+1] and s[i].upper() == s[i+1].upper(): |
| 7 | s.pop(i) |
| 8 | s.pop(i) |
| 9 | return len(s) |
| 10 | |
| 11 | @aoc.main('05') |
| 12 | def main(indata: str) -> tuple[int,int]: |