diff options
Diffstat (limited to '2025/02/a.py')
| -rw-r--r-- | 2025/02/a.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/2025/02/a.py b/2025/02/a.py index 5fdb11b..9c6fd84 100644 --- a/2025/02/a.py +++ b/2025/02/a.py | |||
| @@ -1,6 +1,17 @@ | |||
| 1 | import fileinput | 1 | import fileinput |
| 2 | 2 | ||
| 3 | def invalid(n): | ||
| 4 | return n[:len(n)//2] == n[len(n)//2:] | ||
| 5 | |||
| 6 | s = 0 | ||
| 3 | with fileinput.input() as lines: | 7 | with fileinput.input() as lines: |
| 4 | for line in lines: | 8 | for line in lines: |
| 5 | ... | 9 | for r in line.split(","): |
| 10 | l = r.split("-"); | ||
| 11 | for n in range(int(l[0]), int(l[1])+1): | ||
| 12 | if invalid(str(n)): | ||
| 13 | print(n) | ||
| 14 | s += n | ||
| 15 | print(s) | ||
| 16 | |||
| 6 | 17 | ||
