From 0d953991a30fc64cb0fb31a757479a3c9a0d0e64 Mon Sep 17 00:00:00 2001 From: Michael Lane <mikelane@gmail.com> Date: Thu, 4 Oct 2018 18:54:23 -0700 Subject: [PATCH 1/2] 1 Completes challenge and adds doctests --- beginner/sum-of-all-numbers-rosdyana.py | 29 +++++++++++++++---------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/beginner/sum-of-all-numbers-rosdyana.py b/beginner/sum-of-all-numbers-rosdyana.py index 0eca840..5b6178c 100644 --- a/beginner/sum-of-all-numbers-rosdyana.py +++ b/beginner/sum-of-all-numbers-rosdyana.py @@ -1,13 +1,18 @@ +from typing import List -def sum_all(list_input): - result = 0 - # find the max and min on the list - firstnum = min(list_input) - secondnum = max(list_input) - # in case the list contain same number - if list_input[0] == list_input[1]: - return list_input[0] - # start to sum it - for i in range(firstnum, secondnum+1): - result += i - return result \ No newline at end of file + +def sum_all(list_input: List[int]) -> int: + """Challenge + + - Write a function called sum_all() that takes a list of two numbers. + - Return the sum of those two numbers plus the sum of all the numbers between them. + + Notes: + The lowest number will not always come first + + >>> sum_all([1, 4]) + 10 + >>> sum_all([4, 1]) + 10 + """ + return sum(range(min(list_input), max(list_input) + 1)) From f77a3b2e7cac3c00f44d143979f35e892ea79f2b Mon Sep 17 00:00:00 2001 From: Michael Lane <mikelane@gmail.com> Date: Thu, 4 Oct 2018 19:44:15 -0700 Subject: [PATCH 2/2] 1 Fixes filenames --- beginner/sum-of-all-numbers-rosdyana.py | 29 ++++++++++--------------- beginner/sum_of_all_numbers_mikelane.py | 18 +++++++++++++++ 2 files changed, 30 insertions(+), 17 deletions(-) create mode 100644 beginner/sum_of_all_numbers_mikelane.py diff --git a/beginner/sum-of-all-numbers-rosdyana.py b/beginner/sum-of-all-numbers-rosdyana.py index 5b6178c..8c8da4c 100644 --- a/beginner/sum-of-all-numbers-rosdyana.py +++ b/beginner/sum-of-all-numbers-rosdyana.py @@ -1,18 +1,13 @@ -from typing import List - -def sum_all(list_input: List[int]) -> int: - """Challenge - - - Write a function called sum_all() that takes a list of two numbers. - - Return the sum of those two numbers plus the sum of all the numbers between them. - - Notes: - The lowest number will not always come first - - >>> sum_all([1, 4]) - 10 - >>> sum_all([4, 1]) - 10 - """ - return sum(range(min(list_input), max(list_input) + 1)) +def sum_all(list_input): + result = 0 + # find the max and min on the list + firstnum = min(list_input) + secondnum = max(list_input) + # in case the list contain same number + if list_input[0] == list_input[1]: + return list_input[0] + # start to sum it + for i in range(firstnum, secondnum+1): + result += i + return result diff --git a/beginner/sum_of_all_numbers_mikelane.py b/beginner/sum_of_all_numbers_mikelane.py new file mode 100644 index 0000000..5b6178c --- /dev/null +++ b/beginner/sum_of_all_numbers_mikelane.py @@ -0,0 +1,18 @@ +from typing import List + + +def sum_all(list_input: List[int]) -> int: + """Challenge + + - Write a function called sum_all() that takes a list of two numbers. + - Return the sum of those two numbers plus the sum of all the numbers between them. + + Notes: + The lowest number will not always come first + + >>> sum_all([1, 4]) + 10 + >>> sum_all([4, 1]) + 10 + """ + return sum(range(min(list_input), max(list_input) + 1))