Skip to content

Latest commit

 

History

History
46 lines (27 loc) · 753 Bytes

Sum_without_highest_and_lowest_number.md

File metadata and controls

46 lines (27 loc) · 753 Bytes

CodeWars Python Solutions


Sum without highest and lowest number

Take 2 strings s1 and s2 including only letters from a to z. Return a new sorted string, the longest possible, containing distinct letters,

  • each taken only once - coming from s1 or s2.

Examples

a = "xyaabbbccccdefww"
b = "xxxxyyyyabklmopq"
longest(a, b) -> "abcdefklmopqwxy"

a = "abcdefghijklmnopqrstuvwxyz"
longest(a, a) -> "abcdefghijklmnopqrstuvwxyz"

Given Code

def sum_array(arr):
    pass

Solution

def sum_array(arr):
    return 0 if arr == None  or len(arr) < 3 else sum(arr) - (max(arr) + min(arr))

See on CodeWars.com