2020 day 1 and 2 (:
This commit is contained in:
parent
cbc02f04d5
commit
de2fa19311
6 changed files with 1276 additions and 0 deletions
19
2020/01/part1.js
Normal file
19
2020/01/part1.js
Normal file
|
@ -0,0 +1,19 @@
|
|||
const fs = require('fs');
|
||||
|
||||
let data = fs.readFileSync('input.txt', 'utf-8');
|
||||
let lines = data.split('\n').map(x => parseInt(x));
|
||||
|
||||
let done = false
|
||||
lines.forEach((number, index) => {
|
||||
if (done) {return}
|
||||
lines.forEach((number2, index2) => {
|
||||
if (done) {return}
|
||||
if (index != index2) {
|
||||
//console.log(number, number2)
|
||||
if (number + number2 == 2020){
|
||||
done = true
|
||||
console.log(number, number2, number*number2)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue