26 lines
553 B
Rust
26 lines
553 B
Rust
|
use std::io::{self, Write};
|
||
|
|
||
|
use day16::nim_winner;
|
||
|
|
||
|
fn main() {
|
||
|
let mut buffer = String::new();
|
||
|
|
||
|
print!("How many stones will you have during your turn? ");
|
||
|
io::stdout().flush().expect("Failed to flush stdout.");
|
||
|
|
||
|
io::stdin()
|
||
|
.read_line(&mut buffer)
|
||
|
.expect("Failed to read from stdin");
|
||
|
|
||
|
let stones = buffer
|
||
|
.trim()
|
||
|
.parse()
|
||
|
.expect("Your input is not a valid number");
|
||
|
|
||
|
if nim_winner(stones) {
|
||
|
println!("You will win!");
|
||
|
} else {
|
||
|
println!("You will lose!");
|
||
|
}
|
||
|
}
|