Adding initial processing of file into a searchable map.

This commit is contained in:
calcu1on 2025-03-29 22:08:18 -04:00
parent ea719c6881
commit 1aa91374c7

View File

@ -1,15 +1,39 @@
use crate::Solution; use crate::Solution;
use std::fs;
use std::process;
pub fn run_day_4() -> Solution { pub fn run_day_4() -> Solution {
let file = fs::read_to_string("./inputs/day4test.txt").expect("Unable to parse file");
let search_map = build_search_map(&file);
// @here you are Dan
// this is now creating a vector which you can iterator over
// will need to work out logic to go through each letter
// and detect if it is part of a match or now
// somehow keeping track of past matches
// need to do in all directions and backwards
// this is...complicated.
dbg!(search_map[0][2]);
// Lets solve day 4 here! // Return the solution
let solution = Solution { let solution = Solution {
day: 4, day: 4,
answer_1: "test".to_string(), answer_1: "test".to_string(),
answer_2: "another".to_string(), answer_2: "another".to_string(),
}; };
solution solution
} }
fn build_search_map(row: &str) -> Vec<Vec<char>> {
let mut search_map: Vec<Vec<char>> = vec!();
for line in row.lines() {
let char_vec: Vec<char> = line_to_chars(&line);
search_map.push(char_vec.clone());
}
search_map
}
fn line_to_chars(row_line: &str) -> Vec<char> {
row_line.chars().collect()
}