Skip to content

Commit

Permalink
[2024/2] p1 solved
Browse files Browse the repository at this point in the history
  • Loading branch information
StarlitGhost committed Dec 2, 2024
1 parent 6d1f276 commit b1cff03
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
Binary file added .aoc_tiles/tiles/2024/02.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions 2024/2/example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
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
22 changes: 22 additions & 0 deletions 2024/2/script.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
from GhostyUtils import aoc


def main():
inputs = aoc.read_lines()

safe = 0
for report in inputs:
report = [int(r) for r in report.split()]
diffs = [ln - l for l, ln in zip(report, report[1:])]
safety = ((all(d < 0 for d in diffs)
or all(d > 0 for d in diffs))
and all(0 < abs(d) <= 3 for d in diffs))
if safety:
safe += 1
print(diffs, safety)

print("p1:", safe)


if __name__ == "__main__":
main()
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ My solutions to the yearly Advents of Code

<!-- AOC TILES BEGIN -->
<h1 align="center">
Advent of Code - 163/452
Advent of Code - 164/454
</h1>
<h1 align="center">
2024 - 2 ⭐ - Python
2024 - 3 ⭐ - Python
</h1>
<a href="2024/1/script.py">
<img src=".aoc_tiles/tiles/2024/01.png" width="161px">
</a>
<a href="2024/2/script.py">
<img src=".aoc_tiles/tiles/2024/02.png" width="161px">
</a>
<h1 align="center">
2023 - 47 ⭐ - Python
</h1>
Expand Down

0 comments on commit b1cff03

Please sign in to comment.