d5-py: bonehead on data copy-paste

master
pegasust 2022-12-05 06:02:53 +00:00
parent 67130ccc37
commit c0912bcc1e
3 changed files with 4 additions and 1 deletions

View File

@ -15,6 +15,7 @@
''; '';
py_pkgs = [ pkgs.python310 ]; py_pkgs = [ pkgs.python310 ];
lua_pkgs = [ (pkgs.lua.withPackages (luapkgs: [ luapkgs.busted luapkgs.luafilesystem ])) ]; lua_pkgs = [ (pkgs.lua.withPackages (luapkgs: [ luapkgs.busted luapkgs.luafilesystem ])) ];
fennel_pkgs = [];
in in
{ {
# Jack of all trades # Jack of all trades

View File

@ -1,4 +1,4 @@
[D] [D]
[N] [C] [N] [C]
[Z] [M] [P] [Z] [M] [P]
1 2 3 1 2 3

View File

@ -17,6 +17,7 @@ class MoveInsn:
def part1(crates: list[list[str]], insns: list[MoveInsn]) -> str: def part1(crates: list[list[str]], insns: list[MoveInsn]) -> str:
for move in insns: for move in insns:
for _ in range(move.how_many): for _ in range(move.how_many):
# print(crates)
crates[move.to_crate - 1].append(crates[move.from_crate - 1].pop()) crates[move.to_crate - 1].append(crates[move.from_crate - 1].pop())
return "".join([crate[-1] for crate in crates]) return "".join([crate[-1] for crate in crates])
@ -75,3 +76,4 @@ if __name__ == "__main__":
import sys import sys
with open(sys.argv[1], "r") as f: with open(sys.argv[1], "r") as f:
main(f) main(f)