2025-05-27 22:33:40 -05:00
|
|
|
// https://adventofcode.com/2024/day/4
|
2025-05-27 22:10:38 -05:00
|
|
|
//
|
|
|
|
|
// Run command: cargo run ./input.txt
|
|
|
|
|
|
|
|
|
|
use std::env;
|
|
|
|
|
use std::error::Error;
|
|
|
|
|
use std::fs::File;
|
|
|
|
|
|
2025-05-27 22:26:05 -05:00
|
|
|
mod crossword;
|
2025-05-27 22:10:38 -05:00
|
|
|
|
2025-05-27 22:26:05 -05:00
|
|
|
use crate::crossword::Crossword;
|
2025-05-27 22:10:38 -05:00
|
|
|
|
|
|
|
|
fn main() -> Result<(), Box<dyn Error>> {
|
|
|
|
|
// Handle command input
|
|
|
|
|
let args: Vec<String> = env::args().collect();
|
|
|
|
|
if args.len() != 2 {
|
|
|
|
|
panic!(
|
|
|
|
|
"{} must be run with a single argument of files name!",
|
|
|
|
|
&args[0]
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
let input_file_string = &args[1];
|
|
|
|
|
|
|
|
|
|
let crossword = Crossword::new(File::open(input_file_string)?)?;
|
|
|
|
|
|
|
|
|
|
println!("{}", crossword);
|
2025-05-28 17:01:56 -05:00
|
|
|
println!("n: {}", crossword.n(3,3).take(4));
|
|
|
|
|
println!("ne: {}", crossword.ne(3,3).take(4));
|
|
|
|
|
println!("e: {}", crossword.e(3,3).take(4));
|
|
|
|
|
println!("se: {}", crossword.se(3,3).take(4));
|
|
|
|
|
println!("s: {}", crossword.s(3,3).take(4));
|
|
|
|
|
println!("sw: {}", crossword.sw(3,3).take(4));
|
|
|
|
|
println!("w: {}", crossword.w(3,3).take(4));
|
|
|
|
|
println!("nw: {}", crossword.nw(3,3).take(4));
|
2025-05-27 22:10:38 -05:00
|
|
|
|
|
|
|
|
Ok(())
|
2025-05-26 15:47:33 -05:00
|
|
|
}
|