From 992124623b9d1a21eb10599bdca54c2f5a180099 Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 7 Dec 2021 11:30:00 +0100 Subject: [PATCH] No need for dictionnary, simple list index is enough --- 6/6_2.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/6/6_2.py b/6/6_2.py index 6515cf0..378ea69 100755 --- a/6/6_2.py +++ b/6/6_2.py @@ -7,7 +7,7 @@ def parse_file(file): list_state = [int(x) for x in line.split(',')] - state = dict(zip(range(0, 9), [0]*9)) + state = [0] * 9 for c in range(0, 9): state[c] = list_state.count(c) @@ -36,8 +36,4 @@ DAYS = 256 for d in range(DAYS): iterate(init_state) -lanternfish = 0 -for k, v in init_state.items(): - lanternfish += v - -print(f'There\'s {lanternfish} lanternfish after {DAYS} days') +print(f'There\'s {sum(init_state)} lanternfish after {DAYS} days')