summaryrefslogtreecommitdiffstats
path: root/Day 2/Untitled.py
blob: 536e83b67dfb84e45371ec66cfc19f6aad45ec46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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} ")