From 1f1ad1dfe5b34f4565048c3ca25def9d197fda0a Mon Sep 17 00:00:00 2001 From: tebarius Date: Tue, 2 Dec 2025 20:58:26 +0100 Subject: [PATCH] day 2-1 --- 02/02-1.py | 27 +++++++++++++++++++++++++++ 02/ex.txt | 1 + 02/input.txt | 1 + 3 files changed, 29 insertions(+) create mode 100644 02/02-1.py create mode 100644 02/ex.txt create mode 100644 02/input.txt diff --git a/02/02-1.py b/02/02-1.py new file mode 100644 index 0000000..950453f --- /dev/null +++ b/02/02-1.py @@ -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}") \ No newline at end of file diff --git a/02/ex.txt b/02/ex.txt new file mode 100644 index 0000000..a3f22ef --- /dev/null +++ b/02/ex.txt @@ -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 diff --git a/02/input.txt b/02/input.txt new file mode 100644 index 0000000..825afb6 --- /dev/null +++ b/02/input.txt @@ -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