def make_random_contest(ballot_count, candidate_count, format_cls,
                        json_contests_path, output_dir,
                        normalize=True, stdout=None):
    if stdout is None:
        stdout = sys.stdout

    format = format_cls()
    creator = contestgen.ContestCreator()

    with temp_ballots_resource() as ballots_resource:
        contest = creator.create_random(ballots_resource, ballot_count=ballot_count,
                                        candidate_count=candidate_count)
        if normalize:
            contest.ballots_resource.normalize()
        else:
            contest.normalize_ballots = False

        output_paths = format.write_contest(contest, output_dir=output_dir, stdout=stdout)
        if json_contests_path:
            jcmanage.add_contest_to_contests_file(contest, json_contests_path)

    return "\n".join(output_paths) + "\n" if output_paths else None
a.trim(shape)
dataset/ETHPy150Open cjerdonek/open-rcv/openrcv/scripts/commands.py/make_random_contest--crossover with--dataset/ETHPy150Open CountZer0/PipelineConstructionSet/python/maya/site-packages/pymel-1.0.5/extras/completion/py/pymel/util/arrays.py/Array.trim