d5p2
This commit is contained in:
@@ -20,6 +20,8 @@ for (let idx = stack.length - 2; idx >= 0; idx--) {
|
||||
}
|
||||
}
|
||||
|
||||
let stackInputPart2: any[] = JSON.parse(JSON.stringify(stackInput));
|
||||
|
||||
for (let idx = 0; idx < rules.length; idx++) {
|
||||
const [move, from, to] = rules[idx].split(' ').filter(el => !isNaN(Number(el))).map(Number);
|
||||
for (let num = 0; num < move; num++) stackInput[to - 1].push(stackInput[from - 1].pop());
|
||||
@@ -29,4 +31,16 @@ const part1 = stackInput.map(buck => buck[buck.length - 1]).join("");
|
||||
|
||||
console.log("Part1:", part1);
|
||||
|
||||
elapsed = process.hrtime.bigint() - start;
|
||||
elapsed = process.hrtime.bigint() - start;
|
||||
|
||||
for (let idx = 0; idx < rules.length; idx++) {
|
||||
const [move, from, to] = rules[idx].split(' ').filter(el => !isNaN(Number(el))).map(Number);
|
||||
|
||||
let cratemover9001: any[] = [];
|
||||
for (let num = 0; num < move; num++) cratemover9001.push(stackInputPart2[from - 1].pop());
|
||||
stackInputPart2[to - 1] = stackInputPart2[to - 1].concat(cratemover9001.reverse());
|
||||
}
|
||||
|
||||
const part2 = stackInputPart2.map(buck => buck[buck.length - 1]).join("");
|
||||
console.log("Part2:", part2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user