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}")
|
||||||
1
02/ex.txt
Normal file
1
02/ex.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
11-22,95-115,998-1012,1188511880-1188511890,222220-222224,1698522-1698528,446443-446449,38593856-38593862,565653-565659,824824821-824824827,2121212118-2121212124
|
||||||
1
02/input.txt
Normal file
1
02/input.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
24-46,124420-259708,584447-720297,51051-105889,6868562486-6868811237,55-116,895924-1049139,307156-347325,372342678-372437056,1791-5048,3172595555-3172666604,866800081-866923262,5446793-5524858,6077-10442,419-818,57540345-57638189,2143479-2274980,683602048-683810921,966-1697,56537997-56591017,1084127-1135835,1-14,2318887654-2318959425,1919154462-1919225485,351261-558210,769193-807148,4355566991-4355749498,809094-894510,11116-39985,9898980197-9898998927,99828221-99856128,9706624-9874989,119-335
|
||||||
Reference in New Issue
Block a user