22 lines
536 B
TypeScript
22 lines
536 B
TypeScript
import fs from 'node:fs';
|
|
|
|
|
|
const file = fs.readFileSync('./2025/inputs/5').toString();
|
|
const [strRanges, strIngredients] = file.split("\n\n").map(e => e.split("\n"))
|
|
const ingredients = strIngredients.map(Number)
|
|
const ranges = strRanges.map(e => {
|
|
const [min, max] = e.split("-")
|
|
return [Number(min), Number(max)]
|
|
})
|
|
|
|
let count = 0
|
|
for (const i of ingredients) {
|
|
const fresh = ranges.some(([min, max]: number[]) => {
|
|
return (i >= min && max >= i)
|
|
})
|
|
if (fresh) {
|
|
count++
|
|
}
|
|
}
|
|
|
|
console.log(count) |