Skip to content

Instantly share code, notes, and snippets.

@ariesabao
Created May 7, 2018 22:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ariesabao/4a0ecbeae7d5e2dc0cac87b4005b151a to your computer and use it in GitHub Desktop.
Save ariesabao/4a0ecbeae7d5e2dc0cac87b4005b151a to your computer and use it in GitHub Desktop.
Codewars | Sum of two lowest positive integers
"""Create a function that returns the sum of the two lowest positive numbers
given an array of minimum 4 integers. No floats or empty arrays will be
passed.
For example, when an array is passed like [19, 5, 42, 2, 77],
the output should be 7.
[10, 343445353, 3453445, 3453545353453] should return 3453455.
Hint: Do not modify the original array. """
#This is my noob entry on codewars challenge
def sum_two_smallest_numbers(numbers):
numbers.sort()
result = sum(numbers[0:2])
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment