aboutsummaryrefslogtreecommitdiff
path: root/challenge-243/packy-anderson/python/ch-2.py
diff options
context:
space:
mode:
authorPacky Anderson <packy@cpan.org>2023-11-17 00:26:15 -0500
committerPacky Anderson <packy@cpan.org>2023-11-17 00:26:15 -0500
commitf7a9faeb822c20217b1d1c00a008bd247397c3a8 (patch)
tree3c107c6e50b27f333127ef8fb3722a32493f7c8b /challenge-243/packy-anderson/python/ch-2.py
parent1a59d9883fd5f113ea3b6ad4c045dcdc87fcdb83 (diff)
downloadperlweeklychallenge-club-f7a9faeb822c20217b1d1c00a008bd247397c3a8.tar.gz
perlweeklychallenge-club-f7a9faeb822c20217b1d1c00a008bd247397c3a8.tar.bz2
perlweeklychallenge-club-f7a9faeb822c20217b1d1c00a008bd247397c3a8.zip
Challenge 243 solutions by Packy Anderson
* Raku * Perl * Python 1 Blog post
Diffstat (limited to 'challenge-243/packy-anderson/python/ch-2.py')
-rwxr-xr-xchallenge-243/packy-anderson/python/ch-2.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-243/packy-anderson/python/ch-2.py b/challenge-243/packy-anderson/python/ch-2.py
new file mode 100755
index 0000000000..8b2172ab3a
--- /dev/null
+++ b/challenge-243/packy-anderson/python/ch-2.py
@@ -0,0 +1,24 @@
+#!/usr/bin/env python
+
+from math import trunc
+
+def floorSum(nums):
+ sum = 0;
+ for i in range(0, len(nums)):
+ for j in range(0, len(nums)):
+ sum += trunc(nums[i] / nums[j])
+ return sum
+
+def comma_join(arr):
+ return ', '.join(map(lambda i: str(i), arr))
+
+def solution(nums):
+ print(f'Input: @nums = ({comma_join(nums)})')
+ sum = floorSum(nums)
+ print(f'Output: {sum}')
+
+print('Example 1:')
+solution([2, 5, 9])
+
+print('\nExample 2:')
+solution([7, 7, 7, 7, 7, 7, 7])