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))
好像有什么不对的地方,明天再看看
时间: 2024-10-11 14:20:37