<jupyter_start><jupyter_text>Given a non-negative integer numRows, generate the first numRows of Pascal's triangle.<jupyter_code># n = 5
def sol(n):
    if n == 1:
        return [[1]]
    if n == 2:
        return [[1], [1, 1]]
    if n == 3:
        return [[1], [1, 1], [1, 2, 1]]
    if n > 3:
        z = [[1], [1, 1], [1, 2, 1]]
        a = [1, 2, 1]
        for j in range(n - 3):
            x = []
            x.append(1)
            for i in range(len(a)-1):
                x.append(a[i] + a[i + 1])
            x.append(1)
            a = x.copy()
            z.append(a)
        return z
sol(7)
n = 4
for j in range(4 - 3):
    z = [[1], [1, 1], [1, 2, 1]]
    a = [1, 2, 1]
    x = []
    x.append(1)
    for i in range(2):
        x.append(a[i] + a[i + 1])
    x.append(1)
    a = x.copy()
    z.append(a)
    print(x)
    print(a)
    print(z)
z = [[1], [1, 1], [1, 2, 1]]
a = [1, 2, 1]
for j in range(7 - 3):
    x = []
    x.append(1)
    for i in range(len(a)-1):
        x.append(a[i] + a[i + 1])
    x.append(1)
    a = x.copy()
    z.append(a)
    print(z)<jupyter_output>[[1], [1, 1], [1, 2, 1], [1, 3, 3, 1]]
[[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1]]
[[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1]]
[[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1], [1, 6, 15, 20, 15, 6, 1]]<jupyter_text>풀이<jupyter_code>def generate(n):
        if n == 0:
            return []
        if n == 1:
            return [[1]]
        if n == 2:
            return [[1], [1, 1]]
        if n == 3:
            return [[1], [1, 1], [1, 2, 1]]
        if n > 3:
            z = [[1], [1, 1], [1, 2, 1]]
            a = [1, 2, 1]
            for j in range(n - 3):
                x = []
                x.append(1)
                for i in range(len(a)-1):
                    x.append(a[i] + a[i + 1])
                x.append(1)
                a = x[:]
                z.append(a)
            return z
generate(4)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.22436849925705796, 'fraction_numerical': 0.08519068845963348, 'mean_word_length': 1.3933649289099526, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '485518', 'license': 'MIT', 'n_tokens_mistral': 993, 'n_tokens_neox': 874, 'n_words': 272, 'path': ".ipynb_checkpoints/[leetcode] 118. Pascal's Triangle-checkpoint.ipynb", 'repo_name': 'foxsayy/python', 'size': '2019'}