1
0
Fork 0

Added input. Reading file and puting them in a vector.

This commit is contained in:
Yohan Boujon 2023-10-11 17:00:35 +02:00
parent 7c722de821
commit ae8c7447db
2 changed files with 2508 additions and 0 deletions

2500
rust/day2/input Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,8 +1,16 @@
use std::fs::read_to_string;
use std::collections::HashMap; use std::collections::HashMap;
mod rps; mod rps;
fn main() fn main()
{ {
// Checking if the file is found.
let mut oponent : Vec<String> = read_to_string("input").unwrap().split_whitespace().map(|s| s.to_string()).collect();
let mut player = oponent.clone();
oponent.retain(|s| s == "A" || s == "B" || s == "C");
player.retain(|s| s == "X" || s == "Y" || s == "Z");
assert!(oponent.len() == player.len(), "Oponent and Player don't play as many turns.");
let converter : HashMap<char, rps::RockPaperScissors> = rps::get_converter(); let converter : HashMap<char, rps::RockPaperScissors> = rps::get_converter();
let player = converter.get(&'Y').unwrap().battle(converter.get(&'A').unwrap()); let player = converter.get(&'Y').unwrap().battle(converter.get(&'A').unwrap());
println!("First battle = {}", player); println!("First battle = {}", player);