adventofcode/2024/02/part2.ts

14 lines
353 B
TypeScript
Raw Permalink Normal View History

2024-12-04 20:46:05 +00:00
import { isSafe } from './part1.ts';
function isSafeDampened(report: number[]) {
for( let i =0; i < report.length; i++) {
const copy = [...report];
copy.splice( i, 1);
if( isSafe(copy) ) return true;
}
return false;
}
export function solve(reports: number[][]) {
return reports.filter(isSafeDampened).length;
}