No need for dictionnary, simple list index is enough
This commit is contained in:
parent
7db14d6368
commit
992124623b
1 changed files with 2 additions and 6 deletions
8
6/6_2.py
8
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')
|
||||
|
|
Loading…
Reference in a new issue