diff options
Diffstat (limited to 'challenge-243/packy-anderson/python/ch-2.py')
| -rwxr-xr-x | challenge-243/packy-anderson/python/ch-2.py | 24 |
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]) |
