day 4 - part 1

This commit is contained in:
Stanislas Jouffroy 2024-12-04 15:52:43 +01:00
parent e32a98204d
commit 38013bf705
7 changed files with 331 additions and 0 deletions

View file

@ -0,0 +1,33 @@
from pathlib import Path
from aoc_2024.day4 import part1
import numpy as np
def test_find_all():
data_str = """MMMSXXMASM
MSAMXMSMSA
AMXSXMAAMM
MSAMASMSMX
XMASAMXAMM
XXAMMXXAMA
SMSMSASXSS
SAXAMASAAA
MAMMMXMMMM
MXMXAXMASX"""
data = np.full((10, 10), "")
i, j = 0, 0
for character in data_str:
if character != "\n":
data[i, j] = character
j += 1
else:
i += 1
j = 0
assert part1.find_xmas(data) == 18
def test_main():
data_file = Path(__file__).parent / "test-data"
assert part1.main(data_file) == 18