From ba312a3aef21c96c214256d272eb66a9ae031ea7 Mon Sep 17 00:00:00 2001 From: thatscringebro Date: Wed, 4 Dec 2024 20:56:08 -0500 Subject: [PATCH] Started TP3 --- Session1/{ => TP3}/Tp3.pdf | Bin Session1/TP3/simon/Cargo.toml | 7 +++++++ Session1/TP3/simon/src/main.rs | 20 ++++++++++++++++++++ 3 files changed, 27 insertions(+) rename Session1/{ => TP3}/Tp3.pdf (100%) create mode 100644 Session1/TP3/simon/Cargo.toml create mode 100644 Session1/TP3/simon/src/main.rs diff --git a/Session1/Tp3.pdf b/Session1/TP3/Tp3.pdf similarity index 100% rename from Session1/Tp3.pdf rename to Session1/TP3/Tp3.pdf diff --git a/Session1/TP3/simon/Cargo.toml b/Session1/TP3/simon/Cargo.toml new file mode 100644 index 0000000..0a87dbe --- /dev/null +++ b/Session1/TP3/simon/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "simon" +version = "0.1.0" +edition = "2021" + +[dependencies] +rand = "0.8.5" diff --git a/Session1/TP3/simon/src/main.rs b/Session1/TP3/simon/src/main.rs new file mode 100644 index 0000000..a086932 --- /dev/null +++ b/Session1/TP3/simon/src/main.rs @@ -0,0 +1,20 @@ +use rand::prelude::*; + +fn main() { + println!("Hello, world!"); + let turns: Vec = gen_turn_array(); + for turn in turns { + println!("{}", turn); + } +} + +fn gen_turn_array() -> Vec { + let mut rng = rand::thread_rng(); + let mut vec = Vec::with_capacity(255); + + for _ in 0..255 { + vec.push(rng.gen_range(1..5)); + } + + return vec; +}