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

Function decorator

2018/src/aoc.py:9–18  ·  view source on GitHub ↗
(solver: AocSolution)

Source from the content-addressed store, hash-verified

7
8def main(day: str) -> Callable[[AocSolution], Callable[[],None]]:
9 def decorator(solver: AocSolution) -> Callable[[],None]:
10 def timer() -> None:
11 indata = (INPUT_DIR / f'{day}.in').read_text()
12 start = time.time()
13 p1, p2 = solver(indata.rstrip('\n'))
14 elapsed = int((time.time() - start) * 1000)
15 print(f"Part 1: {p1}")
16 print(f"Part 2: {p2}")
17 print(f"Time: {elapsed}ms")
18 return timer
19 return decorator

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected