黑猫

我觉得我每天吃饱喝足往床上一躺侧着身子玩手机的样子,简直就是对旧社会里大烟鬼子抽大烟的情景昨日重现。

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
def func(n):
    def calc_str(s):
        s = s.strip() if s is not None else ""
        s = s.upper()
        result = 0
        for c in s:
            result += 1 if c == "S" else 2
        return result
    result = list()
    if n == 0:
        result.append("")
    elif n == 1:
        result.append("S")
    else:
        offset = -1
        while (n + offset) >= 0:
            for s in func(n + offset):
                if calc_str(s + "S") == n:
                    result.append(s + "S")
                if calc_str(s + "L") == n:
                    result.append(s + "L")
            offset -= 1
    return result
    
print(func(6))

好像有什么不对的地方,明天再看看

posted on 2015-11-12 22:24  amtoor  阅读(355)  评论(0编辑  收藏  举报