From 3affea8701e07e117303daed5053540f9a74d84b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Ortega=20Froysa?= Date: Thu, 30 Jun 2022 17:59:19 +0200 Subject: [PATCH] Generate boxes. --- src/main.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 3ec4edf..fe35497 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,6 +22,20 @@ * distribution. */ +extern crate rand; + fn main() { - println!("Hello, world!"); + let size = 100; + let mut boxes:Vec = Vec::with_capacity(size as usize); + + { + let mut nums:Vec = (1..size+1).collect(); + + for _i in 0..nums.len() + { + let rand_i:usize = rand::random::() % nums.len(); + boxes.push(nums[rand_i]); + nums.remove(rand_i); + } + } }