solved 9b in 9a

kwout 2 years ago
parent 35d86b41b7
commit d38e9fa85b
  1. 1
      .gitignore
  2. 24
      2021/day9/9a.py
  3. 4
      README.md

1
.gitignore vendored

@ -4,3 +4,4 @@
*.swp *.swp
*.swo *.swo
.DS_Store

@ -18,4 +18,26 @@ for p in lowList:
print(summa) print(summa)
print(lowList) explored = []
def explore(x,y):
if lines[x][y] == 9 or (x,y) in explored:
return 0
explored.append((x,y))
size = 1
if y != 0:
size += explore(x,y-1)
if y != len(lines[x]) - 1:
size += explore(x,y+1)
if x != 0:
size += explore(x-1,y)
if x != len(lines) - 1:
size += explore(x+1,y)
return size
sizes = [0]*len(lowList)
for i in range(len(lowList)):
sizes[i] = explore(lowList[i][0],lowList[i][1])
sizes.sort()
print(sizes[-1] * sizes[-2] * sizes[-3])

@ -1,10 +1,10 @@
my solutions for the [Advent of Code](https://adventofcode.com/) my solutions for the [Advent of Code](https://adventofcode.com/)
in progress:\ in progress:\
2021 (python) 2021 (python)\
2022 (python)
planned:\ planned:\
2022 (rust)\
2020\ 2020\
2019\ 2019\
2018\ 2018\

Loading…
Cancel
Save