diff --git a/doc/concepts.md b/doc/concepts.md new file mode 100644 index 00000000..943a9ca2 --- /dev/null +++ b/doc/concepts.md @@ -0,0 +1,98 @@ + +| Day | Concepts | +| --- | --- | +| 2016_13 | A*, binary, path finding | +| 2017_01 | circular list, rule matching, sum | +| 2017_02 | combinations, division, maximum, minimum, sum | +| 2017_03 | exotic coordinate system, grid, manhattan distance | +| 2017_04 | rule matching, string | +| 2017_10 | ascii, hexadecimal, knot hash, xor | +| 2017_14 | ascii, bfs, binary, grid, group finding, hexadecimal, knot hash, xor | +| 2017_21 | dihedral group of the square, grid | +| 2020_20 | dihedral group of the square, grid, pattern recognition, sea monsters | +| 2021_15 | A*, grid, int grid, path finding | +| 2022_01 | sum | +| 2022_02 | simulation | +| 2022_03 | ascii, set operations | +| 2024_01 | counter, difference, transpose | +| 2024_02 | increasing/decreasing | +| 2024_03 | regex | +| 2024_04 | char grid search, grid | +| 2024_05 | custom sort, sort | +| 2024_06 | grid, grid navigation | +| 2024_07 | recursion | +| 2024_08 | combinations, geometry, grid | +| 2024_09 | large list | +| 2024_10 | grid, int grid, path finding | +| 2024_11 | memoization, recursion | +| 2024_12 | char grid, geometry, grid, polygons | +| 2024_13 | geometry, linear equations | +| 2024_14 | christmas tree, geometry, loop detection, pattern recognition | +| 2024_15 | char grid, grid | +| 2024_16 | char grid, grid, path finding | +| 2024_17 | bit shifting, reverse engineering, virtual machine | +| 2024_18 | binary search, char grid, grid, path finding | +| 2024_19 | memoization, recursion | +| 2024_20 | char grid, grid, manhattan distance, path finding | +| 2024_21 | memoization, recursion | +| 2024_22 | large list | +| 2024_23 | graph, graph cliques | +| 2024_24 | binary logic, simulation | +| 2024_25 | char grid, grid | + + + +| Concept | Days | +| --- | --- | +| A* | 2016_13, 2021_15 | +| ascii | 2017_10, 2017_14, 2022_03 | +| bfs | 2017_14 | +| binary | 2016_13, 2017_14 | +| binary logic | 2024_24 | +| binary search | 2024_18 | +| bit shifting | 2024_17 | +| char grid | 2024_12, 2024_15, 2024_16, 2024_18, 2024_20, 2024_25 | +| char grid search | 2024_04 | +| christmas tree | 2024_14 | +| circular list | 2017_01 | +| combinations | 2017_02, 2024_08 | +| counter | 2024_01 | +| custom sort | 2024_05 | +| difference | 2024_01 | +| dihedral group of the square | 2017_21, 2020_20 | +| division | 2017_02 | +| exotic coordinate system | 2017_03 | +| geometry | 2024_08, 2024_12, 2024_13, 2024_14 | +| graph | 2024_23 | +| graph cliques | 2024_23 | +| grid | 2017_03, 2017_14, 2017_21, 2020_20, 2021_15, 2024_04, 2024_06, 2024_08, 2024_10, 2024_12, 2024_15, 2024_16, 2024_18, 2024_20, 2024_25 | +| grid navigation | 2024_06 | +| group finding | 2017_14 | +| hexadecimal | 2017_10, 2017_14 | +| increasing/decreasing | 2024_02 | +| int grid | 2021_15, 2024_10 | +| knot hash | 2017_10, 2017_14 | +| large list | 2024_09, 2024_22 | +| linear equations | 2024_13 | +| loop detection | 2024_14 | +| manhattan distance | 2017_03, 2024_20 | +| maximum | 2017_02 | +| memoization | 2024_11, 2024_19, 2024_21 | +| minimum | 2017_02 | +| path finding | 2016_13, 2021_15, 2024_10, 2024_16, 2024_18, 2024_20 | +| pattern recognition | 2020_20, 2024_14 | +| polygons | 2024_12 | +| recursion | 2024_07, 2024_11, 2024_19, 2024_21 | +| regex | 2024_03 | +| reverse engineering | 2024_17 | +| rule matching | 2017_01, 2017_04 | +| sea monsters | 2020_20 | +| set operations | 2022_03 | +| simulation | 2022_02, 2024_24 | +| sort | 2024_05 | +| string | 2017_04 | +| sum | 2017_01, 2017_02, 2022_01 | +| transpose | 2024_01 | +| virtual machine | 2024_17 | +| xor | 2017_10, 2017_14 | + diff --git a/doc/concepts.yml b/doc/concepts.yml new file mode 100644 index 00000000..aa44e0e5 --- /dev/null +++ b/doc/concepts.yml @@ -0,0 +1,190 @@ +concepts: + year: + - 2016: + day: + - 13: + tags: + - path finding + - A* + - binary + - 2017: + day: + - 1: + tags: + - circular list + - sum + - rule matching + - 2: + tags: + - minimum + - maximum + - division + - sum + - combinations + - 3: + tags: + - manhattan distance + - grid + - exotic coordinate system + - 4: + tags: + - string + - rule matching + - 10: + tags: + - knot hash + - ascii + - hexadecimal + - xor + - 14: + tags: + - knot hash + - ascii + - hexadecimal + - binary + - xor + - grid + - group finding + - bfs + - 21: + tags: + - grid + - dihedral group of the square + - 2020: + day: + - 20: + tags: + - grid + - dihedral group of the square + - sea monsters + - pattern recognition + - 2021: + day: + - 15: + tags: + - grid + - int grid + - path finding + - A* + - 2022: + day: + - 1: + tags: + - sum + - 2: + tags: + - simulation + - 3: + tags: + - set operations + - ascii + - 2024: + day: + - 1: + tags: + - difference + - transpose + - counter + - 2: + tags: + - increasing/decreasing + - 3: + tags: + - regex + - 4: + tags: + - grid + - char grid search + - 5: + tags: + - sort + - custom sort + - 6: + tags: + - grid + - grid navigation + - 7: + tags: + - recursion + - 8: + tags: + - grid + - geometry + - combinations + - 9: + tags: + - large list + - 10: + tags: + - grid + - int grid + - path finding + - 11: + tags: + - recursion + - memoization + - 12: + tags: + - grid + - char grid + - geometry + - polygons + - 13: + tags: + - geometry + - linear equations + - 14: + tags: + - geometry + - pattern recognition + - loop detection + - christmas tree + - 15: + tags: + - grid + - char grid + - 16: + tags: + - grid + - char grid + - path finding + - 17: + tags: + - virtual machine + - bit shifting + - reverse engineering + - 18: + tags: + - grid + - char grid + - path finding + - binary search + - 19: + tags: + - recursion + - memoization + - 20: + tags: + - grid + - char grid + - path finding + - manhattan distance + - 21: + tags: + - recursion + - memoization + - 22: + tags: + - large list + - 23: + tags: + - graph + - graph cliques + - 24: + tags: + - simulation + - binary logic + - 25: + tags: + - grid + - char grid diff --git a/src/main/python/aoc/concepts/__init__.py b/src/main/python/aoc/concepts/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/src/main/python/aoc/concepts/__main__.py b/src/main/python/aoc/concepts/__main__.py new file mode 100644 index 00000000..5ac9d196 --- /dev/null +++ b/src/main/python/aoc/concepts/__main__.py @@ -0,0 +1,6 @@ +#! /usr/bin/env python3 + +import sys +from .concepts import main + +main(sys.argv[1]) diff --git a/src/main/python/aoc/concepts/concepts.py b/src/main/python/aoc/concepts/concepts.py new file mode 100644 index 00000000..5c007c2e --- /dev/null +++ b/src/main/python/aoc/concepts/concepts.py @@ -0,0 +1,81 @@ +#! /usr/bin/env python3 + +import logging +import sys +from collections import defaultdict +from typing import IO +from typing import Iterator + +from prettyprinter import cpprint + +if __name__ == "__main__": + from config import Day # type:ignore + from config import concepts +else: + from aoc.concepts.config import Day + from aoc.concepts.config import concepts + + +log = logging.getLogger(__name__) + + +def _get_tags() -> dict[str, Day]: + tags = defaultdict(list) + for day in _get_days(): + for tag in day.tags: + tags[tag].append(day) + return tags + + +def _get_days() -> Iterator[Day]: + for _ in concepts.get_days(): + yield _ + + +def _print_days(days: Iterator[Day], f: IO[str]) -> None: + print("| Day | Concepts |", file=f) + print("| --- | --- |", file=f) + for day in sorted(days): + t = ", ".join(sorted(day.tags)) + print(f"| {day.year}_{day.day:02} | {t} |", file=f) + + +def _print_tags(tags: dict[str, Day], f: IO[str]) -> None: + print("| Concept | Days |", file=f) + print("| --- | --- |", file=f) + for tag, days in sorted(tags.items()): + d = ", ".join(f"{day.year}_{day.day:02}" for day in sorted(days)) + print(f"| {tag} | {d} |", file=f) + + +def main(file_name: str) -> None: + log.debug(f"file: {file_name}") + with open(file_name, "r", encoding="utf-8") as f: + tmp = f.read() + with open(file_name, "w", encoding="utf-8") as f: + in_days_table, in_tags_table = False, False + for line in tmp.splitlines(): + if line.startswith("