import random


def uniformly_random(
        num_tasks,
        num_resources,
        rng_seed=None,
        verbose=False):
    """Random scheduling algorithm.

    Parameters
    ----------
    num_tasks : int
        Number of tasks
    num_resources : int
        Number of resources
    rng_seed : int [default=None]
        Seed for the random number generator
    verbose : bool [default=False]
        True if messages should be printed during scheduling

    Returns
    -------
    list of int
        Mapping of tasks to resources

    Notes
    -----
    The random algorithm chooses resources uniformly at random for each task.
    """
    if verbose:
        print(f'Random: starting with {num_tasks} tasks' +
              f' and {num_resources} resources.')
        if rng_seed is not None:
            print(f'- RNG seed is {rng_seed}.')
    # Empty mapping
    mapping = [None] * num_tasks

    # Sets the RNG seed
    random.seed(rng_seed)

    # Iterates mapping tasks to resources in order
    for task in range(num_tasks):
        resource = random.randrange(num_resources)
        mapping[task] = resource
        if verbose:
            print(f'- Mapping task {task} to resource {resource}')

    return mapping