🥱 2024 Day 2

This commit is contained in:
Felix Pankratz 2024-12-02 18:49:00 +01:00
parent 15024dbdaf
commit ac8563d39c
2 changed files with 1016 additions and 0 deletions

16
2024/02/01.py Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env python3
INPUT_FILE = 'input.txt'
def main():
reports = [list(map(int, vals.split())) for vals in open(INPUT_FILE, 'r').readlines()]
safe_reports = 0
for report in reports:
ok = all([1 <= abs(report[i] - report[i + 1]) <= 3 for i in range(len(report) - 1 )])
is_sorted = report == sorted(report) or report == sorted(report, reverse=True)
if ok and is_sorted: safe_reports += 1
print(safe_reports)
if __name__ == '__main__':
main()

1000
2024/02/input.txt Executable file

File diff suppressed because it is too large Load Diff