From 9d97e63709ec193d11a8bb5f5f04e51550bdf64a Mon Sep 17 00:00:00 2001 From: Jake Date: Tue, 14 Dec 2021 07:50:17 +0000 Subject: [PATCH] Completed day 10, task 1 --- Day-10/day10-1.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Day-10/day10-1.py diff --git a/Day-10/day10-1.py b/Day-10/day10-1.py new file mode 100644 index 0000000..ae62c21 --- /dev/null +++ b/Day-10/day10-1.py @@ -0,0 +1,34 @@ +#!/usr/bin/python3 + +totalScore = 0 + +closers = { + '(':')', + '{':'}', + '[':']', + '<':'>' +} + +points = { + ')':3, + ']':57, + '}':1197, + '>':25137 +} + +with open('/home/jake/Documents/AoC-2021/Day-10/input.txt') as inputFile: + for line in inputFile: + line = line.strip('\n') + i = 0 + expecting = [] + i = 0 + for char in line: + if(char in closers): + expecting.insert(0,closers[char]) + else: + if(expecting[i] != char): + totalScore += points[char] + break + else: + del expecting[i] +print("Our total score was: " + str(totalScore)) \ No newline at end of file