diff options
Diffstat (limited to 'challenge-252/deadmarshal/python')
| -rw-r--r-- | challenge-252/deadmarshal/python/ch1.py | 10 | ||||
| -rw-r--r-- | challenge-252/deadmarshal/python/ch2.py | 12 |
2 files changed, 22 insertions, 0 deletions
diff --git a/challenge-252/deadmarshal/python/ch1.py b/challenge-252/deadmarshal/python/ch1.py new file mode 100644 index 0000000000..803e722eb5 --- /dev/null +++ b/challenge-252/deadmarshal/python/ch1.py @@ -0,0 +1,10 @@ +#!/usr/bin/env python + +def special_numbers(arr): + ret = [] + for i in range(len(arr)): + if len(arr) % (i+1) == 0: ret.append(arr[i]**2) + return sum(ret) + +print(special_numbers([1,2,3,4])) +print(special_numbers([2,7,1,19,18,3])) diff --git a/challenge-252/deadmarshal/python/ch2.py b/challenge-252/deadmarshal/python/ch2.py new file mode 100644 index 0000000000..17868430ab --- /dev/null +++ b/challenge-252/deadmarshal/python/ch2.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python + +def unique_sum_zero(n): + ret = [] + for i in range(1,n//2+1): + ret += [i,-i] + if n % 2 != 0: ret.append(0) + return ret + +print(unique_sum_zero(5)) +print(unique_sum_zero(3)) +print(unique_sum_zero(1)) |
