Refactor code for API (#3)
Co-authored-by: Mikael CAPELLE <mikael.capelle@thalesaleniaspace.com> Co-authored-by: Mikaël Capelle <capelle.mikael@gmail.com> Reviewed-on: #3
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
import sys
|
||||
from typing import Any, Iterator
|
||||
|
||||
line = sys.stdin.read().strip()
|
||||
|
||||
floor = 0
|
||||
floors = [(floor := floor + (1 if c == "(" else -1)) for c in line]
|
||||
from ..base import BaseSolver
|
||||
|
||||
|
||||
print(f"answer 1 is {floors[-1]}")
|
||||
print(f"answer 2 is {floors.index(-1)}")
|
||||
class Solver(BaseSolver):
|
||||
def solve(self, input: str) -> Iterator[Any]:
|
||||
floor = 0
|
||||
floors = [(floor := floor + (1 if c == "(" else -1)) for c in input]
|
||||
|
||||
yield floors[-1]
|
||||
yield floors.index(-1)
|
||||
|
Reference in New Issue
Block a user