Untitled

mail@pastecode.io avatar
unknown
python
22 days ago
512 B
1
Indexable
Never
    def draw_star_pattern(self, n: int):
        def helper(i, cur_len, delta):
            if delta == -1 and i == 0:
                return
            
            print("*", end="")
            cur_len += 1
            
            if i == cur_len:
                print("")
                if i == n:
                    helper(i-1, 0, -1)
                else:
                    helper(i + delta, 0, delta)
            else:
                helper(i, cur_len, delta)
            

        helper(1, 0, 1)
Leave a Comment