day 1: no special case needed for single digit

This commit is contained in:
Wouter Groeneveld 2023-12-01 13:39:55 +01:00
parent 4b800f8921
commit b51a6213bf
1 changed files with 1 additions and 1 deletions

View File

@ -5,7 +5,7 @@ module.exports.solve = function(input) {
.filter(line => line.length > 1)
.map(line => {
const nrs = line.replace(/[^0-9.]/g, '')
return nrs.length == 1 ? parseInt(nrs[0] + nrs[0]) : parseInt(nrs[0] + nrs[nrs.length - 1])
return parseInt(nrs[0] + nrs[nrs.length - 1])
})
.reduce((a, b) => a + b)
}