day 1: no special case needed for single digit
This commit is contained in:
parent
4b800f8921
commit
b51a6213bf
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue