From 78f896dd625fbbfe33fbd88b55790e55bf0dd57f Mon Sep 17 00:00:00 2001 From: Simon Green Date: Sun, 11 May 2025 11:31:25 +1000 Subject: sgreen solutions to challenge 320 --- challenge-320/sgreen/python/ch-1.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 challenge-320/sgreen/python/ch-1.py (limited to 'challenge-320/sgreen/python/ch-1.py') diff --git a/challenge-320/sgreen/python/ch-1.py b/challenge-320/sgreen/python/ch-1.py new file mode 100755 index 0000000000..60156de33e --- /dev/null +++ b/challenge-320/sgreen/python/ch-1.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 + +import sys + + +def maximum_count(ints: list) -> int: + """Return the maximum between the number of positive and negative integers + + Args: + ints (list): A list of integers + + Returns: + int: The maximum + """ + + # Count the number of positive and negative integers + pos_count = sum(1 for i in ints if i > 0) + neg_count = sum(1 for i in ints if i < 0) + + # Return the maximum of these two values + return max(pos_count, neg_count) + +def main(): + # Convert input into integers + array = [int(n) for n in sys.argv[1:]] + result = maximum_count(array) + print(result) + + +if __name__ == '__main__': + main() -- cgit