Added input. Reading file and puting them in a vector.
This commit is contained in:
parent
7c722de821
commit
ae8c7447db
2 changed files with 2508 additions and 0 deletions
2500
rust/day2/input
Normal file
2500
rust/day2/input
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,8 +1,16 @@
|
|||
use std::fs::read_to_string;
|
||||
use std::collections::HashMap;
|
||||
mod rps;
|
||||
|
||||
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 player = converter.get(&'Y').unwrap().battle(converter.get(&'A').unwrap());
|
||||
println!("First battle = {}", player);
|
||||
|
|
Loading…
Add table
Reference in a new issue