code cleanup

This commit is contained in:
Stefan Harmuth 2022-11-29 19:35:27 +01:00
parent 6d77259384
commit 63eafb5f42

View File

@ -13,24 +13,20 @@ class Day(AOCDay):
]
]
def part1(self):
def count(self, step: int = 1) -> int:
count = 0
depths = self.getInputListAsType(int)
for x in range(1, len(depths)):
if depths[x] > depths[x-1]:
for x in range(step, len(depths)):
if depths[x] > depths[x - step]:
count += 1
return count
def part1(self):
return self.count()
def part2(self):
count = 0
depths = self.getInputListAsType(int)
for x in range(3, len(depths)):
if depths[x] > depths[x-3]:
count += 1
return count
return self.count(3)
if __name__ == '__main__':