diff options
| author | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-02 19:10:49 +0100 |
|---|---|---|
| committer | Sebastiano Tronto <sebastiano@tronto.net> | 2025-12-02 19:10:49 +0100 |
| commit | d662d817052767047807f8f1d5643608b9943fa0 (patch) | |
| tree | 796c1be7bf1df37f3bdebb8040acd676887d2f6a | |
| parent | c0c0f809bb5b2327db96c7dbb5e9ef8ea5960b00 (diff) | |
| download | aoc-d662d817052767047807f8f1d5643608b9943fa0.tar.gz aoc-d662d817052767047807f8f1d5643608b9943fa0.zip | |
Cleanup day 1 solution
| -rw-r--r-- | 2025/01/b.py | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/2025/01/b.py b/2025/01/b.py index ea32dc7..3ef4a9d 100644 --- a/2025/01/b.py +++ b/2025/01/b.py | |||
| @@ -7,13 +7,7 @@ with fileinput.input() as lines: | |||
| 7 | oldp = p | 7 | oldp = p |
| 8 | s = 1 if line[0] == "R" else -1 | 8 | s = 1 if line[0] == "R" else -1 |
| 9 | p += s * int(line[1:]) | 9 | p += s * int(line[1:]) |
| 10 | if p >= 100: | 10 | c += abs(p) // 100 + (1 if p <= 0 and oldp != 0 else 0) |
| 11 | d = p // 100 | 11 | p %= 100 |
| 12 | c += d | ||
| 13 | p -= d * 100 | ||
| 14 | elif p <= 0: | ||
| 15 | d = -p // 100 + 1 | ||
| 16 | c += d if oldp != 0 else d-1 | ||
| 17 | p = (p + d * 100) % 100 | ||
| 18 | 12 | ||
| 19 | print(c) | 13 | print(c) |
