Skip to content

Commit

Permalink
day 05 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vsedov committed Dec 5, 2024
1 parent c5dc3c1 commit d987c66
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
36 changes: 19 additions & 17 deletions src/aoc/aoc2024/day_05.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,9 @@ def parse_rules(rules_array: npt.NDArray) -> npt.NDArray:
return dep_matrix


# @njit
# def check_order(deps: npt.NDArray, sequence: npt.NDArray) -> bool:
# n = len(sequence)
# for i in range(n):
# curr = sequence[i]
# for j in range(i + 1, n):
# if deps[curr, sequence[j]] == 1:
# return False
# return True
# @njit
# def check_order(deps: npt.NDArray, sequence: npt.NDArray) -> bool:
# seen = np.zeros_like(deps[0], dtype=np.bool_)
# for num in sequence:
# if np.any(deps[num] & seen):
# return False
# seen[num] = True
# return True
@njit
def check_order(deps: npt.NDArray, sequence: npt.NDArray) -> bool:
# sourcery skip: use-any, use-next
n = len(sequence)
seq_deps = deps[sequence]
for i in range(n - 1):
Expand Down Expand Up @@ -107,3 +91,21 @@ def main(txt: str) -> None:
if __name__ == "__main__":
aoc = Aoc(day=get_day(), years=YEAR)
aoc.run(main, submit=True, part="both", readme_update=True)

# @njit
# def check_order(deps: npt.NDArray, sequence: npt.NDArray) -> bool:
# n = len(sequence)
# for i in range(n):
# curr = sequence[i]
# for j in range(i + 1, n):
# if deps[curr, sequence[j]] == 1:
# return False
# return True
# @njit
# def check_order(deps: npt.NDArray, sequence: npt.NDArray) -> bool:
# seen = np.zeros_like(deps[0], dtype=np.bool_)
# for num in sequence:
# if np.any(deps[num] & seen):
# return False
# seen[num] = True
# return True
2 changes: 1 addition & 1 deletion src/aoc/aoc2024/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
| 02 | [Red-Nosed Reports](https://adventofcode.com/2024/day/2) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| 03 | [Mull It Over](https://adventofcode.com/2024/day/3) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| 04 | [Ceres Search](https://adventofcode.com/2024/day/4) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| 05 | [?](https://adventofcode.com/2024/day/5) | :x: | :x: | :x: |
| 05 | [Print Queue](https://adventofcode.com/2024/day/5) | :heavy_check_mark: | :heavy_check_mark: | :heavy_check_mark: |
| 06 | [?](https://adventofcode.com/2024/day/6) | :x: | :x: | :x: |
| 07 | [?](https://adventofcode.com/2024/day/7) | :x: | :x: | :x: |
| 08 | [?](https://adventofcode.com/2024/day/8) | :x: | :x: | :x: |
Expand Down

0 comments on commit d987c66

Please sign in to comment.