2017: d01: ex1: add solution
This commit is contained in:
parent
cc723e61bd
commit
64db8a4834
1 changed files with 17 additions and 0 deletions
17
2017/d01/ex1/ex1.py
Executable file
17
2017/d01/ex1/ex1.py
Executable file
|
|
@ -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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue