This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| def build_map() -> list[list[str]]: | |
| with open("input.txt") as f: | |
| rows = [] | |
| for line in f: | |
| line = list(line.strip()) | |
| elems = set(line) | |
| if len(elems) == 1 and '.' in elems: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from functools import cache | |
| def solve(pattern: str, groups: list[int]) -> int: | |
| @cache | |
| def dp(start_pos: int, g: int) -> int: | |
| if start_pos == len(pattern): | |
| return int(g == len(groups)) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| def solve(pattern: list[str]) -> int: | |
| n = len(pattern) | |
| m = len(pattern[0]) | |
| rows = [] | |
| repeated_rows = [] | |
| for i in range(n): | |
| x = 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| from collections import defaultdict | |
| from heapq import heappop, heappush | |
| with open("input.txt") as f: | |
| empty, rocks, walls = defaultdict(list), defaultdict(list), defaultdict(list) | |
| n = 0 |
OlderNewer