Crates.io | round_robin |
lib.rs | round_robin |
version | 1.0.1 |
source | src |
created_at | 2021-05-22 19:59:51.406803 |
updated_at | 2024-07-06 20:27:16.699323 |
description | Create a vector of rounds and their respective matches in a tournament, using the Round-robin algorithm. |
homepage | |
repository | https://github.com/savi8sant8s/round_robin |
max_upload_size | |
id | 400916 |
size | 6,789 |
Create a vector of rounds using the Round-robin algorithm.
let teams = vec!["A", "B", "C", "D"];
let rounds = generate_rounds(teams);
// [("A", "D"), ("C", "B"), ("A", "C"), ("B", "D"), ("A", "C"), ("B", "D")]
let teams = vec![1, 2, 3, 4];
let rounds = generate_rounds(teams);
// [(1, 4), (3, 2), (1, 3), (2, 4), (1, "C"), (2, 4)]
#[derive(Debug, Clone)]
struct Team { name: &'static str }
let teams = vec![
Team { name: "Liverpool" }, Team { name: "Chelsea" },
Team { name: "M. City" }, Team { name: "M. United" },
];
let rounds = generate_rounds(teams);
// [(Team { name: "Liverpool" }, Team { name: "M. United" }), (Team { name: "M. City" }, Team { name: "Chelsea" }), (Team { name: "Liverpool" }, Team { name: "M. City" }), (Team { name: "Chelsea" }, Team { name: "M. United" }), (Team { name: "Liverpool" }, Team { name: "M. City" }), (Team { name: "Chelsea" }, Team { name: "M. United" })]