Adding gitignore updates, changing around day4 to add directional based handling.
This commit is contained in:
parent
a98a34a23c
commit
d6d310fcc8
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
/target
|
/target
|
||||||
2016/twenty16/target
|
2016/twenty16/target
|
||||||
2024/rust/target
|
2024/rust/target
|
||||||
|
2023/rust/target
|
||||||
|
*/target
|
||||||
|
|||||||
@ -2,17 +2,32 @@ use crate::Solution;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
use std::process;
|
use std::process;
|
||||||
|
|
||||||
|
struct Direction {
|
||||||
|
x: i32,
|
||||||
|
y: i32,
|
||||||
|
}
|
||||||
|
|
||||||
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 file = fs::read_to_string("./inputs/day4test.txt").expect("Unable to parse file");
|
||||||
let search_map = build_search_map(&file);
|
let search_map = build_search_map(&file);
|
||||||
// @here you are Dan
|
let directions: Vec<(i32, i32)> = vec![
|
||||||
// this is now creating a vector which you can iterator over
|
(0,1), // N
|
||||||
// will need to work out logic to go through each letter
|
(0,-1), // S
|
||||||
// and detect if it is part of a match or now
|
(1,0), // E
|
||||||
// somehow keeping track of past matches
|
(-1,0), // W
|
||||||
// need to do in all directions and backwards
|
(1,1), // NE
|
||||||
// this is...complicated.
|
(-1,1), // NW
|
||||||
dbg!(search_map[0][2]);
|
(1,-1), // SE
|
||||||
|
(-1,-1), // SW
|
||||||
|
];
|
||||||
|
|
||||||
|
// idea 3.0
|
||||||
|
// iterate over each letter in the word search
|
||||||
|
// for each letter, build all possible words around it
|
||||||
|
// we know the character length is 4 (XMAS, SAMX)
|
||||||
|
// so if we have a given point, i.e. (3,4)
|
||||||
|
|
||||||
|
dbg!(directions[0].0);
|
||||||
|
|
||||||
// Return the solution
|
// Return the solution
|
||||||
let solution = Solution {
|
let solution = Solution {
|
||||||
@ -23,6 +38,7 @@ pub fn run_day_4() -> Solution {
|
|||||||
solution
|
solution
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Builds a searchable map.
|
||||||
fn build_search_map(row: &str) -> Vec<Vec<char>> {
|
fn build_search_map(row: &str) -> Vec<Vec<char>> {
|
||||||
let mut search_map: Vec<Vec<char>> = vec!();
|
let mut search_map: Vec<Vec<char>> = vec!();
|
||||||
for line in row.lines() {
|
for line in row.lines() {
|
||||||
@ -32,8 +48,7 @@ fn build_search_map(row: &str) -> Vec<Vec<char>> {
|
|||||||
search_map
|
search_map
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// converts a line into a vectory of chars
|
||||||
fn line_to_chars(row_line: &str) -> Vec<char> {
|
fn line_to_chars(row_line: &str) -> Vec<char> {
|
||||||
row_line.chars().collect()
|
row_line.chars().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user