-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ted Cassirer
committed
Dec 1, 2023
1 parent
47aa48e
commit a49d8c2
Showing
5 changed files
with
37 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
import importlib | ||
from .util import load_module | ||
|
||
from aocd import get_data | ||
|
||
|
||
def plugin(year, day, **kwargs): | ||
module_name = f"aoc_cas.aoc{year}.day{day}" | ||
mod = importlib.import_module(module_name) | ||
data = get_data(year=year, day=day) | ||
def plugin(year: int, day: int, data: str) -> tuple: | ||
mod = load_module(year, day) | ||
return mod.part_a(data), mod.part_b(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import importlib | ||
|
||
from aocd.models import Puzzle | ||
|
||
|
||
def load_module(year: int, day: int): | ||
module_name = f"aoc_cas.aoc{year}.day{day}" | ||
return importlib.import_module(module_name) | ||
|
||
|
||
def test_with_examples(year: int, day: int) -> None: | ||
mod = load_module(year, day) | ||
puzzle = Puzzle(year, day) | ||
print(f"Testing example data") | ||
for example in puzzle.examples: | ||
print(f"\n{example.input_data}\n") | ||
if example.answer_a is not None: | ||
part_a_result = str(mod.part_a(example.input_data)) | ||
correct = part_a_result == example.answer_a | ||
print(f"{'❌✅'[correct]} [Part A] Actual: {part_a_result} - Expected: {example.answer_a}") | ||
if example.answer_b is not None: | ||
part_b_result = mod.part_b(example.input_data) | ||
correct = part_b_result == example.answer_a | ||
print(f"{'❌✅'[correct]} [Part B] Actual: {part_b_result} - Expected: {example.answer_b}\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters