From 64db8a4834325982355ef9af4d97b39827554e9f Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Fri, 9 May 2025 14:59:31 +0100 Subject: [PATCH] 2017: d01: ex1: add solution --- 2017/d01/ex1/ex1.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 2017/d01/ex1/ex1.py diff --git a/2017/d01/ex1/ex1.py b/2017/d01/ex1/ex1.py new file mode 100755 index 0000000..7d20719 --- /dev/null +++ b/2017/d01/ex1/ex1.py @@ -0,0 +1,17 @@ +#!/usr/bin/env python + +import sys + + +def solve(input: str) -> int: + nums = [int(n) for n in input.strip()] + return sum(n for n, m in zip(nums, nums[1:] + nums[:1]) if n == m) + + +def main() -> None: + input = sys.stdin.read() + print(solve(input)) + + +if __name__ == "__main__": + main()