100-days-of-rust/Week-04/Day-26_Briefcase-Lock/day26/src/main.rs

25 lines
594 B
Rust

use std::io::{self, Write};
use day26::min_turns;
fn read_lock(request: &str) -> String {
let mut buffer = String::new();
print!("{}", request);
io::stdout().flush().expect("Failed to flush");
io::stdin()
.read_line(&mut buffer)
.expect("Failed to read line");
buffer.trim().to_owned()
}
fn main() {
let current_lock = read_lock("Insert the current lock: ");
let target_lock = read_lock("Insert the target lock: ");
let result = min_turns(&current_lock, &target_lock);
println!("The minimum number of turns required is {}", result);
}