Changement d'ordi! (Non le jour 12 n'est pas terminé)

This commit is contained in:
2023-12-13 08:08:13 +01:00
parent a9d7c6a101
commit 6df1e1c3ec
9 changed files with 109 additions and 6 deletions

35
day13/common.py Normal file
View File

@@ -0,0 +1,35 @@
from dataclasses import dataclass
from collections.abc import Iterator
@dataclass(init=False)
class MirrorField:
_data: list[str]
def __getitem__(self, key: int) -> str:
return self._data[key]
def __len__(self) -> int:
return len(self._data)
def __iter__(self) -> Iterator[str]:
return iter(self._data)
def iter_horizontal(self) -> Iterator[str]:
return iter(self)
def iter_vertical(self) -> Iterator[str]:
x = 0
while x < len(self._data[0]):
the_str = ""
for line in self._data:
the_str += line[x]
yield the_str
x += 1
def find_symetry(self) -> tuple[str, int] | None:
"""Return a tuple indicating a symetry horizontal (h) or vertical (v) and the first row or column index"""
def parse(input_file: str) -> MirrorField:
return MirrorField()

15
day13/example_input.txt Normal file
View File

@@ -0,0 +1,15 @@
#.##..##.
..#.##.#.
##......#
##......#
..#.##.#.
..##..##.
#.#.##.#.
#...##..#
#....#..#
..##..###
#####.##.
#####.##.
..##..###
#....#..#

7
day13/part1.py Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env python3.11
from common import *
def part1(input_file: str) -> int:
return 0

7
day13/part2.py Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env python3.11
from common import *
def part2(input_file: str) -> int:
return 0

23
day13/test.py Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env python3.11
from unittest import TestCase, main
import logging
from common import *
from part1 import part1
from part2 import part2
class DayXTests(TestCase):
def test_parsing(self):
pass
def test_part1(self):
self.assertEqual(405, part1("example_input.txt"))
def test_part2(self):
pass
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG)
main(verbosity=2)