Skip to content

generate

cl_forge.verify.generate

generate(
    n: int, min: int, max: int, seed: int | None = None
) -> list[dict[str, int | str]]

Generates a list of unique Chilean RUT/RUN numbers with their verifier digits.

Parameters:

Name Type Description Default
n int

The number of RUT/RUNs to generate.

required
min int

The minimum value for the numeric part of the RUT/RUN.

required
max int

The maximum value for the numeric part of the RUT/RUN.

required
seed int | None

An optional seed for the random number generator to ensure reproducibility. If None, a random seed is used.

None

Returns:

Type Description
list[dict[str, int | str]]

A list of dictionaries, each containing 'correlative' and 'verifier' keys representing the generated RUT/RUN numbers.

Raises:

Type Description
InvalidInput
  • If n is less than or equal to 0.
  • If min and/or max are negative.
  • If seed is given and is negative.
InvalidRange

If min is greater than or equal to max.

InsufficientRange

If the range between min and max is too small to generate n unique RUT/RUNs.

Source code in src/cl_forge/core/impl/rs_cl_forge/rs_verify.pyi
def generate(
        n: int,
        min: int,  # noqa: A002
        max: int,  # noqa: A002
        seed: int | None = None
) -> list[dict[str, int | str]]:
    """
    Generates a list of unique Chilean RUT/RUN numbers with their verifier
    digits.

    Parameters
    ----------
    n : int
        The number of RUT/RUNs to generate.
    min : int
        The minimum value for the numeric part of the RUT/RUN.
    max : int
        The maximum value for the numeric part of the RUT/RUN.
    seed : int | None
        An optional seed for the random number generator to ensure
        reproducibility. If `None`, a random seed is used.

    Returns
    -------
    list[dict[str, int | str]]
        A list of dictionaries, each containing 'correlative' and 'verifier'
        keys representing the generated RUT/RUN numbers.

    Raises
    ------
    InvalidInput
        - If `n` is less than or equal to 0.
        - If `min` and/or `max` are negative.
        - If `seed` is given and is negative.
    InvalidRange
        If `min` is greater than or equal to `max`.
    InsufficientRange
        If the range between `min` and `max` is too small to generate `n`
        unique RUT/RUNs.
    """