advent-of-code

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit 3751975ff7fc1f864c9c6799f920fbb4ba31d748
parent a636ee04d03136551f6d90105034e77635bf323b
Author: mpizzzle <michael.770211@gmail.com>
Date:   Sat,  9 Dec 2017 15:30:12 +0000

minor refactoring

Diffstat:
Mpuzzle9.py | 24++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/puzzle9.py b/puzzle9.py @@ -10,16 +10,10 @@ total = 0 garbage_characters = 0 for char in stream: - if not garbage: - if char == '{': - depth += 1 - total += depth - if char == '}': - depth -= 1 - if char == '<': - garbage = True - else: - if not skip: + if garbage: + if skip: + skip = False + else: if char == '!': skip = True continue @@ -27,8 +21,14 @@ for char in stream: garbage = False else: garbage_characters += 1 - else: - skip = False + else: + if char == '{': + depth += 1 + total += depth + if char == '}': + depth -= 1 + if char == '<': + garbage = True print total print garbage_characters