Files
advent-of-code/2021/day-8/part-1.ts
2022-11-24 11:55:20 +01:00

24 lines
414 B
TypeScript

import fs from 'fs'
const input = fs.readFileSync(__dirname + '/input.txt').toString()
.split('\n')
.map((it) => it.split('|')[1].split(' '))
function is1478(str: string): boolean {
return str.length === 2 || str.length === 4 || str.length === 3 || str.length === 7
}
let count = 0
for (const line of input) {
for (const item of line) {
if (is1478(item)) count++
}
}
console.log(
"Result:", count
)