Lochard avatar

Codewars Kata — Sum of two lowest positive integers

lochard

Published: 19 Aug 2023 › Updated: 19 Aug 2023Codewars Kata — Sum of two lowest positive integers

Codewars Kata — 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 positive integers. No floats or non-positive integers 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.

def sum_two_smallest_numbers( numbers ):
    return sum( sorted( numbers )[ : 2 ] )

Leave Codewars Kata — Sum of two lowest positive integers to:

Written by

Asylum seeker who hopes to be rid of authoritarian and their surveillance.

Read more #programming posts


Best Posts From Lochard

We have not curated any of lochard's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Lochard