Compare commits
No commits in common. "9f280f2e3d15d8481f15e8e08e8cd7fa86559caa" and "da90cd8472f2f40d4e4b3c67ca6ac7e7de6c2ab2" have entirely different histories.
9f280f2e3d
...
da90cd8472
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,2 +0,0 @@
|
|||
# Generated by Nix
|
||||
/.pre-commit-config.yaml
|
|
@ -1,18 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import itertools
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
|
||||
def solve(input: List[int]) -> int:
|
||||
return sum(prev < cur for (prev, cur) in itertools.pairwise(input))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
input = [int(line) for line in sys.stdin.readlines()]
|
||||
print(solve(input))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
2000
2021/d01/ex1/input
2000
2021/d01/ex1/input
File diff suppressed because it is too large
Load diff
|
@ -1,30 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import collections
|
||||
import itertools
|
||||
import sys
|
||||
from typing import List
|
||||
|
||||
|
||||
def sliding_window(iterable, n):
|
||||
it = iter(iterable)
|
||||
window = collections.deque(itertools.islice(it, n), maxlen=n)
|
||||
if len(window) == n:
|
||||
yield tuple(window)
|
||||
for x in it:
|
||||
window.append(x)
|
||||
yield tuple(window)
|
||||
|
||||
|
||||
def solve(input: List[int]) -> int:
|
||||
windowed = [sum(window) for window in sliding_window(input, 3)]
|
||||
return sum(prev < cur for (prev, cur) in itertools.pairwise(windowed))
|
||||
|
||||
|
||||
def main() -> None:
|
||||
input = [int(line) for line in sys.stdin.readlines()]
|
||||
print(solve(input))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
2000
2021/d01/ex2/input
2000
2021/d01/ex2/input
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue