美文网首页python
8 kyu Short Long Short

8 kyu Short Long Short

作者: Python_Camp | 来源:发表于2020-07-21 15:00 被阅读0次
Given 2 strings, a and b, return a string of the form short+long+short, with the shorter string on the outside and the longer string on the inside. The strings will not be the same length, but they may be empty ( length 0 ).

For example:

solution("1", "22") # returns "1221"
solution("22", "1") # returns "1221"

1st WOAILIAN@codewars

def solution(a, b):
      return a+b+a if len(b) > len(a) else b+a+b

def solution(a, b):
    if len(a) > len(b):
        return b+a+b
    else:
        return a+b+a

#8 kyu Beginner Series #2 Clock
def past(h, m, s):
    return 3600000 * h + 60000 * m + 1000 * s

这是今天最早提交成功的李同学,只上了7节课,奥力给

2nd 李老师 八爪鱼写字

def solution(a, b):    
    return a + b + a if len(a) < len(b) else b + a +b

3rd #周宏宇

def solution(a, b):
return a+b+a if len(b) > len(a) else b+a+b

相关文章

网友评论

    本文标题:8 kyu Short Long Short

    本文链接:https://www.haomeiwen.com/subject/fyeikktx.html