diff options
| -rw-r--r-- | aoc/__main__.py | 6 | ||||
| -rw-r--r-- | day7/__init__.py | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/aoc/__main__.py b/aoc/__main__.py index befa8ec..25a7026 100644 --- a/aoc/__main__.py +++ b/aoc/__main__.py | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | import argparse | 1 | import argparse |
| 2 | import importlib | 2 | import importlib |
| 3 | import os | 3 | import os |
| 4 | from time import perf_counter | ||
| 4 | from typing import List | 5 | from typing import List |
| 5 | 6 | ||
| 6 | 7 | ||
| @@ -34,8 +35,13 @@ if __name__ == '__main__': | |||
| 34 | **dict(args.kwargs) | 35 | **dict(args.kwargs) |
| 35 | ) | 36 | ) |
| 36 | 37 | ||
| 38 | start = perf_counter() | ||
| 37 | print( | 39 | print( |
| 38 | assignment.run( | 40 | assignment.run( |
| 39 | input=assignment.read_input(example=args.example), | 41 | input=assignment.read_input(example=args.example), |
| 40 | ) | 42 | ) |
| 41 | ) | 43 | ) |
| 44 | end = perf_counter() | ||
| 45 | delta = end - start | ||
| 46 | print() | ||
| 47 | print(f'{(delta if delta > 1 else delta * 1000):.3f}{"s" if delta > 1 else "ms"}') | ||
diff --git a/day7/__init__.py b/day7/__init__.py index b3579b7..933b9e0 100644 --- a/day7/__init__.py +++ b/day7/__init__.py | |||
| @@ -37,5 +37,6 @@ class AssignmentTwo(Assignment): | |||
| 37 | @staticmethod | 37 | @staticmethod |
| 38 | def calculate_cost(start, end) -> int: | 38 | def calculate_cost(start, end) -> int: |
| 39 | base_cost = AssignmentOne.calculate_cost(start, end) | 39 | base_cost = AssignmentOne.calculate_cost(start, end) |
| 40 | extra = sum(i for i in range(base_cost)) | 40 | # extra = sum(i for i in range(base_cost)) |
| 41 | return base_cost + extra \ No newline at end of file | 41 | # return base_cost + extra |
| 42 | return int(base_cost * (base_cost + 1) / 2) | ||
