diff --git a/2024/src/2024/day04/day04.ts b/2024/src/2024/day04/day04.ts index c1ddb99..76d6211 100644 --- a/2024/src/2024/day04/day04.ts +++ b/2024/src/2024/day04/day04.ts @@ -29,13 +29,10 @@ function solve_XMAS_Crosswords(grid: Grid): number { grid.forEach((value, cell) => { if (value === 'X') { - const neighbors = getNeighbors(Coord.deserialize(cell), grid, true); - if (neighbors.some(n => n === 'M')) { - const all = getAllCandidates(Coord.deserialize(cell), grid); + const all = getAllCandidates(Coord.deserialize(cell), grid); - const localXmasCount: number = all.filter(s => s === 'XMAS').length; - xmasCount += localXmasCount; - } + const localXmasCount: number = all.filter(s => s === 'XMAS').length; + xmasCount += localXmasCount; } }); @@ -65,9 +62,7 @@ function getAllCandidates(cell: Coord, grid: Grid) { .filter(c => grid.has(c.serialize())) .map(c => grid.get(c.serialize())); - if (values.length === 4) { - candidates.push(values.join('')); - } + candidates.push(values.join('')); }); return candidates;