42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
import logging
|
|
import sys
|
|
|
|
def main():
|
|
# Logger setup
|
|
logger = logging.getLogger(__name__)
|
|
logger.setLevel(logging.INFO)
|
|
stream_handler = logging.StreamHandler()
|
|
logger.addHandler(stream_handler)
|
|
|
|
output = 0
|
|
logger.debug("Init output with value: " + str(output))
|
|
with open("input.txt", "r") as input:
|
|
for line in input:
|
|
line = line.strip()
|
|
ranges = line.split(",")
|
|
for id_range in ranges:
|
|
ids = id_range.split("-")
|
|
print(ids)
|
|
for x in range(int(ids[0]), int(ids[1]) + 1):
|
|
# print("Testing " + str(x))
|
|
if len(str(x)) % 2 != 0:
|
|
continue
|
|
middle = int(len(str(x))/2)
|
|
if(str(x)[middle:] == str(x)[:middle]):
|
|
print(str(x))
|
|
output += x
|
|
logger.info("Output: " + str(output))
|
|
|
|
# x = 1111
|
|
# if len(str(x)) % 2 != 0:
|
|
# print("NOO")
|
|
# middle = int(len(str(x))/2)
|
|
# if(str(x)[middle:] == str(x)[:middle]):
|
|
# print(str(x))
|
|
#print(x[(len(x)/2):])
|
|
#print(x[:(len(x)/2)])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|