MCPcopy Create free account
hub / github.com/AxlLind/AdventOfCode / react

Function react

2018/src/05.py:3–9  ·  view source on GitHub ↗
(init: str, c: str = '')

Source from the content-addressed store, hash-verified

1import aoc
2
3def 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')
12def main(indata: str) -> tuple[int,int]:

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected