aboutsummaryrefslogtreecommitdiff
path: root/challenge-320/steven-wilson/python/ch-1.py
diff options
context:
space:
mode:
authorSteven <steven1170@zoho.eu>2025-05-06 17:10:04 +0100
committerSteven <steven1170@zoho.eu>2025-05-06 17:10:04 +0100
commitb4dcca2f02759b5b910bf5ef2e10f5816301d46d (patch)
tree1aa23ae98adba3044ba5798ebb2b89903a7e603b /challenge-320/steven-wilson/python/ch-1.py
parent7d67833e2e7de682d2d418145812d575218e0fa9 (diff)
downloadperlweeklychallenge-club-b4dcca2f02759b5b910bf5ef2e10f5816301d46d.tar.gz
perlweeklychallenge-club-b4dcca2f02759b5b910bf5ef2e10f5816301d46d.tar.bz2
perlweeklychallenge-club-b4dcca2f02759b5b910bf5ef2e10f5816301d46d.zip
add solutions week 320 in python
Diffstat (limited to 'challenge-320/steven-wilson/python/ch-1.py')
-rw-r--r--challenge-320/steven-wilson/python/ch-1.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-320/steven-wilson/python/ch-1.py b/challenge-320/steven-wilson/python/ch-1.py
new file mode 100644
index 0000000000..c6f8d506f9
--- /dev/null
+++ b/challenge-320/steven-wilson/python/ch-1.py
@@ -0,0 +1,27 @@
+#!/usr/bin/env python3
+
+
+def maximum_count(integers):
+ """ Given an array of integers, return the maximum between the number of
+ positive and negative integers. Zero is neither positive nor negative.
+
+ >>> maximum_count([-3, -2, -1, 1, 2, 3])
+ 3
+ >>> maximum_count([-2, -1, 0, 0, 1])
+ 2
+ >>> maximum_count([1, 2, 3, 4])
+ 4
+ """
+ (positive, negative) = (0, 0)
+ for i in integers:
+ if i > 0:
+ positive += 1
+ elif i < 0:
+ negative += 1
+ return max(positive, negative)
+
+
+if __name__ == "__main__":
+ import doctest
+
+ doctest.testmod(verbose=True)