'''simple docstring'''




def __lowerCAmelCase					(				UpperCamelCase__							)      ->       None:
    __lowerCamelCase            =    generate_pascal_triangle(UpperCamelCase__							)
    for row_idx in range(UpperCamelCase__							):
        # Print left spaces
        for _ in range(num_rows - row_idx - 1							):
            print(end=''' '''							)
        # Print row values
        for col_idx in range(row_idx + 1							):
            if col_idx != row_idx:
                print(triangle[row_idx][col_idx]							,    end=''' '''							)
            else:
                print(triangle[row_idx][col_idx]							,    end=''''''							)
        print()






def __lowerCAmelCase					(				UpperCamelCase__							)      ->       list[list[int]]:

    if not isinstance(UpperCamelCase__							,    UpperCamelCase__							):
        raise TypeError('''The input value of \'num_rows\' should be \'int\''''							)

    if num_rows == 0:
        return []
    elif num_rows < 0:
        raise ValueError(
            '''The input value of \'num_rows\' should be greater than or equal to 0'''							)

    __lowerCamelCase            =    []
    for current_row_idx in range(UpperCamelCase__							):
        __lowerCamelCase            =    populate_current_row(UpperCamelCase__							,    UpperCamelCase__							)
        triangle.append(UpperCamelCase__							)
    return triangle






def __lowerCAmelCase					(				UpperCamelCase__							,    UpperCamelCase__							)      ->       list[int]:
    __lowerCamelCase            =    [-1] * (current_row_idx + 1)
    # first and last elements of current row are equal to 1
    __lowerCamelCase      ,    __lowerCamelCase            =    1, 1
    for current_col_idx in range(1							,    UpperCamelCase__							):
        calculate_current_element(
            UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__							)
    return current_row






def __lowerCAmelCase					(				UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__							,    )      ->       None:
    __lowerCamelCase            =    triangle[current_row_idx - 1][current_col_idx - 1]
    __lowerCamelCase            =    triangle[current_row_idx - 1][current_col_idx]
    __lowerCamelCase            =    above_to_left_elt + above_to_right_elt






def __lowerCAmelCase					(				UpperCamelCase__							)      ->       list[list[int]]:

    if not isinstance(UpperCamelCase__							,    UpperCamelCase__							):
        raise TypeError('''The input value of \'num_rows\' should be \'int\''''							)

    if num_rows == 0:
        return []
    elif num_rows < 0:
        raise ValueError(
            '''The input value of \'num_rows\' should be greater than or equal to 0'''							)

    __lowerCamelCase            =    [[1]]

    for row_index in range(1							,    UpperCamelCase__							):
        __lowerCamelCase            =    [0] + result[-1] + [0]
        __lowerCamelCase            =    row_index + 1
        # Calculate the number of distinct elements in a row
        __lowerCamelCase            =    sum(divmod(UpperCamelCase__							,    2							)							)
        __lowerCamelCase            =    [
            temp_row[i - 1] + temp_row[i] for i in range(1							,    distinct_elements + 1							)
        ]
        __lowerCamelCase            =    row_first_half[: (row_index + 1) // 2]
        row_second_half.reverse()
        __lowerCamelCase            =    row_first_half + row_second_half
        result.append(UpperCamelCase__							)

    return result






def __lowerCAmelCase					(				)      ->       None:
    from collections.abc import Callable
    from timeit import timeit

    def benchmark_a_function(UpperCamelCase__							,    UpperCamelCase__							) -> None:
        __lowerCamelCase            =    f"""{func.__name__}({value})"""
        __lowerCamelCase            =    timeit(f"""__main__.{call}"""							,    setup='''import __main__'''							)
        # print(f"{call:38} = {func(value)} -- {timing:.4f} seconds")
        print(f"""{call:38} -- {timing:.4f} seconds"""							)

    for value in range(15							):  # (1, 7, 14):
        for func in (generate_pascal_triangle, generate_pascal_triangle_optimized):
            benchmark_a_function(UpperCamelCase__							,    UpperCamelCase__							)
        print()


if __name__ == "__main__":
  import doctest

  doctest.testmod()
  benchmark()

'''simple docstring'''




import timeit

import numpy as np

import datasets
from datasets.arrow_writer import ArrowWriter
from datasets.features.features import _ArrayXD






def __lowerCAmelCase					(				UpperCamelCase__							)      ->       List[str]:
    def wrapper(*UpperCamelCase__							,    **UpperCamelCase__							):
        __lowerCamelCase            =    timeit.default_timer()
        __lowerCamelCase            =    func(*UpperCamelCase__							,    **UpperCamelCase__							)
        __lowerCamelCase            =    timeit.default_timer() - starttime
        return delta

    __lowerCamelCase            =    func.__name__

    return wrapper






def __lowerCAmelCase					(				UpperCamelCase__							,    UpperCamelCase__=1_00							,    UpperCamelCase__=None							)      ->       Dict:
    __lowerCamelCase            =    []
    __lowerCamelCase            =    seq_shapes or {}
    for i in range(UpperCamelCase__							):
        __lowerCamelCase            =    {}
        for col_id, (k, v) in enumerate(features.items()							):
            if isinstance(UpperCamelCase__							,    _ArrayXD							):
                __lowerCamelCase            =    np.random.rand(*v.shape							).astype(v.dtype							)
            elif isinstance(UpperCamelCase__							,    datasets.Value							):
                if v.dtype == "string":
                    __lowerCamelCase            =    '''The small grey turtle was surprisingly fast when challenged.'''
                else:
                    __lowerCamelCase            =    np.random.randint(10							,    size=1							).astype(v.dtype							).item()
            elif isinstance(UpperCamelCase__							,    datasets.Sequence							):
                while isinstance(UpperCamelCase__							,    datasets.Sequence							):
                    __lowerCamelCase            =    v.feature
                __lowerCamelCase            =    seq_shapes[k]
                __lowerCamelCase            =    np.random.rand(*UpperCamelCase__							).astype(v.dtype							)
            __lowerCamelCase            =    data

        dummy_data.append((i, example)							)

    return dummy_data






def __lowerCAmelCase					(				UpperCamelCase__							,    UpperCamelCase__							,    UpperCamelCase__=1_00							,    UpperCamelCase__=None							)      ->       Dict:
    __lowerCamelCase            =    generate_examples(UpperCamelCase__							,    num_examples=UpperCamelCase__							,    seq_shapes=UpperCamelCase__							)

    with ArrowWriter(features=UpperCamelCase__							,    path=UpperCamelCase__							) as writer:
        for key, record in dummy_data:
            __lowerCamelCase            =    features.encode_example(UpperCamelCase__							)
            writer.write(UpperCamelCase__							)

        __lowerCamelCase      ,    __lowerCamelCase            =    writer.finalize()

    if not num_final_examples == num_examples:
        raise ValueError(
            f"""Error writing the dataset, wrote {num_final_examples} examples but should have written {num_examples}."""							)

    __lowerCamelCase            =    datasets.Dataset.from_file(filename=UpperCamelCase__							,    info=datasets.DatasetInfo(features=UpperCamelCase__							)							)

    return dataset
