From d0a9df1754e2c9182f5b3a3a30682b37014e6206 Mon Sep 17 00:00:00 2001 From: terminaldweller Date: Wed, 3 Jan 2024 03:20:27 -0500 Subject: 2125,2620,2667 --- 2125/main.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 2125/main.py (limited to '2125') diff --git a/2125/main.py b/2125/main.py new file mode 100755 index 0000000..da45c29 --- /dev/null +++ b/2125/main.py @@ -0,0 +1,26 @@ +#!/usr/bin/env python + +import typing + + +class Solution: + def numberOfBeams(self, bank: typing.List[str]) -> int: + row_count = 0 + result = 0 + for row in bank: + count = row.count("1") + if count != 0: + result += row_count * count + row_count = row.count("1") + + return result + + +def main(): + solution = Solution() + print(solution.numberOfBeams(["011001", "000000", "010100", "00100"])) + print(solution.numberOfBeams(["000", "111", "000"])) + + +if __name__ == "__main__": + main() -- cgit v1.2.3