From 457a1d4c4894d65c5f5ee8c55832c5e4a609343e Mon Sep 17 00:00:00 2001 From: MKAY183 Date: Fri, 8 Dec 2023 14:38:37 +0100 Subject: [PATCH] 08-2 fertig --- 08/08-2a.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/08/08-2a.py b/08/08-2a.py index 435beea..490090c 100644 --- a/08/08-2a.py +++ b/08/08-2a.py @@ -7,8 +7,6 @@ startzeit = time() dic = {} rl = "" source = [] -counter = 0 -all_end_z = False # parse input input_file = open("input", "r") @@ -38,19 +36,18 @@ print("Start:", source) loops = [] for s in source: counter = 0 - zcount = 0 + z_count = 0 ss = s out = [] - while zcount < 1: - x = left_or_right(counter) - counter += 1 - if x == "R": + while z_count < 1: + if left_or_right(counter) == "R": ss = dic[ss][1] - elif x == "L": + elif left_or_right(counter) == "L": ss = dic[ss][0] + counter += 1 out.append(ss) if ss.endswith("Z"): - zcount += 1 + z_count += 1 print(s, counter) loops.append(counter) print(loops) @@ -68,7 +65,7 @@ for n in loops: if not li: teiler_liste.append(n) -print("Teilerliste:", teiler_liste) +print("Teiler-Liste:", teiler_liste) unique_teiler = [] for teiler in teiler_liste: