diff options
Diffstat (limited to 'challenge-172/laurent-rosenfeld/python/ch-2.py')
| -rw-r--r-- | challenge-172/laurent-rosenfeld/python/ch-2.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/challenge-172/laurent-rosenfeld/python/ch-2.py b/challenge-172/laurent-rosenfeld/python/ch-2.py new file mode 100644 index 0000000000..f99c3098cb --- /dev/null +++ b/challenge-172/laurent-rosenfeld/python/ch-2.py @@ -0,0 +1,17 @@ +def median(n): + c = len(n) + return n[int((c - 1) / 2)] if c % 2 != 0 else (n[int(c/2 -1)] + n[int(c/2)])/2 + + +def summary(input): + min = input[0] + max = input[-1] + med = median(input) + lower_half = list(filter(lambda p: p < med, input)) + # print(lower_half) + first_quart = median(lower_half) + third_quart = median(list(filter(lambda p: p > med, input))) + return(min, first_quart, med, third_quart, max) + +moons = sorted([0, 0, 1, 2, 63, 61, 27, 13]) +print(summary(moons)); |
