diff options
Diffstat (limited to 'challenge-257/packy-anderson/python/ch-1.py')
| -rwxr-xr-x | challenge-257/packy-anderson/python/ch-1.py | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/challenge-257/packy-anderson/python/ch-1.py b/challenge-257/packy-anderson/python/ch-1.py new file mode 100755 index 0000000000..85c2dd0c36 --- /dev/null +++ b/challenge-257/packy-anderson/python/ch-1.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python + +def smallerThan(ints): + counts = [] + for i in range(len(ints)): + counts.append(0) + for j in range(len(ints)): + if i != j and ints[j] < ints[i]: counts[i] += 1 + return counts + +def comma_join(arr): + return ', '.join(map(lambda i: str(i), arr)) + +def solution(ints): + print(f'Input: @ints = ({comma_join(ints)})') + counts = smallerThan(ints) + print(f'Output: ({comma_join(counts)})') + +print('Example 1:') +solution([5, 2, 1, 6]) + +print('\nExample 2:') +solution([1, 2, 0, 3]) + +print('\nExample 3:') +solution([0, 1]) + +print('\nExample 4:') +solution([9, 4, 9, 2])
\ No newline at end of file |
