From ef196af7e31712def303690f5710e4387f310fc9 Mon Sep 17 00:00:00 2001 From: FrederikBaerentsen Date: Fri, 22 Nov 2024 21:55:01 +0100 Subject: [PATCH] Working on 2017/09 part 2 --- 2017/09/solution.py | 15 ++++++++++++--- 2017/09/test2 | 7 +++++++ 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 2017/09/test2 diff --git a/2017/09/solution.py b/2017/09/solution.py index b21fec0..56d23c8 100644 --- a/2017/09/solution.py +++ b/2017/09/solution.py @@ -4,7 +4,7 @@ from pprint import pprint input_f = 'input' -part = -1 +part = 2 ######################################### # # # Part 1 # @@ -29,8 +29,17 @@ if part == 1: ######################################### # # -# Part 2 # +# not working Part 2 # # # ######################################### if part == 2: - exit() + with open(input_f) as file: + for line in file: + print(line.rstrip(), end=' ') + clean_string = line.rstrip() + clean_string = re.sub(r"!.",'',clean_string) + print(clean_string) + clean_string = re.findall(r"<.*?>", clean_string) + for c in clean_string: + clean_string = c.replace('<','',1).replace('>','',1) + print(len(clean_string)) diff --git a/2017/09/test2 b/2017/09/test2 new file mode 100644 index 0000000..7a8fbc2 --- /dev/null +++ b/2017/09/test2 @@ -0,0 +1,7 @@ +<> + +<<<<> +<{!>}> + +> +<{o"i!a,<{i