day 4 - part 1
This commit is contained in:
parent
e32a98204d
commit
38013bf705
7 changed files with 331 additions and 0 deletions
0
tests/aoc_2024/day4/__init__.py
Normal file
0
tests/aoc_2024/day4/__init__.py
Normal file
10
tests/aoc_2024/day4/test-data
Normal file
10
tests/aoc_2024/day4/test-data
Normal file
|
@ -0,0 +1,10 @@
|
|||
MMMSXXMASM
|
||||
MSAMXMSMSA
|
||||
AMXSXMAAMM
|
||||
MSAMASMSMX
|
||||
XMASAMXAMM
|
||||
XXAMMXXAMA
|
||||
SMSMSASXSS
|
||||
SAXAMASAAA
|
||||
MAMMMXMMMM
|
||||
MXMXAXMASX
|
33
tests/aoc_2024/day4/test_part1.py
Normal file
33
tests/aoc_2024/day4/test_part1.py
Normal 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
|
Loading…
Add table
Add a link
Reference in a new issue