From 22d09272e1cf88d158c016556bec2c205e526445 Mon Sep 17 00:00:00 2001 From: Tristan Date: Thu, 29 Nov 2018 17:10:49 +0000 Subject: [PATCH] finished day 1 2015 --- 2015/1/part_2.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 2015/1/part_2.py diff --git a/2015/1/part_2.py b/2015/1/part_2.py new file mode 100644 index 0000000..784c2ce --- /dev/null +++ b/2015/1/part_2.py @@ -0,0 +1,16 @@ +with open('input.txt', 'r') as input: + pos = 0 + char_pos = 0 + text = input.readline() + for char in text : + if char == ')': + pos -= 1 + elif char == '(': + pos += 1 + char_pos += 1 + if pos == -1: + print (char_pos) + break + + input.close() +