adventofcode/2022/05/part2.js
2022-12-07 18:42:05 -05:00

25 lines
466 B
JavaScript

import * as R from "remeda";
import { parseLines, spy } from "./part1.js";
function moveStacks([stacks, commands]) {
for (let [move, from, to] of commands) {
console.log({ move, from, to });
stacks[to - 1].push(
...stacks[from - 1].splice(stacks[from - 1].length - move)
);
}
return stacks;
}
export default R.createPipe(
(text) => text.split("\n\n"),
parseLines,
moveStacks,
spy,
R.map((x) => x.pop()),
(x) => x.join("")
);