From c06faa97ff66e3ba757d50f89d953a61e8c5f95c Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Thu, 25 Jan 2024 17:45:13 +0100 Subject: [PATCH] extract '#' as galaxies --- src/day11/mod.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/day11/mod.rs b/src/day11/mod.rs index 727a0e3..3c97ca9 100644 --- a/src/day11/mod.rs +++ b/src/day11/mod.rs @@ -8,8 +8,29 @@ pub fn part_two() { #[allow(dead_code)] pub fn part_one() { let input = setup(); + + let mut galaxies = extract(input); } +fn extract(symbols: Vec>) -> Vec { + let mut galaxies = Vec::new(); + + for (y, line) in symbols.iter().enumerate() { + for (x, symbol) in line.iter().enumerate() { + if symbol.as_str() == "." { continue; } + galaxies.push(Galaxy { x, y }); + } + } + + galaxies +} + +struct Galaxy { + x: usize, + y: usize, +} + + fn setup() -> Vec> { let name = "day11"; println!("Executing module '{name}' entrypoint . . . ");