34 lines
773 B
Rust
34 lines
773 B
Rust
use std::{
|
|
io::{self, Write},
|
|
process::exit,
|
|
};
|
|
|
|
use day37::breaking_records;
|
|
|
|
fn main() {
|
|
print!("Insert the scores separated by spaces: ");
|
|
io::stdout().flush().expect("Failed to flush stdout");
|
|
|
|
let mut buffer = String::new();
|
|
io::stdin()
|
|
.read_line(&mut buffer)
|
|
.expect("Failed to read line");
|
|
|
|
let scores: Vec<usize> = buffer
|
|
.split_whitespace()
|
|
.map(|x| match x.parse() {
|
|
Ok(x) => x,
|
|
Err(e) => {
|
|
eprintln!("{}", e);
|
|
exit(1);
|
|
}
|
|
})
|
|
.collect();
|
|
|
|
let result = breaking_records(&scores);
|
|
println!(
|
|
"Maria broke her records {} times for the most and {} for the least points.",
|
|
result.0, result.1
|
|
);
|
|
}
|