adventofcode/2024/02/part2.ts

14 lines
353 B
TypeScript

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;
}