advent-of-code

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

commit e90183eec796cf05e193097d775267817958693f
parent b5619be4e8379d06cda88526dafc45ef63f530c3
Author: mpizzzle <michael.770211@gmail.com>
Date:   Sat,  1 Dec 2018 21:21:32 +0000

cleaning up solution

Diffstat:
M2018/puzzle1.py | 10+++++-----
1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/2018/puzzle1.py b/2018/puzzle1.py @@ -3,16 +3,16 @@ from sets import Set with open('files/puzzle1.txt') as f: file = f.readlines() -#frequency = sum([int(s[1:]) if s[0] == '+' else int(s[1:]) * -1 for s in file]) frequency = 0 frequencies = Set() -frequency_not_found = True -while frequency_not_found: +frequency_found = False + +while not frequency_found: for s in file: frequencies.add(frequency) - frequency += int(s[1:]) if s[0] == '+' else int(s[1:]) * -1 + frequency += int(s) if frequency in frequencies: - frequency_not_found = False + frequency_found = True break print frequency \ No newline at end of file