Skip to content

Commit 847de43

Browse files
committed
feat: unfinished 2024 day 4 part 1 code
1 parent c5bf4bb commit 847de43

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

Diff for: .gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Cargo.lock
1111
*.idea
1212
*.iml
1313
*input.txt
14+
*input

Diff for: 2024/day-4/d4-p1/Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "d4-p1"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[dependencies]

Diff for: 2024/day-4/d4-p1/src/main.rs

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
fn main() {
2+
let input = include_str!("../../input");
3+
println!("{}", solve_input(input));
4+
}
5+
6+
fn solve_input(input: &str) -> u16 {
7+
// https://www.youtube.com/watch?v=tiLwW8StyBc
8+
let zoek = Woordzoeker::from(input);
9+
10+
zoek.find_str("XMAS");
11+
1
12+
}
13+
14+
#[derive(Debug)]
15+
struct Woordzoeker(Vec<Vec<char>>);
16+
17+
impl Woordzoeker {
18+
fn print(&self) {
19+
self.0.iter().for_each(|row| {
20+
println!("{}", row.iter().collect::<String>());
21+
});
22+
println!();
23+
}
24+
25+
fn rotate(&self) -> Self {
26+
let columns = self.0.len(); // (m) length
27+
let rows = self.0[0].len(); // (n) width
28+
29+
let mut rotated: Vec<Vec<char>> = vec![];
30+
for i in 0..rows {
31+
let mut row = vec![];
32+
for j in 0..columns {
33+
row.push(self.0[j][i]);
34+
}
35+
rotated.push(row);
36+
}
37+
38+
Woordzoeker(rotated)
39+
}
40+
41+
fn find_str(&self, target: &str) {
42+
}
43+
}
44+
45+
impl From<&str> for Woordzoeker {
46+
fn from(aoc_input: &str) -> Self {
47+
Woordzoeker(
48+
aoc_input
49+
.lines()
50+
.map(|line| line.chars().collect())
51+
.collect()
52+
)
53+
}
54+
}

0 commit comments

Comments
 (0)