From 81e3d484c8d1e6aca28cc4ec25f11efa243414d6 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 1 Dec 2021 10:43:29 +0100 Subject: [PATCH] 2021: d01: ex1: add solution --- 2021/d01/ex1/ex1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 2021/d01/ex1/ex1.py diff --git a/2021/d01/ex1/ex1.py b/2021/d01/ex1/ex1.py new file mode 100755 index 0000000..b9c93da --- /dev/null +++ b/2021/d01/ex1/ex1.py @@ -0,0 +1,18 @@ +#!/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()