const{readFile}=require('./reader');const{parseInput,processGenerations,sumPots}=require('./12-common');(async()=>{constlines=awaitreadFile('12-input.txt');const{initialState,notes}=parseInput(lines);constlastGeneration=processGenerations(initialState,notes,20,false);constpotsSum=sumPots(lastGeneration);console.log(`The sum of the numbers of all pots is ${potsSum}`);})();
12b.js
const{readFile}=require('./reader');const{parseInput,processGeneration,processGenerations,sumPots}=require('./12-common');(async()=>{constlines=awaitreadFile('12-input.txt');const{initialState,notes}=parseInput(lines);constinitialBatch=processGenerations(initialState,notes,160,false);constinitialSum=sumPots(initialBatch);console.log(`The sum for the first 160 batch is ${initialSum}`);constdiffBatch=processGeneration(initialBatch,notes);constdiffSum=sumPots(diffBatch)-initialSum;console.log(`The sum for the just 1 generation is ${diffSum}`);consttotalSum=initialSum+diffSum*(50000000000-160);console.log(`The total sum is ${totalSum}`);})();
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
JavaScript solution
I'm gonna omit reader.js which is the same as the other solutions, but you can find it at github.com/themindfuldev/advent-of...
12-common.js
12a.js
12b.js