aoc

My solutions for the Advent of Code
git clone https://git.tronto.net/aoc
Download | Log | Files | Refs | README

commit d662d817052767047807f8f1d5643608b9943fa0
parent c0c0f809bb5b2327db96c7dbb5e9ef8ea5960b00
Author: Sebastiano Tronto <sebastiano@tronto.net>
Date:   Tue,  2 Dec 2025 19:10:49 +0100

Cleanup day 1 solution

Diffstat:
M2025/01/b.py | 10++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/2025/01/b.py b/2025/01/b.py @@ -7,13 +7,7 @@ with fileinput.input() as lines: oldp = p s = 1 if line[0] == "R" else -1 p += s * int(line[1:]) - if p >= 100: - d = p // 100 - c += d - p -= d * 100 - elif p <= 0: - d = -p // 100 + 1 - c += d if oldp != 0 else d-1 - p = (p + d * 100) % 100 + c += abs(p) // 100 + (1 if p <= 0 and oldp != 0 else 0) + p %= 100 print(c)