Compare commits
8 Commits
eed66a163e
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43e24c6db9 | ||
|
|
260263b472 | ||
|
|
270093e194 | ||
|
|
041b57bb08 | ||
|
|
775ac4bbe7 | ||
|
|
6b3d803456 | ||
|
|
cd80733367 | ||
|
|
030af6ed8f |
@@ -1,4 +1,4 @@
|
||||
with import ../util.nix;
|
||||
with import ../../util.nix;
|
||||
|
||||
let
|
||||
input = readFile ./input;
|
||||
@@ -1,4 +1,4 @@
|
||||
with import ../util.nix;
|
||||
with import ../../util.nix;
|
||||
|
||||
let
|
||||
# read file
|
||||
@@ -1,4 +1,4 @@
|
||||
with import ../util.nix;
|
||||
with import ../../util.nix;
|
||||
|
||||
let
|
||||
# read input
|
||||
@@ -1,9 +1,10 @@
|
||||
with import ../util.nix;
|
||||
with import ../../util.nix;
|
||||
|
||||
let
|
||||
# read input
|
||||
input = readFile ./input;
|
||||
pairs = let
|
||||
pairs =
|
||||
let
|
||||
readRange = s: splitPair (a: b: [ (toInt a) (toInt b) ]) (splitString "-" s);
|
||||
readPair = a: b: [ (readRange a) (readRange b) ];
|
||||
in map
|
||||
513
days/5/input
Normal file
513
days/5/input
Normal file
@@ -0,0 +1,513 @@
|
||||
[D] [N] [F]
|
||||
[H] [F] [L] [J] [H]
|
||||
[R] [H] [F] [V] [G] [H]
|
||||
[Z] [Q] [Z] [W] [L] [J] [B]
|
||||
[S] [W] [H] [B] [H] [D] [C] [M]
|
||||
[P] [R] [S] [G] [J] [J] [W] [Z] [V]
|
||||
[W] [B] [V] [F] [G] [T] [T] [T] [P]
|
||||
[Q] [V] [C] [H] [P] [Q] [Z] [D] [W]
|
||||
1 2 3 4 5 6 7 8 9
|
||||
|
||||
move 1 from 3 to 9
|
||||
move 2 from 2 to 1
|
||||
move 3 from 5 to 4
|
||||
move 1 from 1 to 8
|
||||
move 1 from 3 to 9
|
||||
move 1 from 5 to 7
|
||||
move 1 from 5 to 3
|
||||
move 4 from 4 to 2
|
||||
move 2 from 3 to 4
|
||||
move 1 from 3 to 2
|
||||
move 6 from 1 to 5
|
||||
move 1 from 4 to 3
|
||||
move 1 from 3 to 9
|
||||
move 4 from 2 to 4
|
||||
move 4 from 8 to 7
|
||||
move 3 from 2 to 6
|
||||
move 1 from 2 to 7
|
||||
move 5 from 5 to 6
|
||||
move 1 from 5 to 8
|
||||
move 5 from 8 to 7
|
||||
move 7 from 4 to 6
|
||||
move 15 from 6 to 4
|
||||
move 1 from 8 to 7
|
||||
move 1 from 1 to 5
|
||||
move 1 from 2 to 4
|
||||
move 2 from 4 to 8
|
||||
move 1 from 5 to 2
|
||||
move 5 from 6 to 4
|
||||
move 2 from 2 to 1
|
||||
move 1 from 9 to 4
|
||||
move 1 from 6 to 9
|
||||
move 3 from 9 to 3
|
||||
move 3 from 4 to 3
|
||||
move 1 from 6 to 1
|
||||
move 5 from 3 to 4
|
||||
move 2 from 8 to 5
|
||||
move 1 from 3 to 6
|
||||
move 1 from 6 to 2
|
||||
move 1 from 2 to 8
|
||||
move 6 from 4 to 2
|
||||
move 1 from 2 to 7
|
||||
move 1 from 5 to 3
|
||||
move 4 from 9 to 3
|
||||
move 1 from 9 to 1
|
||||
move 3 from 1 to 6
|
||||
move 1 from 9 to 7
|
||||
move 14 from 7 to 6
|
||||
move 1 from 8 to 3
|
||||
move 4 from 2 to 6
|
||||
move 3 from 3 to 8
|
||||
move 9 from 4 to 9
|
||||
move 1 from 1 to 5
|
||||
move 2 from 5 to 8
|
||||
move 3 from 8 to 2
|
||||
move 4 from 2 to 6
|
||||
move 1 from 3 to 9
|
||||
move 10 from 6 to 1
|
||||
move 5 from 9 to 8
|
||||
move 1 from 9 to 3
|
||||
move 6 from 1 to 8
|
||||
move 3 from 7 to 4
|
||||
move 2 from 4 to 5
|
||||
move 2 from 9 to 8
|
||||
move 15 from 8 to 3
|
||||
move 3 from 7 to 9
|
||||
move 8 from 4 to 3
|
||||
move 2 from 5 to 9
|
||||
move 6 from 6 to 5
|
||||
move 6 from 5 to 8
|
||||
move 1 from 7 to 8
|
||||
move 6 from 9 to 2
|
||||
move 5 from 2 to 4
|
||||
move 6 from 3 to 5
|
||||
move 5 from 5 to 8
|
||||
move 1 from 5 to 7
|
||||
move 1 from 9 to 7
|
||||
move 2 from 6 to 4
|
||||
move 12 from 8 to 2
|
||||
move 7 from 2 to 4
|
||||
move 3 from 7 to 5
|
||||
move 3 from 5 to 7
|
||||
move 3 from 7 to 9
|
||||
move 2 from 9 to 7
|
||||
move 1 from 9 to 3
|
||||
move 2 from 7 to 4
|
||||
move 3 from 1 to 9
|
||||
move 4 from 6 to 5
|
||||
move 6 from 2 to 8
|
||||
move 14 from 4 to 9
|
||||
move 7 from 9 to 6
|
||||
move 9 from 9 to 2
|
||||
move 1 from 5 to 8
|
||||
move 5 from 6 to 3
|
||||
move 3 from 1 to 9
|
||||
move 3 from 8 to 9
|
||||
move 1 from 8 to 3
|
||||
move 5 from 2 to 5
|
||||
move 1 from 4 to 9
|
||||
move 2 from 6 to 1
|
||||
move 2 from 3 to 6
|
||||
move 3 from 8 to 3
|
||||
move 2 from 6 to 3
|
||||
move 1 from 4 to 9
|
||||
move 4 from 3 to 6
|
||||
move 7 from 6 to 9
|
||||
move 10 from 9 to 2
|
||||
move 10 from 3 to 2
|
||||
move 7 from 2 to 8
|
||||
move 2 from 1 to 7
|
||||
move 13 from 3 to 7
|
||||
move 7 from 5 to 1
|
||||
move 1 from 9 to 6
|
||||
move 4 from 8 to 4
|
||||
move 2 from 3 to 2
|
||||
move 4 from 4 to 6
|
||||
move 1 from 3 to 4
|
||||
move 5 from 6 to 5
|
||||
move 3 from 5 to 7
|
||||
move 12 from 2 to 5
|
||||
move 7 from 5 to 6
|
||||
move 2 from 8 to 3
|
||||
move 7 from 6 to 2
|
||||
move 3 from 9 to 6
|
||||
move 1 from 6 to 7
|
||||
move 1 from 4 to 9
|
||||
move 2 from 7 to 6
|
||||
move 13 from 7 to 4
|
||||
move 3 from 7 to 5
|
||||
move 1 from 9 to 6
|
||||
move 12 from 4 to 3
|
||||
move 1 from 8 to 1
|
||||
move 2 from 6 to 4
|
||||
move 1 from 7 to 9
|
||||
move 2 from 9 to 8
|
||||
move 12 from 3 to 5
|
||||
move 1 from 8 to 2
|
||||
move 15 from 5 to 6
|
||||
move 2 from 4 to 6
|
||||
move 1 from 9 to 6
|
||||
move 5 from 5 to 4
|
||||
move 4 from 4 to 2
|
||||
move 2 from 1 to 5
|
||||
move 4 from 1 to 5
|
||||
move 1 from 8 to 6
|
||||
move 7 from 5 to 2
|
||||
move 22 from 2 to 3
|
||||
move 9 from 6 to 3
|
||||
move 1 from 1 to 8
|
||||
move 1 from 8 to 7
|
||||
move 23 from 3 to 6
|
||||
move 2 from 2 to 4
|
||||
move 1 from 7 to 8
|
||||
move 1 from 8 to 2
|
||||
move 19 from 6 to 9
|
||||
move 2 from 2 to 4
|
||||
move 4 from 4 to 6
|
||||
move 13 from 6 to 8
|
||||
move 12 from 9 to 1
|
||||
move 2 from 5 to 9
|
||||
move 2 from 4 to 8
|
||||
move 1 from 2 to 7
|
||||
move 1 from 7 to 1
|
||||
move 4 from 6 to 2
|
||||
move 10 from 1 to 9
|
||||
move 1 from 6 to 7
|
||||
move 11 from 8 to 2
|
||||
move 6 from 3 to 6
|
||||
move 1 from 7 to 2
|
||||
move 1 from 1 to 8
|
||||
move 2 from 6 to 7
|
||||
move 7 from 6 to 3
|
||||
move 9 from 3 to 1
|
||||
move 7 from 9 to 6
|
||||
move 1 from 8 to 7
|
||||
move 4 from 2 to 6
|
||||
move 1 from 8 to 3
|
||||
move 6 from 6 to 5
|
||||
move 9 from 9 to 3
|
||||
move 5 from 6 to 1
|
||||
move 1 from 7 to 8
|
||||
move 2 from 8 to 4
|
||||
move 1 from 4 to 2
|
||||
move 1 from 4 to 5
|
||||
move 2 from 5 to 6
|
||||
move 1 from 6 to 9
|
||||
move 9 from 1 to 4
|
||||
move 4 from 4 to 6
|
||||
move 2 from 4 to 7
|
||||
move 7 from 2 to 8
|
||||
move 5 from 6 to 7
|
||||
move 6 from 3 to 8
|
||||
move 8 from 1 to 9
|
||||
move 3 from 5 to 2
|
||||
move 2 from 3 to 9
|
||||
move 3 from 9 to 4
|
||||
move 7 from 2 to 3
|
||||
move 1 from 7 to 2
|
||||
move 10 from 3 to 2
|
||||
move 6 from 9 to 4
|
||||
move 1 from 3 to 1
|
||||
move 1 from 1 to 8
|
||||
move 4 from 8 to 5
|
||||
move 10 from 8 to 4
|
||||
move 2 from 8 to 9
|
||||
move 7 from 4 to 9
|
||||
move 6 from 2 to 6
|
||||
move 3 from 6 to 5
|
||||
move 4 from 4 to 9
|
||||
move 8 from 7 to 5
|
||||
move 1 from 9 to 2
|
||||
move 7 from 2 to 1
|
||||
move 4 from 9 to 8
|
||||
move 2 from 6 to 3
|
||||
move 2 from 3 to 2
|
||||
move 13 from 5 to 7
|
||||
move 5 from 4 to 9
|
||||
move 5 from 1 to 7
|
||||
move 3 from 5 to 8
|
||||
move 17 from 7 to 2
|
||||
move 15 from 2 to 6
|
||||
move 15 from 9 to 5
|
||||
move 1 from 9 to 5
|
||||
move 4 from 8 to 6
|
||||
move 1 from 4 to 6
|
||||
move 5 from 4 to 7
|
||||
move 5 from 2 to 7
|
||||
move 18 from 6 to 2
|
||||
move 2 from 7 to 6
|
||||
move 10 from 2 to 8
|
||||
move 2 from 2 to 3
|
||||
move 11 from 8 to 7
|
||||
move 7 from 7 to 5
|
||||
move 9 from 7 to 5
|
||||
move 3 from 7 to 5
|
||||
move 2 from 1 to 7
|
||||
move 4 from 2 to 1
|
||||
move 30 from 5 to 1
|
||||
move 1 from 3 to 1
|
||||
move 35 from 1 to 9
|
||||
move 2 from 2 to 5
|
||||
move 2 from 8 to 3
|
||||
move 20 from 9 to 2
|
||||
move 3 from 7 to 9
|
||||
move 1 from 3 to 6
|
||||
move 5 from 5 to 3
|
||||
move 18 from 2 to 5
|
||||
move 4 from 5 to 8
|
||||
move 7 from 9 to 7
|
||||
move 1 from 6 to 2
|
||||
move 3 from 8 to 5
|
||||
move 6 from 3 to 5
|
||||
move 3 from 7 to 4
|
||||
move 2 from 2 to 3
|
||||
move 1 from 4 to 5
|
||||
move 2 from 4 to 5
|
||||
move 4 from 7 to 2
|
||||
move 26 from 5 to 6
|
||||
move 2 from 2 to 7
|
||||
move 1 from 2 to 9
|
||||
move 1 from 7 to 8
|
||||
move 1 from 5 to 3
|
||||
move 2 from 8 to 3
|
||||
move 11 from 9 to 3
|
||||
move 6 from 3 to 4
|
||||
move 27 from 6 to 4
|
||||
move 33 from 4 to 3
|
||||
move 4 from 6 to 8
|
||||
move 1 from 2 to 8
|
||||
move 1 from 7 to 3
|
||||
move 4 from 8 to 9
|
||||
move 1 from 8 to 6
|
||||
move 34 from 3 to 8
|
||||
move 1 from 8 to 5
|
||||
move 1 from 2 to 9
|
||||
move 8 from 3 to 9
|
||||
move 3 from 5 to 4
|
||||
move 1 from 6 to 5
|
||||
move 27 from 8 to 9
|
||||
move 1 from 3 to 4
|
||||
move 1 from 5 to 7
|
||||
move 3 from 8 to 1
|
||||
move 11 from 9 to 1
|
||||
move 1 from 7 to 5
|
||||
move 11 from 9 to 3
|
||||
move 1 from 5 to 1
|
||||
move 1 from 8 to 7
|
||||
move 2 from 9 to 2
|
||||
move 1 from 2 to 1
|
||||
move 1 from 2 to 7
|
||||
move 2 from 8 to 2
|
||||
move 6 from 3 to 8
|
||||
move 1 from 4 to 2
|
||||
move 7 from 1 to 2
|
||||
move 1 from 7 to 1
|
||||
move 19 from 9 to 1
|
||||
move 3 from 2 to 9
|
||||
move 10 from 1 to 4
|
||||
move 2 from 9 to 1
|
||||
move 1 from 7 to 9
|
||||
move 7 from 1 to 6
|
||||
move 10 from 4 to 3
|
||||
move 14 from 1 to 7
|
||||
move 2 from 9 to 1
|
||||
move 3 from 4 to 6
|
||||
move 9 from 7 to 6
|
||||
move 1 from 3 to 5
|
||||
move 4 from 8 to 5
|
||||
move 10 from 6 to 8
|
||||
move 3 from 5 to 6
|
||||
move 10 from 3 to 4
|
||||
move 4 from 3 to 7
|
||||
move 1 from 5 to 9
|
||||
move 2 from 7 to 9
|
||||
move 1 from 1 to 9
|
||||
move 6 from 2 to 4
|
||||
move 1 from 5 to 3
|
||||
move 11 from 4 to 9
|
||||
move 3 from 4 to 9
|
||||
move 1 from 2 to 7
|
||||
move 2 from 3 to 5
|
||||
move 1 from 3 to 2
|
||||
move 7 from 7 to 2
|
||||
move 2 from 5 to 8
|
||||
move 8 from 2 to 1
|
||||
move 2 from 6 to 8
|
||||
move 9 from 6 to 8
|
||||
move 3 from 8 to 2
|
||||
move 3 from 2 to 6
|
||||
move 9 from 9 to 5
|
||||
move 3 from 5 to 8
|
||||
move 5 from 9 to 4
|
||||
move 3 from 6 to 4
|
||||
move 1 from 6 to 3
|
||||
move 3 from 1 to 6
|
||||
move 3 from 6 to 9
|
||||
move 17 from 8 to 5
|
||||
move 12 from 5 to 4
|
||||
move 21 from 4 to 3
|
||||
move 1 from 4 to 9
|
||||
move 7 from 5 to 4
|
||||
move 22 from 3 to 7
|
||||
move 3 from 1 to 8
|
||||
move 3 from 9 to 1
|
||||
move 4 from 4 to 6
|
||||
move 1 from 6 to 2
|
||||
move 3 from 4 to 1
|
||||
move 1 from 6 to 7
|
||||
move 4 from 9 to 3
|
||||
move 2 from 5 to 7
|
||||
move 1 from 9 to 6
|
||||
move 2 from 6 to 9
|
||||
move 8 from 7 to 9
|
||||
move 1 from 6 to 2
|
||||
move 1 from 9 to 3
|
||||
move 4 from 3 to 4
|
||||
move 14 from 7 to 4
|
||||
move 1 from 3 to 2
|
||||
move 3 from 7 to 8
|
||||
move 12 from 8 to 9
|
||||
move 8 from 4 to 1
|
||||
move 1 from 7 to 4
|
||||
move 2 from 5 to 1
|
||||
move 3 from 2 to 9
|
||||
move 17 from 9 to 3
|
||||
move 6 from 9 to 1
|
||||
move 1 from 9 to 2
|
||||
move 13 from 3 to 9
|
||||
move 4 from 3 to 1
|
||||
move 3 from 9 to 1
|
||||
move 22 from 1 to 9
|
||||
move 1 from 8 to 1
|
||||
move 6 from 9 to 5
|
||||
move 4 from 1 to 9
|
||||
move 3 from 1 to 9
|
||||
move 4 from 4 to 8
|
||||
move 4 from 4 to 2
|
||||
move 1 from 4 to 3
|
||||
move 3 from 8 to 9
|
||||
move 1 from 3 to 4
|
||||
move 1 from 1 to 3
|
||||
move 1 from 8 to 2
|
||||
move 1 from 5 to 8
|
||||
move 4 from 2 to 1
|
||||
move 1 from 8 to 7
|
||||
move 10 from 9 to 6
|
||||
move 1 from 7 to 9
|
||||
move 1 from 2 to 3
|
||||
move 1 from 6 to 1
|
||||
move 3 from 5 to 7
|
||||
move 1 from 8 to 7
|
||||
move 1 from 6 to 1
|
||||
move 1 from 2 to 4
|
||||
move 1 from 5 to 2
|
||||
move 19 from 9 to 2
|
||||
move 1 from 4 to 7
|
||||
move 1 from 3 to 7
|
||||
move 3 from 7 to 9
|
||||
move 4 from 1 to 2
|
||||
move 10 from 9 to 4
|
||||
move 1 from 5 to 8
|
||||
move 3 from 6 to 4
|
||||
move 1 from 3 to 4
|
||||
move 10 from 2 to 8
|
||||
move 12 from 2 to 5
|
||||
move 3 from 5 to 9
|
||||
move 5 from 6 to 5
|
||||
move 5 from 1 to 4
|
||||
move 22 from 4 to 3
|
||||
move 3 from 8 to 7
|
||||
move 1 from 7 to 2
|
||||
move 3 from 2 to 9
|
||||
move 19 from 3 to 5
|
||||
move 2 from 7 to 8
|
||||
move 7 from 5 to 6
|
||||
move 5 from 9 to 6
|
||||
move 1 from 9 to 3
|
||||
move 16 from 5 to 1
|
||||
move 2 from 3 to 1
|
||||
move 3 from 7 to 3
|
||||
move 7 from 8 to 4
|
||||
move 2 from 8 to 1
|
||||
move 5 from 5 to 9
|
||||
move 1 from 5 to 2
|
||||
move 1 from 2 to 3
|
||||
move 1 from 8 to 5
|
||||
move 4 from 5 to 7
|
||||
move 2 from 3 to 8
|
||||
move 2 from 1 to 5
|
||||
move 4 from 7 to 6
|
||||
move 6 from 4 to 7
|
||||
move 4 from 9 to 8
|
||||
move 14 from 6 to 7
|
||||
move 8 from 1 to 7
|
||||
move 7 from 1 to 3
|
||||
move 3 from 5 to 9
|
||||
move 28 from 7 to 5
|
||||
move 1 from 1 to 8
|
||||
move 4 from 8 to 3
|
||||
move 9 from 3 to 1
|
||||
move 1 from 9 to 5
|
||||
move 6 from 3 to 2
|
||||
move 10 from 1 to 6
|
||||
move 1 from 1 to 9
|
||||
move 5 from 9 to 7
|
||||
move 14 from 5 to 3
|
||||
move 1 from 4 to 1
|
||||
move 1 from 7 to 2
|
||||
move 1 from 7 to 1
|
||||
move 1 from 1 to 7
|
||||
move 3 from 8 to 5
|
||||
move 4 from 6 to 3
|
||||
move 3 from 7 to 2
|
||||
move 15 from 3 to 6
|
||||
move 16 from 5 to 7
|
||||
move 4 from 2 to 8
|
||||
move 1 from 3 to 1
|
||||
move 5 from 7 to 3
|
||||
move 12 from 6 to 4
|
||||
move 4 from 8 to 5
|
||||
move 1 from 4 to 2
|
||||
move 2 from 5 to 3
|
||||
move 8 from 6 to 3
|
||||
move 7 from 4 to 5
|
||||
move 9 from 7 to 6
|
||||
move 1 from 7 to 9
|
||||
move 1 from 1 to 9
|
||||
move 1 from 1 to 9
|
||||
move 5 from 2 to 8
|
||||
move 5 from 8 to 2
|
||||
move 11 from 5 to 9
|
||||
move 1 from 4 to 2
|
||||
move 4 from 9 to 6
|
||||
move 12 from 3 to 7
|
||||
move 3 from 4 to 9
|
||||
move 14 from 6 to 2
|
||||
move 2 from 2 to 4
|
||||
move 2 from 3 to 5
|
||||
move 10 from 7 to 2
|
||||
move 1 from 4 to 8
|
||||
move 1 from 2 to 7
|
||||
move 28 from 2 to 9
|
||||
move 4 from 7 to 5
|
||||
move 1 from 2 to 4
|
||||
move 6 from 5 to 1
|
||||
move 2 from 4 to 3
|
||||
move 1 from 8 to 1
|
||||
move 40 from 9 to 1
|
||||
move 10 from 1 to 6
|
||||
move 5 from 3 to 5
|
||||
move 1 from 9 to 8
|
||||
move 3 from 6 to 7
|
||||
move 11 from 1 to 2
|
||||
move 9 from 2 to 3
|
||||
move 3 from 5 to 1
|
||||
move 4 from 7 to 1
|
||||
move 2 from 2 to 4
|
||||
move 2 from 5 to 8
|
||||
move 19 from 1 to 7
|
||||
move 8 from 3 to 2
|
||||
move 14 from 1 to 8
|
||||
move 14 from 7 to 1
|
||||
move 4 from 6 to 5
|
||||
move 1 from 1 to 9
|
||||
109
days/5/puzzle.txt
Normal file
109
days/5/puzzle.txt
Normal file
@@ -0,0 +1,109 @@
|
||||
--- Day 5: Supply Stacks ---
|
||||
|
||||
The expedition can depart as soon as the final supplies have been unloaded from the ships. Supplies are stored in stacks of marked crates, but because the needed supplies are buried under many other crates, the crates need to be rearranged.
|
||||
|
||||
The ship has a giant cargo crane capable of moving crates between stacks. To ensure none of the crates get crushed or fall over, the crane operator will rearrange them in a series of carefully-planned steps. After the crates are rearranged, the desired crates will be at the top of each stack.
|
||||
|
||||
The Elves don't want to interrupt the crane operator during this delicate procedure, but they forgot to ask her which crate will end up where, and they want to be ready to unload them as soon as possible so they can embark.
|
||||
|
||||
They do, however, have a drawing of the starting stacks of crates and the rearrangement procedure (your puzzle input). For example:
|
||||
|
||||
[D]
|
||||
[N] [C]
|
||||
[Z] [M] [P]
|
||||
1 2 3
|
||||
|
||||
move 1 from 2 to 1
|
||||
move 3 from 1 to 3
|
||||
move 2 from 2 to 1
|
||||
move 1 from 1 to 2
|
||||
|
||||
In this example, there are three stacks of crates. Stack 1 contains two crates: crate Z is on the bottom, and crate N is on top. Stack 2 contains three crates; from bottom to top, they are crates M, C, and D. Finally, stack 3 contains a single crate, P.
|
||||
|
||||
Then, the rearrangement procedure is given. In each step of the procedure, a quantity of crates is moved from one stack to a different stack. In the first step of the above rearrangement procedure, one crate is moved from stack 2 to stack 1, resulting in this configuration:
|
||||
|
||||
[D]
|
||||
[N] [C]
|
||||
[Z] [M] [P]
|
||||
1 2 3
|
||||
|
||||
In the second step, three crates are moved from stack 1 to stack 3. Crates are moved one at a time, so the first crate to be moved (D) ends up below the second and third crates:
|
||||
|
||||
[Z]
|
||||
[N]
|
||||
[C] [D]
|
||||
[M] [P]
|
||||
1 2 3
|
||||
|
||||
Then, both crates are moved from stack 2 to stack 1. Again, because crates are moved one at a time, crate C ends up below crate M:
|
||||
|
||||
[Z]
|
||||
[N]
|
||||
[M] [D]
|
||||
[C] [P]
|
||||
1 2 3
|
||||
|
||||
Finally, one crate is moved from stack 1 to stack 2:
|
||||
|
||||
[Z]
|
||||
[N]
|
||||
[D]
|
||||
[C] [M] [P]
|
||||
1 2 3
|
||||
|
||||
The Elves just need to know which crate will end up on top of each stack; in this example, the top crates are C in stack 1, M in stack 2, and Z in stack 3, so you should combine these together and give the Elves the message CMZ.
|
||||
|
||||
After the rearrangement procedure completes, what crate ends up on top of each stack?
|
||||
|
||||
Your puzzle answer was ZWHVFWQWW.
|
||||
--- Part Two ---
|
||||
|
||||
As you watch the crane operator expertly rearrange the crates, you notice the process isn't following your prediction.
|
||||
|
||||
Some mud was covering the writing on the side of the crane, and you quickly wipe it away. The crane isn't a CrateMover 9000 - it's a CrateMover 9001.
|
||||
|
||||
The CrateMover 9001 is notable for many new and exciting features: air conditioning, leather seats, an extra cup holder, and the ability to pick up and move multiple crates at once.
|
||||
|
||||
Again considering the example above, the crates begin in the same configuration:
|
||||
|
||||
[D]
|
||||
[N] [C]
|
||||
[Z] [M] [P]
|
||||
1 2 3
|
||||
|
||||
Moving a single crate from stack 2 to stack 1 behaves the same as before:
|
||||
|
||||
[D]
|
||||
[N] [C]
|
||||
[Z] [M] [P]
|
||||
1 2 3
|
||||
|
||||
However, the action of moving three crates from stack 1 to stack 3 means that those three moved crates stay in the same order, resulting in this new configuration:
|
||||
|
||||
[D]
|
||||
[N]
|
||||
[C] [Z]
|
||||
[M] [P]
|
||||
1 2 3
|
||||
|
||||
Next, as both crates are moved from stack 2 to stack 1, they retain their order as well:
|
||||
|
||||
[D]
|
||||
[N]
|
||||
[C] [Z]
|
||||
[M] [P]
|
||||
1 2 3
|
||||
|
||||
Finally, a single crate is still moved from stack 1 to stack 2, but now it's crate C that gets moved:
|
||||
|
||||
[D]
|
||||
[N]
|
||||
[Z]
|
||||
[M] [C] [P]
|
||||
1 2 3
|
||||
|
||||
In this example, the CrateMover 9001 has put the crates in a totally different order: MCD.
|
||||
|
||||
Before the rearrangement process finishes, update your simulation so that the Elves know where they should stand to be ready to unload the final supplies. After the rearrangement procedure completes, what crate ends up on top of each stack?
|
||||
|
||||
Your puzzle answer was HZFZCCWWV.
|
||||
50
days/5/solution.nix
Normal file
50
days/5/solution.nix
Normal file
@@ -0,0 +1,50 @@
|
||||
with import ../../util.nix;
|
||||
|
||||
let
|
||||
# read input
|
||||
input = splitString "\n\n" (readFile ./input);
|
||||
|
||||
stacks =
|
||||
let
|
||||
# each layer of stacks as a raw input string
|
||||
layers = dropLast (splitString "\n" (head input));
|
||||
# each layer of stacks as a list
|
||||
parsedLayers = map (s: map (l: elemAt l 1) (chunksOf 4 (stringToCharacters s))) layers;
|
||||
in
|
||||
# flip from layers to stacks and remove empty slots
|
||||
map (filter (s: s != " ")) (transpose parsedLayers);
|
||||
|
||||
# list of moves "move 1 from 7 to 9" => [1 7 9]
|
||||
moves = map
|
||||
(line: map toInt (subtractLists ["move" "from" "to"] (splitString " " line)))
|
||||
(splitString "\n" (last input));
|
||||
|
||||
# funcs for how many boxes to be moved
|
||||
moveTopOnly = cnt: 1; # crane can only move one box at a time
|
||||
moveAll = cnt: cnt; # crane can move any number of boxes at a time
|
||||
moveThree = min 3; # crane can only move 3 boxes at a time
|
||||
|
||||
# performs a single move
|
||||
performMove = moveCntFunc: stacks: mv:
|
||||
if head mv == 0 then stacks # base case; no more boxes to move
|
||||
else
|
||||
let
|
||||
cnt = elemAt mv 0; # boxes that need to be moved
|
||||
cnt' = moveCntFunc cnt; # boxes that can be moved
|
||||
src = elemAt mv 1;
|
||||
dest = elemAt mv 2;
|
||||
boxes = take cnt' (elemAt stacks (src -1)); # box(es) being moved
|
||||
stacks' = imap1 (i: s:
|
||||
if i == src then drop cnt' s
|
||||
else if i == dest then boxes ++ s
|
||||
else s) stacks;
|
||||
in
|
||||
performMove moveCntFunc stacks' [(cnt - cnt') src dest];
|
||||
|
||||
# performs all moves in sequence
|
||||
performMoves = moveCntFunc: foldl (performMove moveCntFunc) stacks moves;
|
||||
in {
|
||||
part1 = concatStrings (map head (performMoves moveTopOnly));
|
||||
part2 = concatStrings (map head (performMoves moveAll));
|
||||
# moveThree = concatStrings (map head (performMoves moveThree));
|
||||
}
|
||||
1
days/6/input
Normal file
1
days/6/input
Normal file
@@ -0,0 +1 @@
|
||||
pqffvllhrhthvhshhpnhpnpqpvpvrpvpwvwjjdssmcsmccjvjmjjwnjwjwhjwwwzswwhvhwwlvvlbvbtbzbfbzbtbqbgbpbggwzggvjjdpdffbmffntncchtccbcffcjfjnjfnntssvtstzssmnnhrhlhbbwfwjfwjfwwbhhfhmmpsssbnssssfzzfpffdrdpdqqvnncjjgrjjmhhpqqcjqcjjzdzzpvvprrlglrrcmcqqtltdltddswsrrzzwgzzgssczcmzzmgmwgmggwwzttpccmcsmmvfvnvppzlzvzllgclggpfggfnfrfvrvwwvhwwvgwwrbbgfglflblzblzbznzhzffplffnrrcqqsgsvshvhlldhhvnhhmdddnssdvdwdwccggmddsmswwtctdtqqjsshhjzzdpdmpdmppjtjwjswjsjjjsdjjtrtbrbjjwwvnvppqphqhwhcwhwbbpgbbnhbnhhswwdswwlcczdztzbbbnwwtmmpvvgjjqgqdqzzdjdpjjnnffhccscvvchhbmbcbffpdpggvdvttpvpqqhggdtdhtdhhmghmgggzwgwrgwggwlggvpggcfcttzmtmgmvgmmpqmqlmqllsqqjbjwjsszczlzrzgrzzhshlhjjwttwnntbtjtjpplccqrqhrhssbmbttrddfvfwwjcwcvwcwwvpvggqwgwjgwgccvqqcmqqtqnqpnqnffdqfqhhqnhnmhmvhmhwwfrwrggnmmmcnmmgsszmzlmzmddcwwthtssgjsgjjgpgnppdqqcgqggzjgjngnrnggvffgddvtvctcftcftfnnnnhssbgsgwwthtqtltftqtnqttsrtrggwcgwcwmwgmgvmmzrmzrzjzmmcclmmtjmjhmmlhlwlppnpccbbrlrqrcrjrdrlrnngmnmvmcmzczztbblglccvzvppzspsddrzzlsllfzfsspnpdnpnvvvgmmpccmpcpgcpcwcddtmddgwgngqqcpqqlhqqczqqbvqqgdqgqmgmlmmvrrgfgzffbccldcdmmcmcgcngnghngngdngdndcncbbpqbbphbphpccpcwwjswwfttbqbsszccrbbdndsdrdqrqjrjjbmbtbdbbgbvgvcggwdwcccttqccnffjpjqqzpzlzvlljhhschhzlhhfhcfhchvcvtvtgvgzvzrvrdrgrwrjwjljhljlssszsqzsswhhmlhlrhlhzzgghjhzjjcllwrwtrrbdbrbnrnprnrffjvvphhvbbqbbscstsmslmlvmvrmmvvngnlnzzwqzzjqqsqbqrrtmrtmmfgmgrgjjtmjmrrddmrrqmrrjmjqmqnqmmcmlmfmffcgcclplffzvzwvzzjtztftqftqffjjpwjjbpjjggzdgzgwzzfrfvvhfvvwcvvbccfcvffpcpgpbbqhbbhmmzfmfvvnjvnjjhzhqqmffndndmmzhmmqnnlglvvjhjddvggqwgwdgwdggqbqgqrqlrrtptsswlssqwssbdsdrsddjsszjszjjpnjnvnjvnnmznmnddccpwwhshzzcfcqcwcddsjjmnjmjljwwgmglllqlhhctcvvqrvrrhfrrbcrrfbrfbrfrqffbwbqwbbjggsjjjnqqrqsqhhwnhnshnhhdjjqfqpqmmqgqgqggzmmnncrrpgglgqlqclqlsqqwnnfntnzttrnnmtmvvfppbrprzpzzdzvvtctnncpclpccsbbswwcscjssvhvhhqggzmgmqgmgwwgcwgccrllzhzzlzlbljbllmqqpjqqhrhqhjhbbjmjmhmddmwmcmvvmbbmvbmmznnwvwlwtllhwlwgwpgplgpgmgngjgglbglgmllvvlttgrrrlsrllghlggjdjwwfjwfjfvhjmgqnwhwpbdtzrphsqbmmvscslhbdzffsfshgsdjbqbwlgmrtschcnfhdlnndsvpwmwttfglpghhznmgfcjsdlwhnmfqvmpvhgpnnwtjfztbmtprqhsqtjwzhwcqjtjbtqwlcldnvggrwddmpllwnrqwdljwzfzqwcdwgqwvnthnrpcsfwrmqvbzjvzqnmdnfgtbzgtnrvblfwmhdsddgbffnjzvjzfpwglctpqhnqdvtblcchrlmndzhlsczgnsmnbwgnjngnjtlrdpfhqjrwcrqvcpspbtwcvgvvmpnwqjjpdpnslmcrcjnjmhqmrmfbcmrcmpbcbhpcvwqwflljfpgdvqhgdwgcphjqfnqzjjpsqnbtfzhftjtfcbhhcmmlwcfznsflfpphprrgvqwfgjcwfgjfsghzcbqrldwrjlzlbjhpgrbmgdpgzmfsqsphqbbslwwpzspccrhcfrgcjlfwhlcmzdcltbbpcrzglqgqntpwtmgstqlmcsqqbsqgmsmfznwcrfdgvsmnfqmwtsvqvlhwwjlrlhnsvcnrtwwmrjcgfncvlrcqrllndlvmrjpfjpgrrjcwhsqvlbtnlqgwjjqzwcvtvlnfnmqqshbcnqtcbvnwtwbfdgqmvnpmjhlsfdntfwwntvsrrsmspzqmglfnprjtdbmbgnplzzclsjpnzwdhcbhpfnqrgmgqtpfhgnfbqhrpmznbrshjhntzctslwhtgtjvpqhntmchhtncfjmbzcgnpcbpmldrtnpvrzqfftbjjcjlpwwgvmnstjghftcczjzfsftgzpfhbspqmrbfhcdfmqbrgrbsmjvgpbrnvbblwwvqzzpmqrspzvzppjfbgfftdvsdvmrjzhfslptzmgndnqqgmrrfnbbpvbmvpngwjhzvfbwfnzlrgwffvjsfdldfgchfjmnzfnzhwrwttrzlrhmnwvjjdqfmbpfllhrgmddjgnwjnbqwjnslcrdjrmnldcpsgzjpdhrpdfwhbvwhwnhcsmwcwstvqrcrqsnvjrzljfgbljfszchbsqnldgntvcscwqqmpnlwtlfmswtmvrlpzgbrjhtgjgpnhggnprpvwfqpjffqhtfvpnrptgrtwzzlvplgnfjmqphgmnssccrdndqgpljtwtntshrpgsjcdrpmccjnjdgmpmzbfhqjzphcswtwvvqcrwsjhtdqgrhqjmjjcrblpswcblnpzvfztqtbpgjcgngqmwrjtlmhvlsbmrdzwlgqlfqcqnsnjcnddssqbftjvnlgcwwfcgdpdmqrdsjmcnzrfrpnvjmbsltpzwjhjzqqvbgrltczbgvcpwdzqsvhddsbjgjgcmnldrfhnhddlvjcvsnghprjwlghhtghldcqsdcdgnmbcjglvjjvvlbhzczlmjsdqtdpzdtvfztgsdfjsdtfchvzcgvhjnnncmsrfvvmcsjjdftmlpczgvtwngssqmzlmsrrsrbhhhrnwqhmpcdvqmdsvvtsgsqfdcpgsdgzvmbzpbpgtcbshnvdzlmpnwmqrvnmrjprmvppjwfbjhlhzsfhqqzmpbclqvsvfrcqwprrcvqcbbwvnqfwnrgjhlwmgzpfspqrvqrhmqnwvzjrhvvgdgswlvzjjhjtdctlthlpzqhjvwwbpsclpgflcnsdshrqbhmczcwljqlndfnfrcdgmptpsltrcjccnpdchgnswdcpsslcslcjznzpgfhznhbgqhdqvddmqzdnmpshhdcjrsmfjllhfvjvmzzhzrvlbpzqngwmlwcmqnppqzncvjshfrpjlptvnqfrfcrfnbhwhpdqqvjhsqvsmprtgfrddwzjzlwhhqvjpfrwgwvwpszzsfzwjtwngdjfllhjrmqjtmvwsvggnswpqpjbtcrnhhhlzbrvhjdstnpctjlgsffrrbfdvjzhwsgthgfsqnvqdcjffsttlrjnhtqqdpfqpjtdgfwcdwzmwfvqgglsrmmqwbszclpzwldwcswpwfwldrfmmdndcptjbmnvgcpntqcdrcffvgnlpjmcqjpfmbmwjfpqzbzhqtqbzsghbnfvhphfzzhfznttpfrqwpmzjchpzzrdclhdltlqbjmjdfdjqlqbwptsghcnvtdscwgpqnlhhvsvglplhlrwpnzmdbsbrlhmpczzfz
|
||||
51
days/6/puzzle.txt
Normal file
51
days/6/puzzle.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
--- Day 6: Tuning Trouble ---
|
||||
|
||||
The preparations are finally complete; you and the Elves leave camp on foot and begin to make your way toward the star fruit grove.
|
||||
|
||||
As you move through the dense undergrowth, one of the Elves gives you a handheld device. He says that it has many fancy features, but the most important one to set up right now is the communication system.
|
||||
|
||||
However, because he's heard you have significant experience dealing with signal-based systems, he convinced the other Elves that it would be okay to give you their one malfunctioning device - surely you'll have no problem fixing it.
|
||||
|
||||
As if inspired by comedic timing, the device emits a few colorful sparks.
|
||||
|
||||
To be able to communicate with the Elves, the device needs to lock on to their signal. The signal is a series of seemingly-random characters that the device receives one at a time.
|
||||
|
||||
To fix the communication system, you need to add a subroutine to the device that detects a start-of-packet marker in the datastream. In the protocol being used by the Elves, the start of a packet is indicated by a sequence of four characters that are all different.
|
||||
|
||||
The device will send your subroutine a datastream buffer (your puzzle input); your subroutine needs to identify the first position where the four most recently received characters were all different. Specifically, it needs to report the number of characters from the beginning of the buffer to the end of the first such four-character marker.
|
||||
|
||||
For example, suppose you receive the following datastream buffer:
|
||||
|
||||
mjqjpqmgbljsphdztnvjfqwrcgsmlb
|
||||
|
||||
After the first three characters (mjq) have been received, there haven't been enough characters received yet to find the marker. The first time a marker could occur is after the fourth character is received, making the most recent four characters mjqj. Because j is repeated, this isn't a marker.
|
||||
|
||||
The first time a marker appears is after the seventh character arrives. Once it does, the last four characters received are jpqm, which are all different. In this case, your subroutine should report the value 7, because the first start-of-packet marker is complete after 7 characters have been processed.
|
||||
|
||||
Here are a few more examples:
|
||||
|
||||
bvwbjplbgvbhsrlpgdmjqwftvncz: first marker after character 5
|
||||
nppdvjthqldpwncqszvftbrmjlhg: first marker after character 6
|
||||
nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg: first marker after character 10
|
||||
zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw: first marker after character 11
|
||||
|
||||
How many characters need to be processed before the first start-of-packet marker is detected?
|
||||
|
||||
Your puzzle answer was 1912.
|
||||
--- Part Two ---
|
||||
|
||||
Your device's communication system is correctly detecting packets, but still isn't working. It looks like it also needs to look for messages.
|
||||
|
||||
A start-of-message marker is just like a start-of-packet marker, except it consists of 14 distinct characters rather than 4.
|
||||
|
||||
Here are the first positions of start-of-message markers for all of the above examples:
|
||||
|
||||
mjqjpqmgbljsphdztnvjfqwrcgsmlb: first marker after character 19
|
||||
bvwbjplbgvbhsrlpgdmjqwftvncz: first marker after character 23
|
||||
nppdvjthqldpwncqszvftbrmjlhg: first marker after character 23
|
||||
nznrnfrfntjfmvfwmzdfjlvtqnbhcprsg: first marker after character 29
|
||||
zcfzfwzzqfrljwzlrfnpqdbhtmscgvjw: first marker after character 26
|
||||
|
||||
How many characters need to be processed before the first start-of-message marker is detected?
|
||||
|
||||
Your puzzle answer was 2122.
|
||||
17
days/6/solution.nix
Normal file
17
days/6/solution.nix
Normal file
@@ -0,0 +1,17 @@
|
||||
with import ../../util.nix;
|
||||
|
||||
let
|
||||
# read input
|
||||
input = stringToCharacters (readFile ./input);
|
||||
|
||||
marker = markerLength: data:
|
||||
let
|
||||
isMarker = l: length (unique l) == markerLength;
|
||||
search = start: l:
|
||||
if isMarker (sublist (start - markerLength + 1) markerLength l) then start +1
|
||||
else search (start +1) l;
|
||||
in search (markerLength -1) input;
|
||||
in rec {
|
||||
part1 = marker 4 input;
|
||||
part2 = marker 14 (drop part1 input);
|
||||
}
|
||||
986
days/7/input
Normal file
986
days/7/input
Normal file
@@ -0,0 +1,986 @@
|
||||
$ cd /
|
||||
$ ls
|
||||
dir bnl
|
||||
dir dmpsnhdh
|
||||
272080 dncdssn.hdr
|
||||
dir fcnqg
|
||||
6067 hjpmqrq
|
||||
dir jvwtm
|
||||
dir ldztz
|
||||
dir lmmw
|
||||
dir wthvqw
|
||||
dir zpdnprb
|
||||
$ cd bnl
|
||||
$ ls
|
||||
dir dhw
|
||||
dir dmpsnhdh
|
||||
dir lmw
|
||||
dir vgbqbrst
|
||||
$ cd dhw
|
||||
$ ls
|
||||
237421 vccwmhl
|
||||
$ cd ..
|
||||
$ cd dmpsnhdh
|
||||
$ ls
|
||||
dir chf
|
||||
dir mjpbhjm
|
||||
dir zwhpwp
|
||||
$ cd chf
|
||||
$ ls
|
||||
4679 lmw.wmp
|
||||
217367 wwnfv.qqr
|
||||
dir zfgznbz
|
||||
$ cd zfgznbz
|
||||
$ ls
|
||||
179409 cnj.gdn
|
||||
171574 vglqg
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd mjpbhjm
|
||||
$ ls
|
||||
dir crf
|
||||
dir hqnj
|
||||
dir lmw
|
||||
18783 lmw.rwr
|
||||
302608 twpq
|
||||
166891 vqczlg
|
||||
$ cd crf
|
||||
$ ls
|
||||
32183 dltmqht
|
||||
240428 frqqdsr.hbf
|
||||
224910 sgtnrvrt
|
||||
$ cd ..
|
||||
$ cd hqnj
|
||||
$ ls
|
||||
261723 cgstb
|
||||
77979 dmpsnhdh.cmd
|
||||
$ cd ..
|
||||
$ cd lmw
|
||||
$ ls
|
||||
50307 fcqrwd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd zwhpwp
|
||||
$ ls
|
||||
141133 gdngm.mps
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd lmw
|
||||
$ ls
|
||||
dir dvv
|
||||
267473 jmqgrh.dlz
|
||||
295139 rrqjwpm
|
||||
$ cd dvv
|
||||
$ ls
|
||||
114536 gmlmbrrw.wdm
|
||||
102061 lmw
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd vgbqbrst
|
||||
$ ls
|
||||
105102 dmpsnhdh.bgl
|
||||
269054 gmwgjf.fzz
|
||||
dir jbdtpnw
|
||||
245266 jzsjvgl
|
||||
216220 lmw.gtb
|
||||
dir rflp
|
||||
dir twpq
|
||||
$ cd jbdtpnw
|
||||
$ ls
|
||||
27543 cjvvmzp
|
||||
$ cd ..
|
||||
$ cd rflp
|
||||
$ ls
|
||||
137601 frqqdsr.hbf
|
||||
83444 rrqjwpm
|
||||
$ cd ..
|
||||
$ cd twpq
|
||||
$ ls
|
||||
dir rlbsdj
|
||||
36846 tnrqzjdd
|
||||
$ cd rlbsdj
|
||||
$ ls
|
||||
56078 bvndq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd dmpsnhdh
|
||||
$ ls
|
||||
dir fnpwwhtj
|
||||
dir lmw
|
||||
9090 mgjpsvl.jlh
|
||||
186374 pbb.zln
|
||||
$ cd fnpwwhtj
|
||||
$ ls
|
||||
dir cgp
|
||||
$ cd cgp
|
||||
$ ls
|
||||
81938 hjpmqrq
|
||||
281971 jvszf
|
||||
151057 wmr.bnf
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd lmw
|
||||
$ ls
|
||||
dir bfbv
|
||||
56929 pbb.zln
|
||||
dir rrqjwpm
|
||||
dir sngm
|
||||
$ cd bfbv
|
||||
$ ls
|
||||
92667 qrrttb.jgp
|
||||
$ cd ..
|
||||
$ cd rrqjwpm
|
||||
$ ls
|
||||
25739 cqljn.zqw
|
||||
91325 dncdssn.hdr
|
||||
$ cd ..
|
||||
$ cd sngm
|
||||
$ ls
|
||||
282163 jgrj
|
||||
dir lmw
|
||||
237524 lmw.dff
|
||||
153497 lmw.ntg
|
||||
dir lqd
|
||||
dir szn
|
||||
143535 tvpvc.qpr
|
||||
98326 vbfgh
|
||||
$ cd lmw
|
||||
$ ls
|
||||
32484 dncdssn.hdr
|
||||
dir glwr
|
||||
$ cd glwr
|
||||
$ ls
|
||||
144719 frqqdsr.hbf
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd lqd
|
||||
$ ls
|
||||
231401 dncdssn.hdr
|
||||
dir jnjqmvg
|
||||
dir lmw
|
||||
199704 rrqjwpm
|
||||
$ cd jnjqmvg
|
||||
$ ls
|
||||
104947 trpsrfjz.brg
|
||||
$ cd ..
|
||||
$ cd lmw
|
||||
$ ls
|
||||
230298 rrqjwpm.nnv
|
||||
158947 wfv.qrb
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd szn
|
||||
$ ls
|
||||
197974 frqqdsr.hbf
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd fcnqg
|
||||
$ ls
|
||||
251609 dncdssn.hdr
|
||||
289497 jdjmftqs
|
||||
228459 qbmthcq
|
||||
$ cd ..
|
||||
$ cd jvwtm
|
||||
$ ls
|
||||
dir dmpsnhdh
|
||||
47959 pbb.zln
|
||||
dir tlr
|
||||
dir twpq
|
||||
dir wbgcsw
|
||||
dir zjmldjdh
|
||||
$ cd dmpsnhdh
|
||||
$ ls
|
||||
247567 bnl
|
||||
102471 bnl.wdm
|
||||
80054 fhqvp.hfm
|
||||
dir llhp
|
||||
dir mnsbh
|
||||
dir mpplsfjp
|
||||
20844 mtvl.lmp
|
||||
$ cd llhp
|
||||
$ ls
|
||||
180255 dmpsnhdh
|
||||
$ cd ..
|
||||
$ cd mnsbh
|
||||
$ ls
|
||||
267627 dmpsnhdh
|
||||
$ cd ..
|
||||
$ cd mpplsfjp
|
||||
$ ls
|
||||
dir bnl
|
||||
233742 tcnpvqc.tdr
|
||||
$ cd bnl
|
||||
$ ls
|
||||
243223 fcqrwd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd tlr
|
||||
$ ls
|
||||
dir vcsngm
|
||||
dir wndmt
|
||||
$ cd vcsngm
|
||||
$ ls
|
||||
36434 czs.dnv
|
||||
$ cd ..
|
||||
$ cd wndmt
|
||||
$ ls
|
||||
dir fvmtfcqd
|
||||
dir nvdb
|
||||
dir nwqqgl
|
||||
dir sbspgnpm
|
||||
$ cd fvmtfcqd
|
||||
$ ls
|
||||
237025 nzttjt.rzh
|
||||
$ cd ..
|
||||
$ cd nvdb
|
||||
$ ls
|
||||
235328 dnrqwqtp.vfc
|
||||
51984 rhblt.mfz
|
||||
51332 rjhvhw
|
||||
$ cd ..
|
||||
$ cd nwqqgl
|
||||
$ ls
|
||||
203534 cjghw
|
||||
dir cljbrh
|
||||
$ cd cljbrh
|
||||
$ ls
|
||||
133820 lmw.dnd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd sbspgnpm
|
||||
$ ls
|
||||
270010 hjpmqrq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd twpq
|
||||
$ ls
|
||||
dir dmpsnhdh
|
||||
dir hbchdjjp
|
||||
247649 hjpmqrq
|
||||
29891 rrqjwpm
|
||||
72407 twpq.crb
|
||||
$ cd dmpsnhdh
|
||||
$ ls
|
||||
251490 dncdssn.hdr
|
||||
222231 hjpmqrq
|
||||
102058 pbb.zln
|
||||
$ cd ..
|
||||
$ cd hbchdjjp
|
||||
$ ls
|
||||
70058 dprrmd.qcd
|
||||
230958 tsdbl.bnq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd wbgcsw
|
||||
$ ls
|
||||
292028 bhtfcf
|
||||
dir bnl
|
||||
dir bqq
|
||||
dir ctnlpgt
|
||||
247888 hblhfvwj
|
||||
dir hbqm
|
||||
277949 pbb.zln
|
||||
106225 rrqjwpm
|
||||
125927 ssqpmlfb.gwm
|
||||
dir zqmjwsgz
|
||||
dir zwwphs
|
||||
$ cd bnl
|
||||
$ ls
|
||||
dir fbbr
|
||||
240500 frqqdsr.hbf
|
||||
dir mzfrdl
|
||||
25137 srqlww.mcj
|
||||
dir tqgrdz
|
||||
dir ztrnq
|
||||
$ cd fbbr
|
||||
$ ls
|
||||
84414 mjbw.dhs
|
||||
$ cd ..
|
||||
$ cd mzfrdl
|
||||
$ ls
|
||||
135647 bccwgn
|
||||
dir cjdptqgh
|
||||
dir hwdnrqns
|
||||
dir prq
|
||||
$ cd cjdptqgh
|
||||
$ ls
|
||||
147946 mdgl.drz
|
||||
11972 pbb.zln
|
||||
$ cd ..
|
||||
$ cd hwdnrqns
|
||||
$ ls
|
||||
dir dmpsnhdh
|
||||
$ cd dmpsnhdh
|
||||
$ ls
|
||||
254432 phthmn
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd prq
|
||||
$ ls
|
||||
75827 dmpsnhdh.rtl
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd tqgrdz
|
||||
$ ls
|
||||
251475 bjwnll.rlw
|
||||
$ cd ..
|
||||
$ cd ztrnq
|
||||
$ ls
|
||||
208497 bnl.dtr
|
||||
179376 gqnbswcj.hht
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd bqq
|
||||
$ ls
|
||||
202201 bnl.lbm
|
||||
$ cd ..
|
||||
$ cd ctnlpgt
|
||||
$ ls
|
||||
269484 vsfvzrpr
|
||||
$ cd ..
|
||||
$ cd hbqm
|
||||
$ ls
|
||||
74455 bvnfz
|
||||
42748 pbb.zln
|
||||
$ cd ..
|
||||
$ cd zqmjwsgz
|
||||
$ ls
|
||||
146194 pbb.zln
|
||||
$ cd ..
|
||||
$ cd zwwphs
|
||||
$ ls
|
||||
209587 mtbzd.nwb
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd zjmldjdh
|
||||
$ ls
|
||||
dir cdq
|
||||
dir mdclfbs
|
||||
dir tfc
|
||||
132043 wrm
|
||||
$ cd cdq
|
||||
$ ls
|
||||
289173 twpq.mrn
|
||||
$ cd ..
|
||||
$ cd mdclfbs
|
||||
$ ls
|
||||
64639 bnl.jwf
|
||||
dir hpdgt
|
||||
72868 hznfj.nmj
|
||||
159467 lmw.bfz
|
||||
$ cd hpdgt
|
||||
$ ls
|
||||
52760 fcqrwd
|
||||
54661 tzgt.hvh
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd tfc
|
||||
$ ls
|
||||
185481 bwntlh
|
||||
18925 fcqrwd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ldztz
|
||||
$ ls
|
||||
128430 bwz.fcz
|
||||
dir dmpsnhdh
|
||||
dir lbqgz
|
||||
dir znrnj
|
||||
$ cd dmpsnhdh
|
||||
$ ls
|
||||
238193 dncdssn.hdr
|
||||
285939 hwfngq.dpw
|
||||
$ cd ..
|
||||
$ cd lbqgz
|
||||
$ ls
|
||||
171931 vgrp
|
||||
$ cd ..
|
||||
$ cd znrnj
|
||||
$ ls
|
||||
153738 vmwwbjqd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd lmmw
|
||||
$ ls
|
||||
dir bqqnsfdj
|
||||
163303 fcqrwd
|
||||
43453 frqqdsr.hbf
|
||||
33319 hjpmqrq
|
||||
dir rlpcqtzg
|
||||
$ cd bqqnsfdj
|
||||
$ ls
|
||||
dir bnl
|
||||
2251 hjpmqrq
|
||||
14707 rrqjwpm
|
||||
dir tlnbvhdl
|
||||
$ cd bnl
|
||||
$ ls
|
||||
33357 bnl.fqp
|
||||
151237 bnl.vbs
|
||||
40294 dmpsnhdh.hwz
|
||||
76455 dncdssn.hdr
|
||||
290341 hjpmqrq
|
||||
dir lmw
|
||||
dir nqw
|
||||
$ cd lmw
|
||||
$ ls
|
||||
dir sfj
|
||||
$ cd sfj
|
||||
$ ls
|
||||
156532 fcqrwd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd nqw
|
||||
$ ls
|
||||
59928 dncdssn.hdr
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd tlnbvhdl
|
||||
$ ls
|
||||
183301 hjpmqrq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd rlpcqtzg
|
||||
$ ls
|
||||
258638 dqt.mlc
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd wthvqw
|
||||
$ ls
|
||||
224501 pbb.zln
|
||||
$ cd ..
|
||||
$ cd zpdnprb
|
||||
$ ls
|
||||
dir bnl
|
||||
dir ffg
|
||||
dir jljlwpsv
|
||||
212081 lrzc.lhj
|
||||
dir rrqjwpm
|
||||
dir twpq
|
||||
dir vlgsrtm
|
||||
$ cd bnl
|
||||
$ ls
|
||||
124009 hjgjf
|
||||
74860 hjpmqrq
|
||||
84996 lrdl.swf
|
||||
dir pnzmp
|
||||
$ cd pnzmp
|
||||
$ ls
|
||||
dir btbtlrs
|
||||
128636 nfzf
|
||||
$ cd btbtlrs
|
||||
$ ls
|
||||
107651 hhzbwd.wzj
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ffg
|
||||
$ ls
|
||||
57918 jwzbs.tnt
|
||||
$ cd ..
|
||||
$ cd jljlwpsv
|
||||
$ ls
|
||||
188175 dmpsnhdh.nnb
|
||||
46693 fcqrwd
|
||||
111557 pbb.zln
|
||||
$ cd ..
|
||||
$ cd rrqjwpm
|
||||
$ ls
|
||||
dir bftw
|
||||
dir ccsfws
|
||||
87225 mccw
|
||||
290654 pbb.zln
|
||||
147394 twzqc.pbz
|
||||
52983 wsvgf
|
||||
dir wwfgbzqh
|
||||
$ cd bftw
|
||||
$ ls
|
||||
dir brl
|
||||
167154 crs
|
||||
dir lmw
|
||||
dir rrqjwpm
|
||||
dir twpq
|
||||
174963 twpq.wjl
|
||||
dir vnfhb
|
||||
dir wcldzp
|
||||
$ cd brl
|
||||
$ ls
|
||||
297937 wspcnp
|
||||
$ cd ..
|
||||
$ cd lmw
|
||||
$ ls
|
||||
166695 mcjql.jrv
|
||||
$ cd ..
|
||||
$ cd rrqjwpm
|
||||
$ ls
|
||||
198762 mwn
|
||||
$ cd ..
|
||||
$ cd twpq
|
||||
$ ls
|
||||
141835 jlwf.hcd
|
||||
$ cd ..
|
||||
$ cd vnfhb
|
||||
$ ls
|
||||
128626 tvmwhq.wfn
|
||||
$ cd ..
|
||||
$ cd wcldzp
|
||||
$ ls
|
||||
dir ncq
|
||||
dir twpq
|
||||
$ cd ncq
|
||||
$ ls
|
||||
dir wrtw
|
||||
$ cd wrtw
|
||||
$ ls
|
||||
133331 fcqrwd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd twpq
|
||||
$ ls
|
||||
151811 fcqrwd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ccsfws
|
||||
$ ls
|
||||
100548 twpq.ppm
|
||||
$ cd ..
|
||||
$ cd wwfgbzqh
|
||||
$ ls
|
||||
dir lmw
|
||||
dir mfms
|
||||
dir pjbjgbcl
|
||||
204154 qtflzwm
|
||||
226500 vdmjj.htj
|
||||
dir wzqbwr
|
||||
$ cd lmw
|
||||
$ ls
|
||||
dir bgl
|
||||
95150 dncdssn.hdr
|
||||
119653 frqqdsr.hbf
|
||||
97941 hjpmqrq
|
||||
dir jqthwzj
|
||||
$ cd bgl
|
||||
$ ls
|
||||
dir lmw
|
||||
dir rrqjwpm
|
||||
$ cd lmw
|
||||
$ ls
|
||||
233655 wmdldvbz
|
||||
$ cd ..
|
||||
$ cd rrqjwpm
|
||||
$ ls
|
||||
242918 frqqdsr.hbf
|
||||
227581 hjpmqrq
|
||||
dir hsvnmlp
|
||||
dir nsch
|
||||
25524 pbb.zln
|
||||
dir qlgg
|
||||
dir twpq
|
||||
67453 twpq.fms
|
||||
$ cd hsvnmlp
|
||||
$ ls
|
||||
264517 pbb.zln
|
||||
$ cd ..
|
||||
$ cd nsch
|
||||
$ ls
|
||||
7898 cmsdzh
|
||||
233270 dmpsnhdh.bsq
|
||||
101256 frl
|
||||
133902 jzvh.vdv
|
||||
dir lmw
|
||||
dir sgjsg
|
||||
130245 wcftvft
|
||||
$ cd lmw
|
||||
$ ls
|
||||
69572 bnjnc.csp
|
||||
$ cd ..
|
||||
$ cd sgjsg
|
||||
$ ls
|
||||
38856 tnzpz.tbq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd qlgg
|
||||
$ ls
|
||||
276013 frbstg.pzb
|
||||
$ cd ..
|
||||
$ cd twpq
|
||||
$ ls
|
||||
136454 fhwz.bqb
|
||||
94099 rglp
|
||||
114026 tsrt.cbd
|
||||
26252 zhclpzm.rqf
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd jqthwzj
|
||||
$ ls
|
||||
128200 lmw.btl
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd mfms
|
||||
$ ls
|
||||
274935 dmpsnhdh
|
||||
76547 lchwq.dsd
|
||||
215701 pbb.zln
|
||||
dir rmwtvjt
|
||||
$ cd rmwtvjt
|
||||
$ ls
|
||||
74490 hjpmqrq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd pjbjgbcl
|
||||
$ ls
|
||||
231757 cjcpwwc.wbf
|
||||
dir cswvftzs
|
||||
dir jtvtg
|
||||
dir lmw
|
||||
dir tnctbjr
|
||||
dir tqsrfhdr
|
||||
$ cd cswvftzs
|
||||
$ ls
|
||||
dir dchqnbns
|
||||
dir smf
|
||||
$ cd dchqnbns
|
||||
$ ls
|
||||
94111 szl.hqs
|
||||
$ cd ..
|
||||
$ cd smf
|
||||
$ ls
|
||||
dir dlnsgvl
|
||||
dir zglt
|
||||
$ cd dlnsgvl
|
||||
$ ls
|
||||
dir dsz
|
||||
$ cd dsz
|
||||
$ ls
|
||||
156473 hjpmqrq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd zglt
|
||||
$ ls
|
||||
295383 frgg.sdp
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd jtvtg
|
||||
$ ls
|
||||
202254 bftv.rqb
|
||||
58419 lmw
|
||||
$ cd ..
|
||||
$ cd lmw
|
||||
$ ls
|
||||
8097 fcqrwd
|
||||
$ cd ..
|
||||
$ cd tnctbjr
|
||||
$ ls
|
||||
250830 frqqdsr.hbf
|
||||
dir gzrcqr
|
||||
$ cd gzrcqr
|
||||
$ ls
|
||||
dir fnzgsnv
|
||||
$ cd fnzgsnv
|
||||
$ ls
|
||||
117215 hjpmqrq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd tqsrfhdr
|
||||
$ ls
|
||||
96381 lmw
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd wzqbwr
|
||||
$ ls
|
||||
149066 dmpsnhdh.vnd
|
||||
dir dpbcgfdr
|
||||
dir swp
|
||||
14495 twpq.gsb
|
||||
dir zhj
|
||||
$ cd dpbcgfdr
|
||||
$ ls
|
||||
12909 dmpsnhdh
|
||||
dir jvn
|
||||
173491 mnhpr.lpr
|
||||
222018 rfqfjmd.jqq
|
||||
205077 wbbdrpr.hzj
|
||||
dir wzpbbbhm
|
||||
$ cd jvn
|
||||
$ ls
|
||||
117656 vqddrqlq.nfd
|
||||
233109 vqqvh.swz
|
||||
$ cd ..
|
||||
$ cd wzpbbbhm
|
||||
$ ls
|
||||
143534 pbb.zln
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd swp
|
||||
$ ls
|
||||
131295 pbb.zln
|
||||
$ cd ..
|
||||
$ cd zhj
|
||||
$ ls
|
||||
166268 pbb.zln
|
||||
33734 rrqjwpm.blg
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd twpq
|
||||
$ ls
|
||||
dir bppvlwqs
|
||||
dir bvh
|
||||
dir rmcdr
|
||||
dir tdn
|
||||
2230 whb.lfb
|
||||
dir wwtwnvh
|
||||
$ cd bppvlwqs
|
||||
$ ls
|
||||
195026 hvlhgsw
|
||||
279259 rrqjwpm
|
||||
$ cd ..
|
||||
$ cd bvh
|
||||
$ ls
|
||||
dir lmw
|
||||
$ cd lmw
|
||||
$ ls
|
||||
66958 pdqnd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd rmcdr
|
||||
$ ls
|
||||
dir dmpsnhdh
|
||||
182930 grj
|
||||
dir pmrdhrth
|
||||
119725 qpcqclqh
|
||||
77890 sjgfjz
|
||||
142855 twpq
|
||||
dir zbmcrvbh
|
||||
$ cd dmpsnhdh
|
||||
$ ls
|
||||
dir rrqjwpm
|
||||
188474 zgjzpbl.vgv
|
||||
$ cd rrqjwpm
|
||||
$ ls
|
||||
dir bnl
|
||||
dir lmw
|
||||
7598 vsntvs.pdv
|
||||
$ cd bnl
|
||||
$ ls
|
||||
245600 lmw.mgf
|
||||
$ cd ..
|
||||
$ cd lmw
|
||||
$ ls
|
||||
73396 hjpmqrq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd pmrdhrth
|
||||
$ ls
|
||||
173155 rrqjwpm.pjw
|
||||
178530 smgpzs.qtj
|
||||
$ cd ..
|
||||
$ cd zbmcrvbh
|
||||
$ ls
|
||||
124201 fcqrwd
|
||||
135578 hjpmqrq
|
||||
54356 hnztplsp.qlh
|
||||
dir lmw
|
||||
58350 pbb.zln
|
||||
dir qfrvdm
|
||||
dir rcg
|
||||
15267 rwbzjpt.djn
|
||||
$ cd lmw
|
||||
$ ls
|
||||
dir bbbll
|
||||
28362 bfgfwlf.wvg
|
||||
229637 dmpndms.fln
|
||||
146121 dncdssn.hdr
|
||||
131039 frqqdsr.hbf
|
||||
152805 hjpmqrq
|
||||
dir mlz
|
||||
$ cd bbbll
|
||||
$ ls
|
||||
169940 dncdssn.hdr
|
||||
216888 pbb.zln
|
||||
248369 tjpmlr.vmf
|
||||
$ cd ..
|
||||
$ cd mlz
|
||||
$ ls
|
||||
115167 bhfv.fts
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd qfrvdm
|
||||
$ ls
|
||||
284564 pbb.zln
|
||||
$ cd ..
|
||||
$ cd rcg
|
||||
$ ls
|
||||
dir sqzjz
|
||||
$ cd sqzjz
|
||||
$ ls
|
||||
116435 jrstpcpl.zsq
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd tdn
|
||||
$ ls
|
||||
143971 cmg
|
||||
133317 fcqrwd
|
||||
dir pstpclp
|
||||
133161 tddv
|
||||
$ cd pstpclp
|
||||
$ ls
|
||||
267351 hjpmqrq
|
||||
86930 rrqjwpm.dvl
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd wwtwnvh
|
||||
$ ls
|
||||
256584 frqqdsr.hbf
|
||||
114564 twpq.wrd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd vlgsrtm
|
||||
$ ls
|
||||
148089 bnl.jzj
|
||||
119796 cjfphsfw.hnd
|
||||
197668 cpw
|
||||
dir dmpsnhdh
|
||||
dir fjsglr
|
||||
dir lmw
|
||||
dir lqgrft
|
||||
9231 pltdltrs
|
||||
dir rmdp
|
||||
109777 rncfff.fll
|
||||
dir vgjzqjpq
|
||||
dir ztnqnfnq
|
||||
$ cd dmpsnhdh
|
||||
$ ls
|
||||
dir lltnrdtv
|
||||
dir scthsg
|
||||
$ cd lltnrdtv
|
||||
$ ls
|
||||
179511 pcvmpz
|
||||
90913 tbr
|
||||
$ cd ..
|
||||
$ cd scthsg
|
||||
$ ls
|
||||
dir rrqjwpm
|
||||
$ cd rrqjwpm
|
||||
$ ls
|
||||
188629 fcqrwd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd fjsglr
|
||||
$ ls
|
||||
139754 fcqrwd
|
||||
dir pnsjwfzc
|
||||
$ cd pnsjwfzc
|
||||
$ ls
|
||||
113848 lmw
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd lmw
|
||||
$ ls
|
||||
54999 dmpsnhdh
|
||||
dir ffhcf
|
||||
251476 frqqdsr.hbf
|
||||
dir jpgqspqw
|
||||
198972 nhfclq.pbh
|
||||
180380 nqmjnvc.fvr
|
||||
dir pfsjwmbc
|
||||
213768 rcvccgcd
|
||||
$ cd ffhcf
|
||||
$ ls
|
||||
40478 svmwstq.sjj
|
||||
$ cd ..
|
||||
$ cd jpgqspqw
|
||||
$ ls
|
||||
22181 hjpmqrq
|
||||
$ cd ..
|
||||
$ cd pfsjwmbc
|
||||
$ ls
|
||||
dir bcvchw
|
||||
$ cd bcvchw
|
||||
$ ls
|
||||
225892 bnl.nwc
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd lqgrft
|
||||
$ ls
|
||||
dir rrqjwpm
|
||||
dir twpq
|
||||
$ cd rrqjwpm
|
||||
$ ls
|
||||
54786 fcqrwd
|
||||
3053 tthhqjm.ntd
|
||||
$ cd ..
|
||||
$ cd twpq
|
||||
$ ls
|
||||
109355 bnl
|
||||
dir lmw
|
||||
dir mhgqt
|
||||
301291 rrqjwpm.lrm
|
||||
271233 twpq.srp
|
||||
$ cd lmw
|
||||
$ ls
|
||||
dir lmw
|
||||
dir lngbszqm
|
||||
$ cd lmw
|
||||
$ ls
|
||||
139640 pbb.zln
|
||||
$ cd ..
|
||||
$ cd lngbszqm
|
||||
$ ls
|
||||
98279 mqvq.gsj
|
||||
283599 rvjd.dvt
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd mhgqt
|
||||
$ ls
|
||||
208165 fcqrwd
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd rmdp
|
||||
$ ls
|
||||
dir bqn
|
||||
170956 fcqrwd
|
||||
90954 snnttp.gld
|
||||
$ cd bqn
|
||||
$ ls
|
||||
75628 hdrgbrpc
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd vgjzqjpq
|
||||
$ ls
|
||||
dir bnl
|
||||
dir wpfw
|
||||
$ cd bnl
|
||||
$ ls
|
||||
25911 pbb.zln
|
||||
$ cd ..
|
||||
$ cd wpfw
|
||||
$ ls
|
||||
247784 bzll.ltc
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd ztnqnfnq
|
||||
$ ls
|
||||
dir dtpzsrfc
|
||||
214055 srgzhp.nlr
|
||||
$ cd dtpzsrfc
|
||||
$ ls
|
||||
142652 bhgwj
|
||||
102
days/7/puzzle.txt
Normal file
102
days/7/puzzle.txt
Normal file
@@ -0,0 +1,102 @@
|
||||
--- Day 7: No Space Left On Device ---
|
||||
|
||||
You can hear birds chirping and raindrops hitting leaves as the expedition proceeds. Occasionally, you can even hear much louder sounds in the distance; how big do the animals get out here, anyway?
|
||||
|
||||
The device the Elves gave you has problems with more than just its communication system. You try to run a system update:
|
||||
|
||||
$ system-update --please --pretty-please-with-sugar-on-top
|
||||
Error: No space left on device
|
||||
|
||||
Perhaps you can delete some files to make space for the update?
|
||||
|
||||
You browse around the filesystem to assess the situation and save the resulting terminal output (your puzzle input). For example:
|
||||
|
||||
$ cd /
|
||||
$ ls
|
||||
dir a
|
||||
14848514 b.txt
|
||||
8504156 c.dat
|
||||
dir d
|
||||
$ cd a
|
||||
$ ls
|
||||
dir e
|
||||
29116 f
|
||||
2557 g
|
||||
62596 h.lst
|
||||
$ cd e
|
||||
$ ls
|
||||
584 i
|
||||
$ cd ..
|
||||
$ cd ..
|
||||
$ cd d
|
||||
$ ls
|
||||
4060174 j
|
||||
8033020 d.log
|
||||
5626152 d.ext
|
||||
7214296 k
|
||||
|
||||
The filesystem consists of a tree of files (plain data) and directories (which can contain other directories or files). The outermost directory is called /. You can navigate around the filesystem, moving into or out of directories and listing the contents of the directory you're currently in.
|
||||
|
||||
Within the terminal output, lines that begin with $ are commands you executed, very much like some modern computers:
|
||||
|
||||
cd means change directory. This changes which directory is the current directory, but the specific result depends on the argument:
|
||||
cd x moves in one level: it looks in the current directory for the directory named x and makes it the current directory.
|
||||
cd .. moves out one level: it finds the directory that contains the current directory, then makes that directory the current directory.
|
||||
cd / switches the current directory to the outermost directory, /.
|
||||
ls means list. It prints out all of the files and directories immediately contained by the current directory:
|
||||
123 abc means that the current directory contains a file named abc with size 123.
|
||||
dir xyz means that the current directory contains a directory named xyz.
|
||||
|
||||
Given the commands and output in the example above, you can determine that the filesystem looks visually like this:
|
||||
|
||||
- / (dir)
|
||||
- a (dir)
|
||||
- e (dir)
|
||||
- i (file, size=584)
|
||||
- f (file, size=29116)
|
||||
- g (file, size=2557)
|
||||
- h.lst (file, size=62596)
|
||||
- b.txt (file, size=14848514)
|
||||
- c.dat (file, size=8504156)
|
||||
- d (dir)
|
||||
- j (file, size=4060174)
|
||||
- d.log (file, size=8033020)
|
||||
- d.ext (file, size=5626152)
|
||||
- k (file, size=7214296)
|
||||
|
||||
Here, there are four directories: / (the outermost directory), a and d (which are in /), and e (which is in a). These directories also contain files of various sizes.
|
||||
|
||||
Since the disk is full, your first step should probably be to find directories that are good candidates for deletion. To do this, you need to determine the total size of each directory. The total size of a directory is the sum of the sizes of the files it contains, directly or indirectly. (Directories themselves do not count as having any intrinsic size.)
|
||||
|
||||
The total sizes of the directories above can be found as follows:
|
||||
|
||||
The total size of directory e is 584 because it contains a single file i of size 584 and no other directories.
|
||||
The directory a has total size 94853 because it contains files f (size 29116), g (size 2557), and h.lst (size 62596), plus file i indirectly (a contains e which contains i).
|
||||
Directory d has total size 24933642.
|
||||
As the outermost directory, / contains every file. Its total size is 48381165, the sum of the size of every file.
|
||||
|
||||
To begin, find all of the directories with a total size of at most 100000, then calculate the sum of their total sizes. In the example above, these directories are a and e; the sum of their total sizes is 95437 (94853 + 584). (As in this example, this process can count files more than once!)
|
||||
|
||||
Find all of the directories with a total size of at most 100000. What is the sum of the total sizes of those directories?
|
||||
|
||||
Your puzzle answer was 1444896.
|
||||
--- Part Two ---
|
||||
|
||||
Now, you're ready to choose a directory to delete.
|
||||
|
||||
The total disk space available to the filesystem is 70000000. To run the update, you need unused space of at least 30000000. You need to find a directory you can delete that will free up enough space to run the update.
|
||||
|
||||
In the example above, the total size of the outermost directory (and thus the total amount of used space) is 48381165; this means that the size of the unused space must currently be 21618835, which isn't quite the 30000000 required by the update. Therefore, the update still requires a directory with total size of at least 8381165 to be deleted before it can run.
|
||||
|
||||
To achieve this, you have the following options:
|
||||
|
||||
Delete directory e, which would increase unused space by 584.
|
||||
Delete directory a, which would increase unused space by 94853.
|
||||
Delete directory d, which would increase unused space by 24933642.
|
||||
Delete directory /, which would increase unused space by 48381165.
|
||||
|
||||
Directories e and a are both too small; deleting them would not free up enough space. However, directories d and / are both big enough! Between these, choose the smallest: d, increasing unused space by 24933642.
|
||||
|
||||
Find the smallest directory that, if deleted, would free up enough space on the filesystem to run the update. What is the total size of that directory?
|
||||
|
||||
Your puzzle answer was 404395.
|
||||
60
days/7/solution.nix
Normal file
60
days/7/solution.nix
Normal file
@@ -0,0 +1,60 @@
|
||||
with import ../../util.nix;
|
||||
|
||||
let
|
||||
# read input
|
||||
cmdOuts = splitString "\n$ " (removePrefix "$ " (readFile ./input));
|
||||
|
||||
fileTree =
|
||||
let
|
||||
start = { cwd = []; tree = {}; };
|
||||
|
||||
applyCmd = acc: cmdOut:
|
||||
let
|
||||
# parse cmd + cmd output
|
||||
lines = splitString "\n" cmdOut;
|
||||
cmd = splitString " " (head lines);
|
||||
out = tail lines;
|
||||
|
||||
# apply cmds
|
||||
applyCd = cwd: param:
|
||||
if param == ".." then dropLast cwd
|
||||
else if param == "/" then []
|
||||
else cwd ++ [param];
|
||||
applyLs = cwd: param:
|
||||
let
|
||||
parseFileDir = splitLine:
|
||||
if head splitLine == "dir" then { ${last splitLine} = {}; }
|
||||
else { ${last splitLine} = toInt (head splitLine); };
|
||||
makeSubTree = combineAttrs (map (line: parseFileDir (splitString " " line)) param);
|
||||
in
|
||||
setAttrByPath cwd makeSubTree;
|
||||
in
|
||||
if head cmd == "cd" then
|
||||
{ inherit (acc) tree; cwd = applyCd acc.cwd (last cmd); }
|
||||
else # ls
|
||||
{ inherit (acc) cwd; tree = recursiveUpdate acc.tree (applyLs acc.cwd out); };
|
||||
in (foldl applyCmd start cmdOuts).tree;
|
||||
|
||||
sizeOfDir = dir:
|
||||
sum (map (v: if isAttrs v then sizeOfDir v else v) (attrValues dir));
|
||||
|
||||
# a flat list of sizes for all directories
|
||||
dirSizes = recurisveVisitAttrs (n: v: if isAttrs v then sizeOfDir v else 0) fileTree;
|
||||
|
||||
# a list of sizes for small directories
|
||||
smallDirSizes =
|
||||
foldl (acc: size: if size < 100000 && size != 0 then acc ++ [size] else acc) [] dirSizes;
|
||||
|
||||
totalUsedSize = sizeOfDir fileTree;
|
||||
|
||||
# smallest directory to delete to free target size
|
||||
minDirOfAtLeastSize = targetSize: foldl (acc: s: if s >= targetSize && s < acc then s else acc) totalUsedSize dirSizes;
|
||||
|
||||
totalFsSize = 70000000;
|
||||
fsSizeNeeded = 30000000;
|
||||
availableSpace = totalFsSize - totalUsedSize;
|
||||
spaceNeeded = fsSizeNeeded - availableSpace;
|
||||
in rec {
|
||||
part1 = sum smallDirSizes;
|
||||
part2 = minDirOfAtLeastSize spaceNeeded;
|
||||
}
|
||||
99
days/8/input
Normal file
99
days/8/input
Normal file
@@ -0,0 +1,99 @@
|
||||
121212011303121030310342042402330124244111344151215543452341031241241020400101112013333020112100012
|
||||
021211021113201200034023433130134132413414155334115143443355322133444324121312404302011201132211211
|
||||
112100131112221303204244242431121003451531135255455445141455432541312201002214304203010313110102221
|
||||
020110213013113103013204332232423553543445433222155153431441144442133012114241240204113022033210212
|
||||
220211123123023221431120203212535513244235435131233452411353515142141342420233430124211033211103201
|
||||
201022331320201202140104411413522115413213345254535252552153334555534422544330002102424023033322310
|
||||
002011111302111311312434241323154521232411313453434133354341132333115133343011222312043111232231222
|
||||
013200323000441302142430153512351514554144243134335236231323244242514241141543000044010321332222320
|
||||
030100102011023442422335322343425254455155645352466333266624622411411531253414114432034034311131222
|
||||
322030202043440231214443243242233422366246622362565344565233563555324325333511154331042320111021203
|
||||
213003300414441314312513553152343433222235343463444622556454453564615122442121152433110144401122122
|
||||
021322211313341320225244345212526464422556233255442242524636654565546141313334241514223301121200020
|
||||
200002004321134302434442521521345336526234552642236565226243663554552342241443523255344432431132112
|
||||
112123334441323144345534151556562252635233363355224653254253523344642442351332145221300143332241010
|
||||
022320131410010151254142156636463345252452625423376754343432433653322245664252425413321040141302232
|
||||
213010110022111155333545424663525462442454635436533755536636426266424643655512213435531304111222000
|
||||
130321001200011144555214565543554643256537345337535434444635673532262633225653144544344432301332432
|
||||
022001420212325411453144445434236254466446337636634543774555355374353662522435224132353244034031000
|
||||
002330010431341554551434253422254276654743665367455334457473364473622344254456352551331135411240234
|
||||
312302212143534422423465564263334474566667447435655556674563544344656444223542363235332253222404014
|
||||
212121032141343134355434224534464675674454653637667644577377433543363445523354433252255211144312024
|
||||
032232100153554252235624563224356655547365457745734763767533657435437475664325434442351433444413432
|
||||
110200301524124453246544643533747547556475446575748877586377673774564455425343566541443431232401214
|
||||
401423221442241424632554334447574565754568668848564545648588775376576657452244522662354432522131430
|
||||
104434155511311263462424433673653733578444556668584487456756485643337355375433336556353432343531212
|
||||
232312213322425552554325453754633766755865457774587845874856686753435335647736522565231415412413211
|
||||
431001313425254645265623577666433748788645854658656747656847848685876376476452325453225544433534043
|
||||
313010515252544635324244436374454465476587445778467648477556767674587735374763224263634154351324340
|
||||
144012455355126524425677566774755774557844864767878874787745686455847654436466543454462444251355032
|
||||
000424311444526324323553475355554746544864774656675767558855668566488767334344352635356531552442234
|
||||
013342542545525235236366465754548568775676857795999885788785445466456855736374463562353442551411143
|
||||
311242111152354425663445553378875855775477957697697578856798848566484877333477545525362635425135332
|
||||
341433232336543522273555566685786646768568869658667859787755556468565557473633366352553433511511241
|
||||
200113144455442526465477677487545446885795579597859665775997897975488858867346567332543224253422254
|
||||
321322215536436463377577768487764477789778877885995868965678966676487767568444576663626645634432310
|
||||
443312521324223555545636634855747678676887796567769797975557659998448677554734374642453342212431515
|
||||
411525331432266364737736458775755877785596969568668977556998758996667657677735543737262252641333145
|
||||
442522353464222643737346685584745598686858597889698887876897967879654657446543634637433266563152432
|
||||
454243531252525455465534878756559675878866666799676687797788596788597656655885633463554433643143535
|
||||
254423532244235655655733654475546977569587699768887776679688866766759778548883343347646235554115351
|
||||
314314544653622563457635588785666699859596886897989897689788798876985987846687577376763532335135532
|
||||
412142442632445563355677548756466696866899796677677889898887669778596858564457554576762226623533152
|
||||
332242122354466554535565547487598955988896787986776867776877888955599984888475443433742663453323444
|
||||
144151346544425765674636457564767658869896996679899997667979896767868998474585737643642635544533421
|
||||
314415255322554774543648464765966788579669799899779987788989898667968687447844667337662354653241144
|
||||
531151535525325346676758455659698557997896686798987988779868698785888786564857433665336664523341524
|
||||
433523552663344344473467546666588759889896677787898898779776878975758958484784434645376646243431411
|
||||
515135226664626774436754686667956875999777879798898978998697788977889685548778857447736246224344422
|
||||
145435565465625543633666766675858858766886989979799999899997668785989599567745864566755645326525215
|
||||
451353163534546735577664785687859598879898988887899889888777867978579599658876447575744455463535421
|
||||
224133454534644344357668774586679766688667987978788777787978767996768679587486553753676234444243145
|
||||
212224343354636435353376785568986575788667679879987787799996968667996977844764744747546562653555311
|
||||
533215146234664535345776886669575768966898869977999998888778799896585966878485433376437563225631352
|
||||
511524423463344353364385568455757877769888788888799787979869867976859678654676857776376644445445215
|
||||
351234256625356736743655474675867598588879869899999799789878697766889955677655765744675453466515352
|
||||
334415234234535577366766846485775897899678799797988789798686779975797678558486666454465242325255315
|
||||
141341534526526535446644587564577966676787678799988989799997999875957694554787466435645653653555414
|
||||
313324416232534373476357468674589657599899799798689797986786698995665798657574376535655252364222345
|
||||
311221544446655446757777886865788857567967696689867999769799886898598995658847463557355652223224412
|
||||
455533545356434343353337767878785976765769968899769879969687867689997585485648456367636362352431235
|
||||
344444353536223353357778884687469798765676998669777968698779855796996985778555675367324552333255445
|
||||
051125313425464566733636456767476978655987889896897676668688798768558878654457367667555264222423551
|
||||
353542241453466263566466444568785959568996966999897988769675557699898764775776773566735422341532411
|
||||
022324211323442654554445655776687576866866899996988868898585669578658688644533765553546656434125445
|
||||
114453323344233423677473675646888489555668785777968786767598875656578848476447533734652563225415414
|
||||
114422544242345362734473678567647667869987569695895789896698699557445648854544743436662644341252531
|
||||
121342551166453322745565437644747478898555998668897895775999796995587786474657764352544656531442143
|
||||
303141113253266635447343344867888466769679588758558756866968688847688674876656737744543462242255453
|
||||
211553143135554522563734546548487876869685667557688879976567575866584774455433565742656362424324221
|
||||
124145331431636546255374743445654474455696878969759677857655988487587487353655433225556322453333301
|
||||
212244412131664532653366547437778778757756559965879758976787487565565586665457556563646654415332511
|
||||
011305211242465446332773543655556877674464555978676866698775787766666456756644432225665434112311020
|
||||
004241221433546245432264563633447545674557677448454476555877787756767637433767625564453222213212214
|
||||
310343115521416426645326746575333484685764464876676658588877654688747777476753344453622354123212043
|
||||
140122345414213664253233365647757664866655755465564678758484884488574665556644653435636451242442431
|
||||
244102135324345326634353374375547456884585456867666677454868468687435553747753654545544441144303342
|
||||
432104041214342544334655425474547463448788757857558655488554466655536543533544446366314241124214112
|
||||
323340324334354443354245236535677365643457874448486874757456574363667673472262365365211122323243114
|
||||
430330302152115233222436253333446747553365334585488745577537474744744537762432632263215224143034311
|
||||
311442302225213454546466432534566554436677736533674654344734776664563675555452243452512224320440414
|
||||
012223322322424155255455565223573376357653457774454463735446656766537352553544256234512225223230043
|
||||
301040234123443123232563623663643633535443553744547733637676336764634633454454353153253554114310123
|
||||
133230222202333125332643444534665265775555366656333664577746375536432522432632352414133321233403141
|
||||
130131122340253113451232453334526422447633735643377464757575366556545326434445112532143151333444233
|
||||
123141143123235144241534634442646462453347557645744747744444465243533265534335312135141342344141402
|
||||
003321424141234554211325444625623263425263674757674335463664556352656232255214521252351130300034201
|
||||
112312001424231145115555432333342644223335545625473535264242623526263634466325543223334324011234121
|
||||
000221124024240324421331531356324362422542263363234455442425223655564222213351113145440100221140111
|
||||
033311243403013332514242224522366666224344244563634356355445532225333344231213331535121420140433130
|
||||
303323104303402340514525522211134233445565565244563523544534354246644545425131313341424434300003032
|
||||
011323012002420122421144112234234535335555456426433464426356545662531135434153435334430024313303120
|
||||
031202221220044224202355531555315433255252442366562265422542236431311515541243440113402324302332130
|
||||
201100001202303212021041315334534534143533633663456666642564224231354441333414120340321342200233132
|
||||
221201212012302142404132243444141351134325452546423522255432534112215145442242342110400232302021322
|
||||
220223222003322321422133444521333545342441534125321334411524122521525135453342042001304403200303321
|
||||
222220302103313411301404030054314141423224422211413131115533525334423132133412232211310121021132101
|
||||
122003101321113124242202433422213424522545354542323525531511234344125550023302132204220012211210020
|
||||
000112201313122024204100421340022524132134142432553221315323551243135131212431102431311323201221002
|
||||
020202200133011113024021012122001204231413324533351552454535514252231001424310042133312311233022121
|
||||
74
days/8/puzzle.txt
Normal file
74
days/8/puzzle.txt
Normal file
@@ -0,0 +1,74 @@
|
||||
--- Day 8: Treetop Tree House ---
|
||||
|
||||
The expedition comes across a peculiar patch of tall trees all planted carefully in a grid. The Elves explain that a previous expedition planted these trees as a reforestation effort. Now, they're curious if this would be a good location for a tree house.
|
||||
|
||||
First, determine whether there is enough tree cover here to keep a tree house hidden. To do this, you need to count the number of trees that are visible from outside the grid when looking directly along a row or column.
|
||||
|
||||
The Elves have already launched a quadcopter to generate a map with the height of each tree (your puzzle input). For example:
|
||||
|
||||
30373
|
||||
25512
|
||||
65332
|
||||
33549
|
||||
35390
|
||||
|
||||
Each tree is represented as a single digit whose value is its height, where 0 is the shortest and 9 is the tallest.
|
||||
|
||||
A tree is visible if all of the other trees between it and an edge of the grid are shorter than it. Only consider trees in the same row or column; that is, only look up, down, left, or right from any given tree.
|
||||
|
||||
All of the trees around the edge of the grid are visible - since they are already on the edge, there are no trees to block the view. In this example, that only leaves the interior nine trees to consider:
|
||||
|
||||
The top-left 5 is visible from the left and top. (It isn't visible from the right or bottom since other trees of height 5 are in the way.)
|
||||
The top-middle 5 is visible from the top and right.
|
||||
The top-right 1 is not visible from any direction; for it to be visible, there would need to only be trees of height 0 between it and an edge.
|
||||
The left-middle 5 is visible, but only from the right.
|
||||
The center 3 is not visible from any direction; for it to be visible, there would need to be only trees of at most height 2 between it and an edge.
|
||||
The right-middle 3 is visible from the right.
|
||||
In the bottom row, the middle 5 is visible, but the 3 and 4 are not.
|
||||
|
||||
With 16 trees visible on the edge and another 5 visible in the interior, a total of 21 trees are visible in this arrangement.
|
||||
|
||||
Consider your map; how many trees are visible from outside the grid?
|
||||
|
||||
Your puzzle answer was 1801.
|
||||
--- Part Two ---
|
||||
|
||||
Content with the amount of tree cover available, the Elves just need to know the best spot to build their tree house: they would like to be able to see a lot of trees.
|
||||
|
||||
To measure the viewing distance from a given tree, look up, down, left, and right from that tree; stop if you reach an edge or at the first tree that is the same height or taller than the tree under consideration. (If a tree is right on the edge, at least one of its viewing distances will be zero.)
|
||||
|
||||
The Elves don't care about distant trees taller than those found by the rules above; the proposed tree house has large eaves to keep it dry, so they wouldn't be able to see higher than the tree house anyway.
|
||||
|
||||
In the example above, consider the middle 5 in the second row:
|
||||
|
||||
30373
|
||||
25512
|
||||
65332
|
||||
33549
|
||||
35390
|
||||
|
||||
Looking up, its view is not blocked; it can see 1 tree (of height 3).
|
||||
Looking left, its view is blocked immediately; it can see only 1 tree (of height 5, right next to it).
|
||||
Looking right, its view is not blocked; it can see 2 trees.
|
||||
Looking down, its view is blocked eventually; it can see 2 trees (one of height 3, then the tree of height 5 that blocks its view).
|
||||
|
||||
A tree's scenic score is found by multiplying together its viewing distance in each of the four directions. For this tree, this is 4 (found by multiplying 1 * 1 * 2 * 2).
|
||||
|
||||
However, you can do even better: consider the tree of height 5 in the middle of the fourth row:
|
||||
|
||||
30373
|
||||
25512
|
||||
65332
|
||||
33549
|
||||
35390
|
||||
|
||||
Looking up, its view is blocked at 2 trees (by another tree with a height of 5).
|
||||
Looking left, its view is not blocked; it can see 2 trees.
|
||||
Looking down, its view is also not blocked; it can see 1 tree.
|
||||
Looking right, its view is blocked at 2 trees (by a massive tree of height 9).
|
||||
|
||||
This tree's scenic score is 8 (2 * 2 * 1 * 2); this is the ideal spot for the tree house.
|
||||
|
||||
Consider each tree on your map. What is the highest scenic score possible for any tree?
|
||||
|
||||
Your puzzle answer was 209880.
|
||||
55
days/8/solution.nix
Normal file
55
days/8/solution.nix
Normal file
@@ -0,0 +1,55 @@
|
||||
with import ../../util.nix;
|
||||
|
||||
let
|
||||
input = map (line: map toInt (stringToCharacters line)) (splitString "\n" (readFile ./input));
|
||||
input' = transpose input;
|
||||
|
||||
visibleTrees =
|
||||
let
|
||||
# counts the number of trees visible from a starting
|
||||
hiddenTreesLineDir = l:
|
||||
(foldl
|
||||
(acc: x:
|
||||
if x > acc.highest then { highest = x; out = acc.out ++ [true]; } # visible
|
||||
else { inherit (acc) highest; out = acc.out ++ [false]; }) # hidden
|
||||
{ highest = -1; out = []; } l).out;
|
||||
hiddenTreesLine = l:
|
||||
mergeLists or (hiddenTreesLineDir l) (reverseList (hiddenTreesLineDir (reverseList l)));
|
||||
hiddenTreesGrid = map hiddenTreesLine;
|
||||
hiddenTreesRows = hiddenTreesGrid input;
|
||||
hiddenTreesCols = hiddenTreesGrid input';
|
||||
mergeGrid = f:
|
||||
let
|
||||
w = length hiddenTreesCols;
|
||||
h = length hiddenTreesRows;
|
||||
in genList (i: genList (j: f (elemAt (elemAt hiddenTreesCols i) j) (elemAt (elemAt hiddenTreesRows j) i) ) h) w;
|
||||
in mergeGrid or;
|
||||
|
||||
countVisibleRow = l: sum (map boolToInt l);
|
||||
countVisible = sum (map countVisibleRow visibleTrees);
|
||||
|
||||
# number of trees visible from each point as a score
|
||||
visibleScore =
|
||||
let
|
||||
getCol = x: map (l: elemAt l x) input;
|
||||
getRow = y: elemAt input y;
|
||||
left = x: l: reverseList (take x l);
|
||||
right = x: l: drop (x+1) l;
|
||||
visibleCountDir = treeHeight: l:
|
||||
(foldl (acc: x:
|
||||
if acc.stop == false then
|
||||
if x >= treeHeight then { cnt = acc.cnt +1; stop = true; }
|
||||
else { cnt = acc.cnt +1; stop = false; }
|
||||
else acc) { cnt = 0; stop = false; } l).cnt;
|
||||
treeScore = x: y: v:
|
||||
(visibleCountDir v (left x (getRow y)))
|
||||
* (visibleCountDir v (right x (getRow y)))
|
||||
* (visibleCountDir v (left y (getCol x)))
|
||||
* (visibleCountDir v (right y (getCol x)));
|
||||
in map2D treeScore input;
|
||||
maxVisibleScore = foldr (x: max (maxList x)) 0 visibleScore;
|
||||
|
||||
in rec {
|
||||
part1 = countVisible;
|
||||
part2 = maxVisibleScore;
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
#! /bin/sh
|
||||
|
||||
for i in {1..4}
|
||||
days_dir="./days"
|
||||
days_count=$(find $days_dir -maxdepth 1 -type d -not -path $days_dir | wc -l)
|
||||
|
||||
for i in $(seq 1 $days_count);
|
||||
do
|
||||
echo "--- Day $i ---"
|
||||
nix eval -f $i/solution.nix
|
||||
nix eval -f $days_dir/$i/solution.nix
|
||||
done
|
||||
|
||||
34
util.nix
34
util.nix
@@ -16,16 +16,40 @@ let
|
||||
cutInHalf = l: [(take (length l / 2) l) (drop (length l / 2) l)];
|
||||
# Splits a list into a list of lists with length cnt
|
||||
chunksOf = cnt: l:
|
||||
if length l >= cnt then
|
||||
if length l > 0 then
|
||||
[(take cnt l)] ++ chunksOf cnt (drop cnt l)
|
||||
else [];
|
||||
# same as intersectLists but takes an array of lists to intersect instead of just two
|
||||
intersectManyLists = l:
|
||||
if length l == 0 then []
|
||||
else if length l == 1 then head l
|
||||
else intersectLists (head l) (intersectManyLists (tail l));
|
||||
intersectManyLists = ll: foldr intersectLists (head ll) ll;
|
||||
# converts a boolean to a int (c style)
|
||||
boolToInt = b: if b then 1 else 0;
|
||||
# drops the last element of a list
|
||||
dropLast = l: take (length l - 1) l;
|
||||
# transposes a matrix
|
||||
transpose = ll:
|
||||
let
|
||||
outerSize = length ll;
|
||||
innerSize = length (elemAt ll 0);
|
||||
in genList (i: genList (j: elemAt (elemAt ll j) i) outerSize) innerSize;
|
||||
# attriset recursiveUpdate but for a list of attrisets
|
||||
combineAttrs = foldl recursiveUpdate {};
|
||||
# visits every single attriset element of an attriset recursively
|
||||
# and accumulates the result of every visit in a flat list
|
||||
recurisveVisitAttrs = f: set:
|
||||
let
|
||||
visitor = n: v:
|
||||
if isAttrs v then [(f n v)] ++ recurisveVisitAttrs f v
|
||||
else [(f n v)];
|
||||
in concatLists (map (name: visitor name set.${name}) (attrNames set));
|
||||
# merges two lists of the same size (similar to map but both lists are inputs per iteration)
|
||||
mergeLists = f: a: imap0 (i: f (elemAt a i));
|
||||
map2D = f: ll:
|
||||
let
|
||||
outerSize = length ll;
|
||||
innerSize = length (elemAt ll 0);
|
||||
getElem = x: y: elemAt (elemAt ll y) x;
|
||||
in
|
||||
genList (y: genList (x: f x y (getElem x y)) innerSize) outerSize;
|
||||
};
|
||||
in
|
||||
lib // lib.strings // builtins // utils
|
||||
Reference in New Issue
Block a user