From a48b701ebd1fa3a4739a863255e2c3e68624f75d Mon Sep 17 00:00:00 2001 From: tebarius Date: Wed, 3 Dec 2025 22:48:53 +0100 Subject: [PATCH] day 3-2 --- 03/03-2.py | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/03/03-2.py b/03/03-2.py index 94c6026..34773c0 100644 --- a/03/03-2.py +++ b/03/03-2.py @@ -1,22 +1,20 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- -file = "./ex.txt" -#file = "./input.txt" +#file = "./ex.txt" +file = "./input.txt" def find_num(l:str) -> int: numbers = "9876543210" nums = [] pos = 0 - for zell in range(1,12): - - for n in numbers: - if zell < len(nums): - continue - for i in range(pos, len(l)-11+zell): - if n == l[i]: - pos = i+1 - nums.append(n) + for zell in range(0,13): + while zell > len(nums): + for n in numbers: + for i in range(pos, len(l)-12+zell): + if n == l[i] and zell > len(nums): + pos = i+1 + nums.append(n) print("".join(nums)) return int("".join(nums))