From 380b527017eb590e07f5f655380b04743bfae089 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 21 May 2025 00:39:38 +0100 Subject: [PATCH] 2015: d01: ex1: add solution --- 2015/d01/ex1/ex1.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100755 2015/d01/ex1/ex1.py diff --git a/2015/d01/ex1/ex1.py b/2015/d01/ex1/ex1.py new file mode 100755 index 0000000..616d288 --- /dev/null +++ b/2015/d01/ex1/ex1.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python + +import collections +import sys + + +def solve(input: str) -> int: + directions = collections.Counter(input.strip()) + return directions["("] - directions[")"] + + +def main() -> None: + input = sys.stdin.read() + print(solve(input)) + + +if __name__ == "__main__": + main()