diff --git a/days/05/rust/part1/Cargo.toml b/days/05/rust/part1/Cargo.toml new file mode 100644 index 0000000..d53465e --- /dev/null +++ b/days/05/rust/part1/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "part1" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/days/05/rust/part1/src/main.rs b/days/05/rust/part1/src/main.rs new file mode 100644 index 0000000..ca6e4a5 --- /dev/null +++ b/days/05/rust/part1/src/main.rs @@ -0,0 +1,32 @@ +use std::fs; + +fn parse_steps(content: &str) -> Vec>> { + let mut steps: Vec>> = Vec::new(); + steps +} + +fn main() { + let filepath: &str = "../../data/sample.txt"; + + let contents = fs::read_to_string(filepath).expect("Should have been hable to read the file"); + + let mut lines = contents.lines(); + let seeds: Vec<&str> = lines + .next() + .unwrap() + .split(": ") + .nth(1) + .expect("Should have a seed") + .split(" ") + .collect(); + let seeds: Vec = seeds + .iter() + .map(|string| { + let number: u32 = string.trim().parse().unwrap(); + number + }) + .collect(); + for seed in seeds { + println!("{:?}", seed); + } +}