class Solution: def countAndSay(self, n: int) -> str: current = "1" if n == 1: return current for index in range(1, n): count = 0 say = "" point = 0 for i in range(len(current)): if current[i] == current[point]: count += 1 else: say += str(count)+str(current[point]) point = i count = 1 if i == len(current)-1: say += str(count)+str(current[point]) current = say return current def main(): s = Solution() print(s.countAndSay(1)) # "1" print(s.countAndSay(2)) # "11" if __name__ == '__main__': main()