mirror of
https://github.com/Rhelvetican/aoc2024.git
synced 2024-12-23 06:51:40 +00:00
day 4.1
This commit is contained in:
parent
ed5ac4446c
commit
d86f7b2ab3
1 changed files with 12 additions and 10 deletions
|
@ -80,11 +80,12 @@ impl AocSolution for AocDayFourSolution {
|
||||||
let xmas = XmasGrid::new(Self::INPUT);
|
let xmas = XmasGrid::new(Self::INPUT);
|
||||||
let mut tmp = 0;
|
let mut tmp = 0;
|
||||||
|
|
||||||
for (&pos, &ch) in &xmas.grid {
|
xmas.grid
|
||||||
if ch == 'X' {
|
.iter()
|
||||||
tmp += xmas.find_xmas(pos)
|
.filter(|(_, &ch)| ch == 'X')
|
||||||
}
|
.for_each(|(&pt, _)| {
|
||||||
}
|
tmp += xmas.find_xmas(pt);
|
||||||
|
});
|
||||||
|
|
||||||
tmp as Self::Output
|
tmp as Self::Output
|
||||||
}
|
}
|
||||||
|
@ -93,11 +94,12 @@ impl AocSolution for AocDayFourSolution {
|
||||||
let xmas = XmasGrid::new(Self::INPUT);
|
let xmas = XmasGrid::new(Self::INPUT);
|
||||||
let mut tmp = 0;
|
let mut tmp = 0;
|
||||||
|
|
||||||
for (&pos, &ch) in &xmas.grid {
|
xmas.grid
|
||||||
if ch == 'A' {
|
.iter()
|
||||||
tmp += xmas.find_x_mas(pos)
|
.filter(|(_, &ch)| ch == 'A')
|
||||||
}
|
.for_each(|(&pt, _)| {
|
||||||
}
|
tmp += xmas.find_x_mas(pt);
|
||||||
|
});
|
||||||
|
|
||||||
tmp as Self::Output
|
tmp as Self::Output
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue