-
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.
2023: fix some bugs exposed by additional inputs
Using the randomly-generated inputs from https://questionable.engineering/posts/aoc-inputs-2023/
- Loading branch information
Showing
5 changed files
with
60 additions
and
7 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 |
---|---|---|
|
@@ -5,5 +5,6 @@ | |
*/profiling/ | ||
*/perf.data | ||
*/perf.data.old | ||
/2023/unofficial-aoc2023-inputs/ | ||
# clangd cache | ||
*/.cache/ |
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
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,47 @@ | ||
import json | ||
import subprocess | ||
import sys | ||
|
||
|
||
def test_on_input(day: int, input_name: str, expected_answers: tuple[int, int]) -> bool: | ||
result = subprocess.run( | ||
[ | ||
f"build/fast/day{day:02d}", | ||
f"unofficial-aoc2023-inputs/day_{day:03d}/{input_name}", | ||
], | ||
check=False, | ||
text=True, | ||
stdout=subprocess.PIPE, | ||
) | ||
if result.returncode != 0: | ||
print(f"Day {day}, {input_name}: exited with status {result.returncode}") | ||
return False | ||
answers = tuple(map(int, result.stdout.splitlines(keepends=False))) | ||
correct = True | ||
for i in range(2): | ||
if not isinstance(expected_answers[i], int): | ||
continue | ||
if answers[i] != expected_answers[i]: | ||
print( | ||
f"Day {day}, {input_name}: part {i+1} incorrect; expected {expected_answers[i]}, got {answers[i]}" | ||
) | ||
correct = False | ||
return correct | ||
|
||
|
||
def main() -> int: | ||
subprocess.run(["make", "-j", "fast"], check=True) | ||
failure_count = 0 | ||
for day in range(1, 26): | ||
with open(f"unofficial-aoc2023-inputs/day_{day:03d}/solutions.json", "r") as f: | ||
solutions = json.load(f) | ||
for input_name, answers in solutions.items(): | ||
if not test_on_input( | ||
day, input_name, (answers["part_one"], answers["part_two"]) | ||
): | ||
failure_count += 1 | ||
return failure_count | ||
|
||
|
||
if __name__ == "__main__": | ||
sys.exit(main()) |