Skip to content

Commit

Permalink
Merge pull request #18 from mikelane/beginner/#1/sum-of-all-numbers
Browse files Browse the repository at this point in the history
1 Completes challenge and adds doctests
  • Loading branch information
the-vampiire authored Oct 5, 2018
2 parents 4dda0eb + f77a3b2 commit e2ce683
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion beginner/sum-of-all-numbers-rosdyana.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ def sum_all(list_input):
# start to sum it
for i in range(firstnum, secondnum+1):
result += i
return result
return result
18 changes: 18 additions & 0 deletions beginner/sum_of_all_numbers_mikelane.py
Original file line number Diff line number Diff line change
@@ -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))

0 comments on commit e2ce683

Please sign in to comment.