day 2-1
This commit is contained in:
27
02/02-1.py
Normal file
27
02/02-1.py
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#file = "./ex.txt"
|
||||
file = "./input.txt"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
solution = 0
|
||||
input_file = open(file, "r")
|
||||
for line in input_file:
|
||||
line = line.strip()
|
||||
if line == "":
|
||||
continue
|
||||
range_list = line.split(",")
|
||||
for r in range_list:
|
||||
a,b = r.split("-")
|
||||
for i in range(int(a),int(b)+1):
|
||||
i_str = str(i)
|
||||
l = len(i_str)
|
||||
l_half = l // 2
|
||||
if l % 2 != 0:
|
||||
continue
|
||||
elif i_str[:l_half] == i_str[l_half:]:
|
||||
print(i)
|
||||
solution += i
|
||||
print(f"The Password is: {solution}")
|
||||
Reference in New Issue
Block a user