From cc2d1bd49a407a2459bf8fa4452fc5e01dc59856 Mon Sep 17 00:00:00 2001 From: Dale Anderson Date: Mon, 12 Dec 2022 09:44:16 -0800 Subject: [PATCH] Modify for part 2 --- 2022/11/solution.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/2022/11/solution.py b/2022/11/solution.py index 06e138a..f1a1438 100755 --- a/2022/11/solution.py +++ b/2022/11/solution.py @@ -15,11 +15,15 @@ def main(data0): data0 = data0.split('\n\n') + global divide_by_three + if args.part1 or not args.part2: + divide_by_three = True part1_answer = part1(data0) print(f'Part 1: {part1_answer}') if args.part2 or not args.part1: + divide_by_three = False part2_answer = part2(data0) print(f'Part 2: {part2_answer}') @@ -114,7 +118,9 @@ def process_worry_level(old_worry_level, operation_def): raise ValueError(f'Unknown operator: {operator}') # log.debug(f' new_worry_level operated: {new_worry_level}') - new_worry_level = new_worry_level // 3 + global divide_by_three + if divide_by_three: + new_worry_level = new_worry_level // 3 # log.debug(f' new_worry_level divided down: {new_worry_level}') return new_worry_level