-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (20 loc) · 994 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { getStringArrayFromInput, getStringArrayFromInputEmptyLine } = require('./utils');
if(process.argv.length < 3) {
throw new Error('Must provide argument, either all or desired day to run');
process.exit(1);
}
const arg = process.argv[2];
if (arg === 'all') {
for(let i = 1; i < 9; i++) {
const { solve1, solve2 } = require(`./${i}/solve`);
const input = [4, 6].includes(i) ? getStringArrayFromInputEmptyLine(`./${i}/input.txt`) : getStringArrayFromInput(`./${i}/input.txt`);
console.log(`Day ${i} Part 1 solution: `, solve1(input));
console.log(`Day ${i} Part 2 solution: `, solve2(input));
}
} else {
const day = parseInt(arg);
const { solve1, solve2 } = require(`./${day}/solve`);
const input = [4, 6].includes(day) ? getStringArrayFromInputEmptyLine(`./${day}/input.txt`) : getStringArrayFromInput(`./${day}/input.txt`);
console.log(`Day ${day} Part 1 solution: `, solve1(input));
console.log(`Day ${day} Part 2 solution: `, solve2(input));
}