generated from public/aoc_template
Compare commits
No commits in common. "694f9c6db9f8bbab19a87ecd4db2933bca33134a" and "6bc0aa2f0c39d6fd20c33f8037226836e379eb11" have entirely different histories.
694f9c6db9
...
6bc0aa2f0c
Binary file not shown.
|
Before Width: | Height: | Size: 9.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 9.9 KiB |
@ -1,13 +1,4 @@
|
|||||||
# Advent of Code 2024
|
# Advent of Code 2024
|
||||||
|
|
||||||
<!-- AOC TILES BEGIN -->
|
<!-- AOC TILES BEGIN -->
|
||||||
<h1 align="center">
|
|
||||||
2024 - 4 ⭐ - Python
|
|
||||||
</h1>
|
|
||||||
<a href="day01.py">
|
|
||||||
<img src=".aoc_tiles/tiles/2024/01.png" width="161px">
|
|
||||||
</a>
|
|
||||||
<a href="day02.py">
|
|
||||||
<img src=".aoc_tiles/tiles/2024/02.png" width="161px">
|
|
||||||
</a>
|
|
||||||
<!-- AOC TILES END -->
|
<!-- AOC TILES END -->
|
||||||
51
day02.py
51
day02.py
@ -1,51 +0,0 @@
|
|||||||
from tools.aoc import AOCDay
|
|
||||||
from typing import Any
|
|
||||||
|
|
||||||
|
|
||||||
def check_report(levels: list[int]) -> bool:
|
|
||||||
safe = True
|
|
||||||
mode = None
|
|
||||||
for i, level in enumerate(levels):
|
|
||||||
if i == 0: continue
|
|
||||||
if i == 1: mode = level < levels[i - 1]
|
|
||||||
|
|
||||||
if not 1 <= abs(level - levels[i - 1]) <= 3 or mode != (level < levels[i - 1]):
|
|
||||||
safe = False
|
|
||||||
break
|
|
||||||
|
|
||||||
return safe
|
|
||||||
|
|
||||||
|
|
||||||
class Day(AOCDay):
|
|
||||||
inputs = [
|
|
||||||
[
|
|
||||||
(2, "input2_test"),
|
|
||||||
(680, "input2"),
|
|
||||||
],
|
|
||||||
[
|
|
||||||
(4, "input2_test"),
|
|
||||||
(710, "input2"),
|
|
||||||
]
|
|
||||||
]
|
|
||||||
|
|
||||||
def part1(self) -> Any:
|
|
||||||
return sum(check_report(x) for x in self.getInputAsArraySplit(split_char=" ", return_type=int))
|
|
||||||
|
|
||||||
def part2(self) -> Any:
|
|
||||||
safe = 0
|
|
||||||
for report in self.getInputAsArraySplit(split_char=" ", return_type=int):
|
|
||||||
if check_report(report):
|
|
||||||
safe += 1
|
|
||||||
continue
|
|
||||||
|
|
||||||
for x in range(len(report)):
|
|
||||||
if check_report(report[:x] + report[x + 1:]):
|
|
||||||
safe += 1
|
|
||||||
break
|
|
||||||
|
|
||||||
return safe
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
day = Day(2024, 2)
|
|
||||||
day.run(verbose=True)
|
|
||||||
1000
inputs/input2
1000
inputs/input2
File diff suppressed because it is too large
Load Diff
@ -1,6 +0,0 @@
|
|||||||
7 6 4 2 1
|
|
||||||
1 2 7 8 9
|
|
||||||
9 7 6 2 1
|
|
||||||
1 3 2 4 5
|
|
||||||
8 6 4 4 1
|
|
||||||
1 3 6 7 9
|
|
||||||
Loading…
Reference in New Issue
Block a user