diff options
| author | NSDepression <avimanyu.apple@gmail.com> | 2025-12-03 11:56:18 +0530 |
|---|---|---|
| committer | NSDepression <avimanyu.apple@gmail.com> | 2025-12-03 11:56:18 +0530 |
| commit | 881957f4f0865000ab978222c9cb694c73180995 (patch) | |
| tree | 9fb3fc40551ff74d21dceabc37afefb957f238eb /Day 2/Untitled.py | |
| parent | 3a93d2d546476c3fb24f72b50e830930a321f969 (diff) | |
| download | AoC-2025-881957f4f0865000ab978222c9cb694c73180995.tar.gz AoC-2025-881957f4f0865000ab978222c9cb694c73180995.zip | |
Day 2.2
Diffstat (limited to 'Day 2/Untitled.py')
| -rw-r--r-- | Day 2/Untitled.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Day 2/Untitled.py b/Day 2/Untitled.py new file mode 100644 index 0000000..536e83b --- /dev/null +++ b/Day 2/Untitled.py @@ -0,0 +1,21 @@ + + +with open ('input.txt', "r") as file: + content = file.read().strip() +range_groups = content.split(',') +st = [] +sum = 0 + +for group in range_groups: + print (f"Range: {group}") + distinct_nums = group.split("-") + first_value = int(distinct_nums[0]) + last_value = int(distinct_nums[1]) + for num in range(first_value, last_value + 1): + s = str(num) + is_repeating = s in (s + s) [1:-1] + if is_repeating==True: + st.append(num) +for n in st: + sum += n +print (f"Total Sum: {sum} ")
\ No newline at end of file |
