Skip to content

Commit

Permalink
1 Fixes filenames
Browse files Browse the repository at this point in the history
  • Loading branch information
mikelane committed Oct 5, 2018
1 parent 0d95399 commit f77a3b2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
29 changes: 12 additions & 17 deletions beginner/sum-of-all-numbers-rosdyana.py
Original file line number Diff line number Diff line change
@@ -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
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 f77a3b2

Please sign in to comment.