aboutsummaryrefslogtreecommitdiff
path: root/challenge-320/packy-anderson/python/ch-1.py
diff options
context:
space:
mode:
authorDave Jacoby <jacoby.david@gmail.com>2025-05-15 16:45:20 -0400
committerGitHub <noreply@github.com>2025-05-15 16:45:20 -0400
commitefc2a652edb6436965e12883bedf035ea081284d (patch)
tree7e9940d4f72fe1e8d984b3746af2d30dff96330b /challenge-320/packy-anderson/python/ch-1.py
parent6886bd3e06ccf8b0a564f3c434cd53131d126f70 (diff)
parented7588dadb77d63adca3d3aefc6cd325164e0947 (diff)
downloadperlweeklychallenge-club-efc2a652edb6436965e12883bedf035ea081284d.tar.gz
perlweeklychallenge-club-efc2a652edb6436965e12883bedf035ea081284d.tar.bz2
perlweeklychallenge-club-efc2a652edb6436965e12883bedf035ea081284d.zip
Merge branch 'manwar:master' into master
Diffstat (limited to 'challenge-320/packy-anderson/python/ch-1.py')
-rwxr-xr-xchallenge-320/packy-anderson/python/ch-1.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/challenge-320/packy-anderson/python/ch-1.py b/challenge-320/packy-anderson/python/ch-1.py
new file mode 100755
index 0000000000..8e103a1509
--- /dev/null
+++ b/challenge-320/packy-anderson/python/ch-1.py
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+
+def maxCount(ints):
+ pos = 0
+ neg = 0
+ for int in ints:
+ if int > 0:
+ pos += 1
+ elif int < 0:
+ neg +=1
+ max_count = max(pos, neg)
+ explain = (
+ f"There are {pos} positive integers.\n" +
+ f"There are {neg} negative integers.\n" +
+ f"The maximum between {pos} and {neg} is {max_count}."
+ )
+ return max_count, explain
+
+def comma_join(arr):
+ return ', '.join(map(lambda i: str(i), arr))
+
+def solution(ints):
+ print(f'Input: @ints = ({comma_join(ints)})')
+ max_count, explain = maxCount(ints)
+ print(f'Output: {max_count}\n\n{explain}')
+
+print('Example 1:')
+solution([-3, -2, -1, 1, 2, 3])
+
+print('\nExample 2:')
+solution([-2, -1, 0, 0, 1])
+
+print('\nExample 3:')
+solution([1, 2, 3, 4])