day 1 from desktop
This commit is contained in:
parent
dc0f15fe6e
commit
1a085be4db
1016
01/input.txt
Normal file
1016
01/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
3
01/part1.js
Normal file
3
01/part1.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
var input = require("fs").readFileSync("input.txt").toString();
|
||||||
|
var nums = input.split("\n").filter(a=>(a)).map(a=>(parseInt(a)));
|
||||||
|
console.log(nums.reduce((a,b)=>(a+b)));
|
16
01/part2.js
Normal file
16
01/part2.js
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
var input = require("fs").readFileSync("input.txt").toString();
|
||||||
|
var nums = input.split("\n").filter(a=>(a)).map(a=>(parseInt(a)));
|
||||||
|
var seen = {};
|
||||||
|
var total = 0;
|
||||||
|
while(true){
|
||||||
|
for(var i of nums){
|
||||||
|
total += i;
|
||||||
|
if(!seen[total]){
|
||||||
|
seen[total]=1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
console.log(total);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user