diff options
author | Thomas Voss <thomasvoss@live.com> | 2021-12-12 06:58:42 +0100 |
---|---|---|
committer | Thomas Voss <thomasvoss@live.com> | 2021-12-12 06:58:42 +0100 |
commit | 2123df38d2bb5745fdae0e226a02c4759dc22b46 (patch) | |
tree | f4beb03c1340a5ce427fa88ecc17a6e1d1106974 /2021/12 | |
parent | a18ad6c54e635a16a5a5a71312082dd9dcededd3 (diff) |
These files shouldnt have been added
Diffstat (limited to '2021/12')
-rwxr-xr-x | 2021/12/puzzle-1.py | 32 | ||||
-rwxr-xr-x | 2021/12/puzzle-2.py | 37 |
2 files changed, 0 insertions, 69 deletions
diff --git a/2021/12/puzzle-1.py b/2021/12/puzzle-1.py deleted file mode 100755 index 1ec9f51..0000000 --- a/2021/12/puzzle-1.py +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env python3 - -from collections import defaultdict - - -def solve(paths: defaultdict[list[str]], path: str, flag: bool = False) -> int: - acc = 0 - tokens = path.split(",") - - for dest in paths[tokens[-1]]: - if dest == "end": - acc += 1 - # START PART 1 - elif not (dest.islower() and dest in tokens): - acc += solve(paths, f"{path},{dest}") - - return acc - - -def main() -> None: - paths: defaultdict[list[str]] = defaultdict(list) - with open("input", "r", encoding="utf-8") as f: - for entry in f.readlines(): - x, y = entry.strip().split("-") - paths[x].append(y) - paths[y].append(x) - - print(solve(paths, "start", False)) - - -if __name__ == "__main__": - main() diff --git a/2021/12/puzzle-2.py b/2021/12/puzzle-2.py deleted file mode 100755 index d5c6f68..0000000 --- a/2021/12/puzzle-2.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 - -from collections import defaultdict - - -def solve(paths: defaultdict[str, list[str]], path: str, flag: bool = False) -> int: - acc = 0 - tokens = path.split(",") - - for dest in paths[tokens[-1]]: - if dest == "end": - acc += 1 - elif dest != "start": - if dest.islower() and dest in tokens: - if flag: - continue - acc += solve(paths, f"{path},{dest}", True) - else: - acc += solve(paths, f"{path},{dest}", flag) - # END PART 2 - - return acc - - -def main() -> None: - paths: defaultdict[str, list[str]] = defaultdict(list) - with open("input", "r", encoding="utf-8") as f: - for entry in f.readlines(): - x, y = entry.strip().split("-") - paths[x].append(y) - paths[y].append(x) - - print(solve(paths, "start", False)) - - -if __name__ == "__main__": - main() |