From 06cec4dbc06d8b835f6135ae6545bb1c579743ab Mon Sep 17 00:00:00 2001 From: Matthias Puchstein Date: Thu, 7 Dec 2023 20:56:11 +0100 Subject: [PATCH] first fix --- 02/02.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/02/02.py b/02/02.py index d16db4f..0df4071 100755 --- a/02/02.py +++ b/02/02.py @@ -12,20 +12,23 @@ sol = 0 for line in lines: line = line.replace('\n', "") gameid = line.split(":")[0].split(" ")[1] - game = line.split(":")[1].split(",") + game = line.split(":")[1].split(";") valid = True - for color in game: - temp = color.split(' ') - if 'red' in temp[1]: - if int(temp[0]) > maxred: - valid = False - elif 'green' in temp[1]: - if int(temp[0]) > maxgreen: - valid = False - elif 'blue' in temp[1]: - if int(temp[0]) > maxblue: - valid = False + for pull in game: + colors = pull.split(',') + for color in colors: + temp = color.split(' ') + if 'red' in temp[2]: + if int(temp[1]) > maxred: + valid = False + elif 'green' in temp[2]: + if int(temp[1]) > maxgreen: + valid = False + elif 'blue' in temp[2]: + if int(temp[1]) > maxblue: + valid = False if not valid: - sol += gameid + print(gameid) + sol += int(gameid) print(sol)