From 9d58986e29631d3a5fd0b545445093704fb13b14 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Wed, 19 Dec 2018 21:03:25 +0000 Subject: [PATCH] Done day 16 --- advent-of-code.cabal | 9 +- data/advent16.txt | 4041 ++++++++++++++++++++++++++++++++++++++ problems/day15.html | 451 +++++ problems/day16.html | 179 ++ src/advent16/advent16.hs | 151 ++ 5 files changed, 4830 insertions(+), 1 deletion(-) create mode 100644 data/advent16.txt create mode 100644 problems/day15.html create mode 100644 problems/day16.html create mode 100644 src/advent16/advent16.hs diff --git a/advent-of-code.cabal b/advent-of-code.cabal index 78e84a1..5e334e9 100644 --- a/advent-of-code.cabal +++ b/advent-of-code.cabal @@ -191,4 +191,11 @@ executable advent15 , containers , pqueue - \ No newline at end of file +executable advent16 + hs-source-dirs: src/advent16 + main-is: advent16.hs + default-language: Haskell2010 + build-depends: base >= 4.7 && < 5 + , text + , megaparsec + , containers diff --git a/data/advent16.txt b/data/advent16.txt new file mode 100644 index 0000000..17feeb7 --- /dev/null +++ b/data/advent16.txt @@ -0,0 +1,4041 @@ +Before: [3, 1, 2, 3] +5 3 1 1 +After: [3, 0, 2, 3] + +Before: [1, 1, 2, 2] +9 0 2 0 +After: [0, 1, 2, 2] + +Before: [0, 1, 3, 3] +12 1 0 3 +After: [0, 1, 3, 1] + +Before: [1, 0, 2, 3] +9 0 2 2 +After: [1, 0, 0, 3] + +Before: [3, 0, 2, 2] +8 0 3 0 +After: [1, 0, 2, 2] + +Before: [3, 1, 0, 0] +11 2 0 2 +After: [3, 1, 1, 0] + +Before: [0, 1, 2, 2] +7 0 0 3 +After: [0, 1, 2, 0] + +Before: [0, 1, 0, 0] +15 1 3 3 +After: [0, 1, 0, 1] + +Before: [3, 0, 0, 2] +8 0 3 1 +After: [3, 1, 0, 2] + +Before: [0, 2, 2, 1] +3 3 2 0 +After: [1, 2, 2, 1] + +Before: [1, 1, 3, 0] +15 1 3 2 +After: [1, 1, 1, 0] + +Before: [3, 1, 1, 2] +1 1 3 0 +After: [0, 1, 1, 2] + +Before: [2, 1, 3, 0] +15 1 3 1 +After: [2, 1, 3, 0] + +Before: [3, 0, 1, 3] +6 2 3 1 +After: [3, 0, 1, 3] + +Before: [2, 1, 1, 2] +1 1 3 1 +After: [2, 0, 1, 2] + +Before: [3, 2, 1, 3] +6 2 3 2 +After: [3, 2, 0, 3] + +Before: [2, 1, 2, 2] +1 1 3 1 +After: [2, 0, 2, 2] + +Before: [1, 2, 1, 3] +5 3 2 2 +After: [1, 2, 0, 3] + +Before: [3, 2, 2, 2] +10 0 2 1 +After: [3, 1, 2, 2] + +Before: [0, 1, 0, 0] +15 1 3 0 +After: [1, 1, 0, 0] + +Before: [0, 0, 2, 1] +5 0 0 2 +After: [0, 0, 1, 1] + +Before: [3, 1, 3, 2] +1 1 3 0 +After: [0, 1, 3, 2] + +Before: [2, 1, 3, 2] +4 3 2 0 +After: [2, 1, 3, 2] + +Before: [0, 2, 3, 3] +4 1 2 0 +After: [2, 2, 3, 3] + +Before: [0, 1, 0, 0] +12 1 0 3 +After: [0, 1, 0, 1] + +Before: [2, 1, 3, 3] +11 0 2 2 +After: [2, 1, 1, 3] + +Before: [0, 3, 2, 1] +3 3 2 2 +After: [0, 3, 1, 1] + +Before: [0, 1, 3, 3] +12 1 0 0 +After: [1, 1, 3, 3] + +Before: [0, 3, 0, 1] +7 0 0 1 +After: [0, 0, 0, 1] + +Before: [1, 0, 2, 1] +14 3 3 3 +After: [1, 0, 2, 0] + +Before: [2, 3, 3, 2] +4 0 2 1 +After: [2, 2, 3, 2] + +Before: [1, 2, 2, 2] +13 2 2 0 +After: [2, 2, 2, 2] + +Before: [3, 0, 3, 2] +4 3 2 3 +After: [3, 0, 3, 2] + +Before: [0, 1, 3, 2] +1 1 3 2 +After: [0, 1, 0, 2] + +Before: [1, 0, 1, 1] +2 3 1 0 +After: [1, 0, 1, 1] + +Before: [0, 1, 1, 3] +6 1 3 3 +After: [0, 1, 1, 0] + +Before: [0, 2, 3, 1] +5 2 3 0 +After: [0, 2, 3, 1] + +Before: [2, 3, 3, 1] +5 2 3 0 +After: [0, 3, 3, 1] + +Before: [2, 1, 2, 2] +13 2 2 0 +After: [2, 1, 2, 2] + +Before: [1, 2, 3, 1] +5 2 3 3 +After: [1, 2, 3, 0] + +Before: [1, 2, 0, 2] +14 3 3 0 +After: [0, 2, 0, 2] + +Before: [2, 1, 0, 2] +14 3 3 2 +After: [2, 1, 0, 2] + +Before: [2, 2, 3, 1] +11 0 2 3 +After: [2, 2, 3, 1] + +Before: [2, 3, 3, 2] +4 3 2 2 +After: [2, 3, 2, 2] + +Before: [2, 2, 1, 1] +14 3 3 3 +After: [2, 2, 1, 0] + +Before: [2, 1, 3, 2] +14 3 3 3 +After: [2, 1, 3, 0] + +Before: [2, 1, 0, 3] +10 0 1 3 +After: [2, 1, 0, 1] + +Before: [0, 1, 2, 1] +0 1 2 0 +After: [0, 1, 2, 1] + +Before: [3, 2, 0, 0] +11 2 0 2 +After: [3, 2, 1, 0] + +Before: [3, 1, 0, 1] +11 2 0 2 +After: [3, 1, 1, 1] + +Before: [1, 1, 3, 0] +15 1 3 3 +After: [1, 1, 3, 1] + +Before: [0, 0, 3, 2] +14 3 3 0 +After: [0, 0, 3, 2] + +Before: [2, 1, 3, 1] +10 0 1 3 +After: [2, 1, 3, 1] + +Before: [1, 1, 2, 3] +0 1 2 2 +After: [1, 1, 0, 3] + +Before: [0, 2, 2, 3] +13 3 3 2 +After: [0, 2, 3, 3] + +Before: [1, 1, 3, 3] +5 3 3 3 +After: [1, 1, 3, 1] + +Before: [1, 2, 3, 3] +4 1 2 1 +After: [1, 2, 3, 3] + +Before: [1, 1, 2, 3] +5 2 2 3 +After: [1, 1, 2, 1] + +Before: [2, 0, 3, 3] +11 0 2 2 +After: [2, 0, 1, 3] + +Before: [1, 0, 2, 3] +13 2 2 1 +After: [1, 2, 2, 3] + +Before: [0, 1, 2, 1] +7 0 0 1 +After: [0, 0, 2, 1] + +Before: [2, 0, 2, 3] +13 2 2 2 +After: [2, 0, 2, 3] + +Before: [3, 0, 1, 0] +2 2 1 0 +After: [1, 0, 1, 0] + +Before: [3, 3, 3, 3] +5 3 2 1 +After: [3, 1, 3, 3] + +Before: [0, 1, 2, 3] +12 1 0 2 +After: [0, 1, 1, 3] + +Before: [2, 0, 3, 1] +11 0 2 3 +After: [2, 0, 3, 1] + +Before: [2, 1, 2, 1] +3 3 2 1 +After: [2, 1, 2, 1] + +Before: [2, 1, 3, 0] +11 0 2 2 +After: [2, 1, 1, 0] + +Before: [0, 1, 2, 2] +1 1 3 0 +After: [0, 1, 2, 2] + +Before: [2, 0, 3, 3] +4 0 2 1 +After: [2, 2, 3, 3] + +Before: [3, 0, 1, 1] +2 3 1 3 +After: [3, 0, 1, 1] + +Before: [2, 2, 1, 2] +8 0 2 1 +After: [2, 1, 1, 2] + +Before: [3, 2, 3, 3] +4 1 2 0 +After: [2, 2, 3, 3] + +Before: [1, 1, 2, 3] +0 1 2 0 +After: [0, 1, 2, 3] + +Before: [2, 1, 1, 1] +8 0 2 1 +After: [2, 1, 1, 1] + +Before: [1, 2, 2, 3] +5 2 1 2 +After: [1, 2, 1, 3] + +Before: [2, 3, 1, 2] +8 0 2 3 +After: [2, 3, 1, 1] + +Before: [0, 1, 2, 1] +12 1 0 1 +After: [0, 1, 2, 1] + +Before: [0, 1, 1, 3] +12 1 0 1 +After: [0, 1, 1, 3] + +Before: [2, 1, 3, 0] +15 1 3 0 +After: [1, 1, 3, 0] + +Before: [0, 1, 2, 2] +1 1 3 3 +After: [0, 1, 2, 0] + +Before: [3, 2, 2, 2] +8 0 3 1 +After: [3, 1, 2, 2] + +Before: [1, 2, 0, 3] +13 3 3 2 +After: [1, 2, 3, 3] + +Before: [0, 1, 0, 1] +12 1 0 3 +After: [0, 1, 0, 1] + +Before: [3, 2, 2, 3] +6 1 3 1 +After: [3, 0, 2, 3] + +Before: [1, 2, 3, 2] +4 3 2 2 +After: [1, 2, 2, 2] + +Before: [3, 2, 2, 3] +10 0 2 2 +After: [3, 2, 1, 3] + +Before: [2, 1, 2, 2] +0 1 2 2 +After: [2, 1, 0, 2] + +Before: [2, 3, 2, 3] +5 3 3 2 +After: [2, 3, 1, 3] + +Before: [1, 1, 2, 3] +6 2 3 3 +After: [1, 1, 2, 0] + +Before: [2, 1, 1, 3] +6 2 3 2 +After: [2, 1, 0, 3] + +Before: [3, 2, 3, 2] +4 1 2 1 +After: [3, 2, 3, 2] + +Before: [1, 0, 2, 2] +9 0 2 1 +After: [1, 0, 2, 2] + +Before: [0, 3, 3, 2] +5 0 0 1 +After: [0, 1, 3, 2] + +Before: [1, 1, 3, 3] +5 3 2 3 +After: [1, 1, 3, 1] + +Before: [3, 1, 0, 2] +1 1 3 0 +After: [0, 1, 0, 2] + +Before: [0, 1, 1, 0] +12 1 0 0 +After: [1, 1, 1, 0] + +Before: [3, 0, 3, 2] +8 0 3 2 +After: [3, 0, 1, 2] + +Before: [1, 0, 1, 1] +14 3 3 1 +After: [1, 0, 1, 1] + +Before: [3, 1, 1, 0] +15 1 3 3 +After: [3, 1, 1, 1] + +Before: [3, 0, 1, 0] +2 2 1 2 +After: [3, 0, 1, 0] + +Before: [3, 1, 0, 2] +8 0 3 2 +After: [3, 1, 1, 2] + +Before: [0, 1, 3, 0] +12 1 0 0 +After: [1, 1, 3, 0] + +Before: [2, 3, 3, 3] +4 0 2 3 +After: [2, 3, 3, 2] + +Before: [3, 2, 2, 2] +8 0 3 0 +After: [1, 2, 2, 2] + +Before: [3, 1, 3, 0] +15 1 3 0 +After: [1, 1, 3, 0] + +Before: [2, 1, 2, 2] +1 1 3 3 +After: [2, 1, 2, 0] + +Before: [0, 1, 2, 2] +1 1 3 2 +After: [0, 1, 0, 2] + +Before: [2, 2, 1, 3] +8 0 2 0 +After: [1, 2, 1, 3] + +Before: [1, 1, 2, 2] +0 1 2 0 +After: [0, 1, 2, 2] + +Before: [0, 1, 3, 2] +4 3 2 2 +After: [0, 1, 2, 2] + +Before: [2, 1, 2, 3] +6 1 3 0 +After: [0, 1, 2, 3] + +Before: [2, 1, 2, 3] +10 0 1 2 +After: [2, 1, 1, 3] + +Before: [1, 1, 2, 2] +9 0 2 2 +After: [1, 1, 0, 2] + +Before: [3, 1, 1, 3] +6 2 3 2 +After: [3, 1, 0, 3] + +Before: [1, 1, 2, 0] +9 0 2 0 +After: [0, 1, 2, 0] + +Before: [3, 1, 3, 1] +14 3 3 1 +After: [3, 0, 3, 1] + +Before: [1, 1, 0, 0] +15 1 3 3 +After: [1, 1, 0, 1] + +Before: [0, 0, 2, 1] +3 3 2 2 +After: [0, 0, 1, 1] + +Before: [2, 3, 3, 2] +4 0 2 3 +After: [2, 3, 3, 2] + +Before: [2, 2, 1, 3] +6 2 3 1 +After: [2, 0, 1, 3] + +Before: [2, 1, 2, 1] +3 3 2 2 +After: [2, 1, 1, 1] + +Before: [2, 2, 3, 2] +14 3 3 2 +After: [2, 2, 0, 2] + +Before: [1, 1, 2, 2] +0 1 2 2 +After: [1, 1, 0, 2] + +Before: [2, 1, 0, 3] +6 1 3 2 +After: [2, 1, 0, 3] + +Before: [3, 2, 2, 0] +13 2 2 3 +After: [3, 2, 2, 2] + +Before: [0, 1, 1, 0] +12 1 0 2 +After: [0, 1, 1, 0] + +Before: [2, 1, 0, 2] +10 0 1 2 +After: [2, 1, 1, 2] + +Before: [1, 0, 0, 2] +2 0 1 1 +After: [1, 1, 0, 2] + +Before: [0, 1, 2, 1] +3 3 2 0 +After: [1, 1, 2, 1] + +Before: [0, 1, 3, 0] +12 1 0 3 +After: [0, 1, 3, 1] + +Before: [0, 1, 2, 3] +13 3 3 1 +After: [0, 3, 2, 3] + +Before: [0, 1, 2, 1] +12 1 0 0 +After: [1, 1, 2, 1] + +Before: [0, 1, 1, 1] +14 2 3 0 +After: [0, 1, 1, 1] + +Before: [0, 2, 2, 3] +6 2 3 1 +After: [0, 0, 2, 3] + +Before: [3, 1, 0, 0] +15 1 3 2 +After: [3, 1, 1, 0] + +Before: [1, 0, 3, 1] +2 0 1 0 +After: [1, 0, 3, 1] + +Before: [2, 1, 1, 2] +8 0 2 0 +After: [1, 1, 1, 2] + +Before: [2, 1, 2, 2] +10 0 1 2 +After: [2, 1, 1, 2] + +Before: [2, 2, 2, 1] +3 3 2 1 +After: [2, 1, 2, 1] + +Before: [2, 1, 3, 2] +11 0 2 1 +After: [2, 1, 3, 2] + +Before: [3, 2, 3, 2] +8 0 3 3 +After: [3, 2, 3, 1] + +Before: [1, 2, 0, 3] +6 1 3 3 +After: [1, 2, 0, 0] + +Before: [2, 1, 0, 2] +1 1 3 1 +After: [2, 0, 0, 2] + +Before: [3, 3, 1, 3] +13 3 3 3 +After: [3, 3, 1, 3] + +Before: [1, 2, 2, 1] +3 3 2 3 +After: [1, 2, 2, 1] + +Before: [2, 1, 3, 2] +1 1 3 1 +After: [2, 0, 3, 2] + +Before: [2, 1, 3, 2] +10 0 1 0 +After: [1, 1, 3, 2] + +Before: [1, 0, 2, 1] +3 3 2 2 +After: [1, 0, 1, 1] + +Before: [1, 1, 3, 2] +1 1 3 2 +After: [1, 1, 0, 2] + +Before: [2, 2, 3, 0] +11 0 2 1 +After: [2, 1, 3, 0] + +Before: [3, 0, 0, 2] +14 3 3 1 +After: [3, 0, 0, 2] + +Before: [3, 1, 3, 0] +15 1 3 2 +After: [3, 1, 1, 0] + +Before: [2, 1, 2, 1] +3 3 2 0 +After: [1, 1, 2, 1] + +Before: [0, 1, 3, 2] +12 1 0 2 +After: [0, 1, 1, 2] + +Before: [3, 3, 0, 3] +11 2 0 3 +After: [3, 3, 0, 1] + +Before: [2, 0, 3, 1] +2 3 1 2 +After: [2, 0, 1, 1] + +Before: [1, 3, 0, 2] +14 3 3 0 +After: [0, 3, 0, 2] + +Before: [3, 0, 0, 2] +8 0 3 3 +After: [3, 0, 0, 1] + +Before: [3, 0, 2, 1] +3 3 2 2 +After: [3, 0, 1, 1] + +Before: [3, 1, 0, 3] +11 2 0 2 +After: [3, 1, 1, 3] + +Before: [0, 1, 0, 3] +12 1 0 1 +After: [0, 1, 0, 3] + +Before: [2, 2, 2, 1] +3 3 2 0 +After: [1, 2, 2, 1] + +Before: [1, 0, 3, 1] +2 0 1 3 +After: [1, 0, 3, 1] + +Before: [1, 1, 2, 3] +9 0 2 0 +After: [0, 1, 2, 3] + +Before: [1, 3, 2, 3] +6 2 3 2 +After: [1, 3, 0, 3] + +Before: [0, 1, 3, 0] +7 0 0 3 +After: [0, 1, 3, 0] + +Before: [1, 1, 2, 0] +15 1 3 1 +After: [1, 1, 2, 0] + +Before: [3, 1, 3, 2] +1 1 3 1 +After: [3, 0, 3, 2] + +Before: [1, 3, 2, 1] +9 0 2 3 +After: [1, 3, 2, 0] + +Before: [0, 0, 2, 1] +7 0 0 1 +After: [0, 0, 2, 1] + +Before: [2, 1, 1, 0] +15 1 3 2 +After: [2, 1, 1, 0] + +Before: [2, 3, 2, 0] +13 2 2 0 +After: [2, 3, 2, 0] + +Before: [1, 1, 2, 1] +9 0 2 1 +After: [1, 0, 2, 1] + +Before: [2, 1, 2, 0] +15 1 3 1 +After: [2, 1, 2, 0] + +Before: [1, 0, 2, 1] +9 0 2 2 +After: [1, 0, 0, 1] + +Before: [1, 1, 0, 2] +1 1 3 2 +After: [1, 1, 0, 2] + +Before: [3, 0, 0, 1] +2 3 1 0 +After: [1, 0, 0, 1] + +Before: [1, 0, 0, 3] +2 0 1 3 +After: [1, 0, 0, 1] + +Before: [3, 1, 2, 0] +0 1 2 1 +After: [3, 0, 2, 0] + +Before: [1, 1, 2, 0] +0 1 2 1 +After: [1, 0, 2, 0] + +Before: [2, 1, 2, 0] +0 1 2 3 +After: [2, 1, 2, 0] + +Before: [1, 0, 3, 1] +14 3 3 0 +After: [0, 0, 3, 1] + +Before: [0, 1, 3, 2] +12 1 0 0 +After: [1, 1, 3, 2] + +Before: [1, 3, 2, 3] +9 0 2 2 +After: [1, 3, 0, 3] + +Before: [0, 2, 2, 1] +3 3 2 3 +After: [0, 2, 2, 1] + +Before: [0, 2, 2, 0] +7 0 0 3 +After: [0, 2, 2, 0] + +Before: [2, 0, 0, 1] +14 3 3 0 +After: [0, 0, 0, 1] + +Before: [2, 3, 3, 3] +13 3 3 3 +After: [2, 3, 3, 3] + +Before: [3, 2, 3, 3] +4 1 2 1 +After: [3, 2, 3, 3] + +Before: [3, 3, 2, 2] +8 0 3 0 +After: [1, 3, 2, 2] + +Before: [2, 2, 3, 0] +4 1 2 2 +After: [2, 2, 2, 0] + +Before: [0, 0, 1, 3] +7 0 0 3 +After: [0, 0, 1, 0] + +Before: [2, 0, 2, 1] +13 2 2 2 +After: [2, 0, 2, 1] + +Before: [2, 2, 3, 1] +5 2 3 1 +After: [2, 0, 3, 1] + +Before: [2, 0, 1, 1] +2 3 1 0 +After: [1, 0, 1, 1] + +Before: [0, 0, 2, 3] +6 2 3 0 +After: [0, 0, 2, 3] + +Before: [2, 1, 3, 3] +13 3 3 2 +After: [2, 1, 3, 3] + +Before: [1, 0, 3, 0] +2 0 1 2 +After: [1, 0, 1, 0] + +Before: [0, 1, 3, 2] +12 1 0 3 +After: [0, 1, 3, 1] + +Before: [0, 2, 3, 1] +7 0 0 1 +After: [0, 0, 3, 1] + +Before: [1, 0, 1, 3] +13 3 3 3 +After: [1, 0, 1, 3] + +Before: [3, 3, 0, 2] +11 2 0 3 +After: [3, 3, 0, 1] + +Before: [3, 0, 2, 1] +3 3 2 1 +After: [3, 1, 2, 1] + +Before: [1, 0, 2, 0] +9 0 2 0 +After: [0, 0, 2, 0] + +Before: [0, 3, 2, 2] +13 2 2 0 +After: [2, 3, 2, 2] + +Before: [0, 0, 0, 1] +2 3 1 3 +After: [0, 0, 0, 1] + +Before: [2, 1, 2, 1] +0 1 2 3 +After: [2, 1, 2, 0] + +Before: [2, 3, 1, 3] +8 0 2 1 +After: [2, 1, 1, 3] + +Before: [3, 3, 0, 0] +11 2 0 1 +After: [3, 1, 0, 0] + +Before: [1, 3, 3, 3] +13 3 3 0 +After: [3, 3, 3, 3] + +Before: [0, 1, 0, 1] +12 1 0 0 +After: [1, 1, 0, 1] + +Before: [3, 2, 0, 1] +14 3 3 0 +After: [0, 2, 0, 1] + +Before: [0, 1, 0, 0] +7 0 0 0 +After: [0, 1, 0, 0] + +Before: [2, 1, 2, 1] +0 1 2 1 +After: [2, 0, 2, 1] + +Before: [3, 2, 1, 1] +14 3 3 3 +After: [3, 2, 1, 0] + +Before: [3, 1, 0, 0] +11 2 0 1 +After: [3, 1, 0, 0] + +Before: [2, 1, 3, 2] +1 1 3 2 +After: [2, 1, 0, 2] + +Before: [0, 2, 2, 3] +6 2 3 0 +After: [0, 2, 2, 3] + +Before: [1, 0, 2, 0] +9 0 2 2 +After: [1, 0, 0, 0] + +Before: [0, 2, 1, 2] +7 0 0 2 +After: [0, 2, 0, 2] + +Before: [0, 0, 1, 3] +6 2 3 3 +After: [0, 0, 1, 0] + +Before: [3, 2, 3, 1] +4 1 2 2 +After: [3, 2, 2, 1] + +Before: [1, 0, 2, 1] +3 3 2 1 +After: [1, 1, 2, 1] + +Before: [2, 3, 2, 1] +3 3 2 3 +After: [2, 3, 2, 1] + +Before: [3, 1, 2, 0] +15 1 3 0 +After: [1, 1, 2, 0] + +Before: [0, 1, 2, 0] +12 1 0 0 +After: [1, 1, 2, 0] + +Before: [3, 3, 0, 0] +11 2 0 3 +After: [3, 3, 0, 1] + +Before: [2, 0, 1, 2] +8 0 2 3 +After: [2, 0, 1, 1] + +Before: [3, 1, 3, 3] +5 3 2 2 +After: [3, 1, 1, 3] + +Before: [1, 0, 2, 2] +14 3 3 1 +After: [1, 0, 2, 2] + +Before: [2, 1, 2, 3] +0 1 2 3 +After: [2, 1, 2, 0] + +Before: [3, 0, 2, 1] +10 0 2 1 +After: [3, 1, 2, 1] + +Before: [2, 1, 0, 2] +1 1 3 2 +After: [2, 1, 0, 2] + +Before: [0, 1, 1, 2] +12 1 0 3 +After: [0, 1, 1, 1] + +Before: [3, 1, 0, 2] +1 1 3 3 +After: [3, 1, 0, 0] + +Before: [0, 2, 3, 0] +4 1 2 2 +After: [0, 2, 2, 0] + +Before: [3, 1, 2, 3] +0 1 2 1 +After: [3, 0, 2, 3] + +Before: [0, 0, 2, 1] +3 3 2 3 +After: [0, 0, 2, 1] + +Before: [0, 1, 2, 1] +0 1 2 3 +After: [0, 1, 2, 0] + +Before: [2, 0, 1, 2] +14 3 3 1 +After: [2, 0, 1, 2] + +Before: [0, 0, 2, 0] +7 0 0 3 +After: [0, 0, 2, 0] + +Before: [3, 1, 3, 2] +1 1 3 2 +After: [3, 1, 0, 2] + +Before: [2, 1, 0, 0] +15 1 3 1 +After: [2, 1, 0, 0] + +Before: [2, 2, 2, 2] +13 2 2 0 +After: [2, 2, 2, 2] + +Before: [0, 2, 3, 3] +6 1 3 1 +After: [0, 0, 3, 3] + +Before: [3, 3, 2, 1] +3 3 2 3 +After: [3, 3, 2, 1] + +Before: [1, 0, 2, 2] +9 0 2 0 +After: [0, 0, 2, 2] + +Before: [0, 1, 2, 3] +0 1 2 0 +After: [0, 1, 2, 3] + +Before: [0, 1, 2, 0] +0 1 2 0 +After: [0, 1, 2, 0] + +Before: [0, 1, 2, 1] +3 3 2 3 +After: [0, 1, 2, 1] + +Before: [0, 1, 0, 3] +7 0 0 3 +After: [0, 1, 0, 0] + +Before: [2, 0, 1, 1] +8 0 2 2 +After: [2, 0, 1, 1] + +Before: [1, 2, 0, 3] +6 1 3 1 +After: [1, 0, 0, 3] + +Before: [1, 1, 2, 2] +0 1 2 1 +After: [1, 0, 2, 2] + +Before: [2, 3, 1, 2] +14 3 3 1 +After: [2, 0, 1, 2] + +Before: [3, 2, 0, 3] +11 2 0 1 +After: [3, 1, 0, 3] + +Before: [1, 0, 2, 3] +9 0 2 0 +After: [0, 0, 2, 3] + +Before: [3, 2, 2, 0] +10 0 2 0 +After: [1, 2, 2, 0] + +Before: [3, 3, 3, 2] +8 0 3 3 +After: [3, 3, 3, 1] + +Before: [0, 1, 3, 2] +1 1 3 0 +After: [0, 1, 3, 2] + +Before: [0, 0, 0, 1] +14 3 3 3 +After: [0, 0, 0, 0] + +Before: [1, 0, 2, 3] +2 0 1 0 +After: [1, 0, 2, 3] + +Before: [2, 1, 3, 1] +14 3 3 3 +After: [2, 1, 3, 0] + +Before: [1, 3, 1, 2] +14 3 3 2 +After: [1, 3, 0, 2] + +Before: [2, 0, 2, 1] +3 3 2 3 +After: [2, 0, 2, 1] + +Before: [0, 1, 2, 3] +6 1 3 0 +After: [0, 1, 2, 3] + +Before: [2, 1, 3, 1] +11 0 2 2 +After: [2, 1, 1, 1] + +Before: [0, 1, 1, 0] +15 1 3 2 +After: [0, 1, 1, 0] + +Before: [1, 1, 2, 1] +9 0 2 2 +After: [1, 1, 0, 1] + +Before: [3, 1, 1, 3] +6 1 3 1 +After: [3, 0, 1, 3] + +Before: [0, 1, 3, 3] +7 0 0 3 +After: [0, 1, 3, 0] + +Before: [1, 0, 2, 1] +2 0 1 1 +After: [1, 1, 2, 1] + +Before: [2, 0, 1, 1] +8 0 2 0 +After: [1, 0, 1, 1] + +Before: [0, 2, 2, 2] +7 0 0 3 +After: [0, 2, 2, 0] + +Before: [3, 2, 3, 3] +6 1 3 3 +After: [3, 2, 3, 0] + +Before: [3, 3, 3, 2] +4 3 2 3 +After: [3, 3, 3, 2] + +Before: [3, 1, 1, 1] +14 3 3 3 +After: [3, 1, 1, 0] + +Before: [2, 0, 3, 1] +4 0 2 3 +After: [2, 0, 3, 2] + +Before: [2, 1, 2, 2] +1 1 3 2 +After: [2, 1, 0, 2] + +Before: [3, 1, 0, 1] +11 2 0 1 +After: [3, 1, 0, 1] + +Before: [2, 3, 2, 1] +3 3 2 2 +After: [2, 3, 1, 1] + +Before: [0, 0, 3, 1] +7 0 0 1 +After: [0, 0, 3, 1] + +Before: [2, 3, 1, 0] +8 0 2 1 +After: [2, 1, 1, 0] + +Before: [2, 0, 0, 1] +14 3 3 1 +After: [2, 0, 0, 1] + +Before: [0, 1, 3, 1] +12 1 0 2 +After: [0, 1, 1, 1] + +Before: [2, 0, 2, 1] +3 3 2 0 +After: [1, 0, 2, 1] + +Before: [2, 3, 3, 1] +11 0 2 0 +After: [1, 3, 3, 1] + +Before: [0, 0, 3, 1] +2 3 1 3 +After: [0, 0, 3, 1] + +Before: [1, 0, 1, 3] +2 0 1 3 +After: [1, 0, 1, 1] + +Before: [0, 2, 2, 2] +14 3 3 2 +After: [0, 2, 0, 2] + +Before: [3, 3, 0, 1] +11 2 0 1 +After: [3, 1, 0, 1] + +Before: [3, 1, 3, 3] +6 1 3 3 +After: [3, 1, 3, 0] + +Before: [1, 2, 3, 2] +4 1 2 3 +After: [1, 2, 3, 2] + +Before: [0, 1, 0, 3] +6 1 3 0 +After: [0, 1, 0, 3] + +Before: [2, 0, 2, 1] +2 3 1 1 +After: [2, 1, 2, 1] + +Before: [0, 2, 0, 3] +13 3 3 0 +After: [3, 2, 0, 3] + +Before: [1, 1, 1, 2] +1 1 3 3 +After: [1, 1, 1, 0] + +Before: [1, 3, 3, 3] +13 3 3 2 +After: [1, 3, 3, 3] + +Before: [0, 1, 3, 0] +12 1 0 2 +After: [0, 1, 1, 0] + +Before: [3, 1, 2, 0] +15 1 3 1 +After: [3, 1, 2, 0] + +Before: [2, 2, 2, 1] +3 3 2 2 +After: [2, 2, 1, 1] + +Before: [2, 2, 1, 2] +8 0 2 0 +After: [1, 2, 1, 2] + +Before: [3, 1, 2, 3] +0 1 2 2 +After: [3, 1, 0, 3] + +Before: [0, 1, 1, 2] +14 3 3 1 +After: [0, 0, 1, 2] + +Before: [0, 1, 3, 3] +5 3 2 0 +After: [1, 1, 3, 3] + +Before: [3, 1, 2, 2] +8 0 3 0 +After: [1, 1, 2, 2] + +Before: [2, 1, 1, 3] +13 3 3 1 +After: [2, 3, 1, 3] + +Before: [0, 2, 1, 2] +7 0 0 0 +After: [0, 2, 1, 2] + +Before: [0, 1, 1, 0] +15 1 3 0 +After: [1, 1, 1, 0] + +Before: [3, 1, 2, 2] +1 1 3 3 +After: [3, 1, 2, 0] + +Before: [0, 0, 2, 3] +13 3 3 1 +After: [0, 3, 2, 3] + +Before: [1, 0, 0, 3] +5 3 3 3 +After: [1, 0, 0, 1] + +Before: [2, 0, 1, 1] +2 2 1 3 +After: [2, 0, 1, 1] + +Before: [3, 3, 1, 2] +14 3 3 2 +After: [3, 3, 0, 2] + +Before: [0, 1, 0, 2] +12 1 0 3 +After: [0, 1, 0, 1] + +Before: [1, 2, 3, 1] +4 1 2 2 +After: [1, 2, 2, 1] + +Before: [3, 0, 3, 2] +8 0 3 1 +After: [3, 1, 3, 2] + +Before: [3, 1, 1, 1] +14 2 3 2 +After: [3, 1, 0, 1] + +Before: [0, 2, 2, 0] +13 2 2 0 +After: [2, 2, 2, 0] + +Before: [0, 1, 3, 2] +12 1 0 1 +After: [0, 1, 3, 2] + +Before: [3, 1, 2, 1] +10 0 2 3 +After: [3, 1, 2, 1] + +Before: [3, 0, 0, 2] +11 2 0 3 +After: [3, 0, 0, 1] + +Before: [1, 2, 2, 2] +9 0 2 2 +After: [1, 2, 0, 2] + +Before: [2, 0, 0, 1] +2 3 1 2 +After: [2, 0, 1, 1] + +Before: [1, 0, 0, 1] +14 3 3 1 +After: [1, 0, 0, 1] + +Before: [3, 3, 1, 2] +8 0 3 2 +After: [3, 3, 1, 2] + +Before: [0, 1, 1, 0] +12 1 0 1 +After: [0, 1, 1, 0] + +Before: [0, 2, 1, 1] +7 0 0 1 +After: [0, 0, 1, 1] + +Before: [0, 1, 2, 0] +12 1 0 3 +After: [0, 1, 2, 1] + +Before: [2, 1, 2, 1] +13 2 2 1 +After: [2, 2, 2, 1] + +Before: [1, 1, 1, 3] +6 2 3 3 +After: [1, 1, 1, 0] + +Before: [1, 1, 2, 0] +0 1 2 0 +After: [0, 1, 2, 0] + +Before: [2, 1, 1, 2] +10 0 1 0 +After: [1, 1, 1, 2] + +Before: [3, 2, 2, 1] +3 3 2 3 +After: [3, 2, 2, 1] + +Before: [3, 0, 3, 2] +4 3 2 1 +After: [3, 2, 3, 2] + +Before: [1, 0, 0, 1] +2 3 1 3 +After: [1, 0, 0, 1] + +Before: [2, 3, 2, 2] +13 2 2 0 +After: [2, 3, 2, 2] + +Before: [2, 1, 0, 0] +10 0 1 2 +After: [2, 1, 1, 0] + +Before: [2, 0, 3, 2] +4 0 2 3 +After: [2, 0, 3, 2] + +Before: [0, 2, 3, 2] +7 0 0 1 +After: [0, 0, 3, 2] + +Before: [0, 3, 2, 3] +7 0 0 2 +After: [0, 3, 0, 3] + +Before: [3, 2, 2, 0] +10 0 2 2 +After: [3, 2, 1, 0] + +Before: [3, 0, 2, 1] +5 2 2 1 +After: [3, 1, 2, 1] + +Before: [2, 0, 2, 1] +3 3 2 2 +After: [2, 0, 1, 1] + +Before: [1, 2, 2, 3] +9 0 2 2 +After: [1, 2, 0, 3] + +Before: [0, 3, 2, 1] +3 3 2 0 +After: [1, 3, 2, 1] + +Before: [0, 3, 1, 3] +13 3 3 0 +After: [3, 3, 1, 3] + +Before: [0, 1, 2, 3] +0 1 2 2 +After: [0, 1, 0, 3] + +Before: [2, 0, 1, 3] +2 2 1 0 +After: [1, 0, 1, 3] + +Before: [1, 1, 2, 2] +1 1 3 0 +After: [0, 1, 2, 2] + +Before: [2, 1, 2, 3] +10 0 1 3 +After: [2, 1, 2, 1] + +Before: [0, 1, 2, 3] +6 1 3 2 +After: [0, 1, 0, 3] + +Before: [3, 1, 3, 2] +4 3 2 3 +After: [3, 1, 3, 2] + +Before: [3, 1, 0, 2] +11 2 0 3 +After: [3, 1, 0, 1] + +Before: [2, 0, 3, 1] +11 0 2 2 +After: [2, 0, 1, 1] + +Before: [2, 3, 3, 3] +4 0 2 2 +After: [2, 3, 2, 3] + +Before: [0, 1, 2, 2] +1 1 3 1 +After: [0, 0, 2, 2] + +Before: [0, 1, 1, 2] +1 1 3 2 +After: [0, 1, 0, 2] + +Before: [1, 3, 2, 0] +9 0 2 2 +After: [1, 3, 0, 0] + +Before: [3, 3, 1, 3] +13 3 3 1 +After: [3, 3, 1, 3] + +Before: [1, 1, 3, 3] +5 3 3 2 +After: [1, 1, 1, 3] + +Before: [0, 0, 0, 2] +7 0 0 0 +After: [0, 0, 0, 2] + +Before: [2, 1, 1, 2] +10 0 1 1 +After: [2, 1, 1, 2] + +Before: [3, 0, 0, 1] +2 3 1 1 +After: [3, 1, 0, 1] + +Before: [0, 1, 2, 2] +0 1 2 1 +After: [0, 0, 2, 2] + +Before: [1, 1, 2, 2] +0 1 2 3 +After: [1, 1, 2, 0] + +Before: [0, 1, 1, 3] +12 1 0 0 +After: [1, 1, 1, 3] + +Before: [1, 2, 2, 1] +3 3 2 0 +After: [1, 2, 2, 1] + +Before: [2, 1, 2, 0] +10 0 1 2 +After: [2, 1, 1, 0] + +Before: [0, 1, 2, 3] +0 1 2 3 +After: [0, 1, 2, 0] + +Before: [1, 2, 1, 3] +6 2 3 0 +After: [0, 2, 1, 3] + +Before: [3, 1, 2, 2] +1 1 3 1 +After: [3, 0, 2, 2] + +Before: [1, 2, 2, 2] +5 2 1 0 +After: [1, 2, 2, 2] + +Before: [2, 1, 2, 1] +3 3 2 3 +After: [2, 1, 2, 1] + +Before: [3, 1, 0, 0] +15 1 3 3 +After: [3, 1, 0, 1] + +Before: [3, 3, 2, 0] +10 0 2 3 +After: [3, 3, 2, 1] + +Before: [1, 0, 3, 1] +2 3 1 0 +After: [1, 0, 3, 1] + +Before: [1, 2, 1, 3] +6 1 3 3 +After: [1, 2, 1, 0] + +Before: [3, 1, 0, 2] +11 2 0 1 +After: [3, 1, 0, 2] + +Before: [0, 1, 0, 2] +1 1 3 2 +After: [0, 1, 0, 2] + +Before: [1, 0, 1, 2] +14 3 3 2 +After: [1, 0, 0, 2] + +Before: [2, 1, 1, 1] +10 0 1 0 +After: [1, 1, 1, 1] + +Before: [1, 3, 1, 3] +6 2 3 0 +After: [0, 3, 1, 3] + +Before: [1, 1, 2, 1] +9 0 2 0 +After: [0, 1, 2, 1] + +Before: [1, 2, 3, 3] +6 1 3 3 +After: [1, 2, 3, 0] + +Before: [3, 1, 2, 2] +0 1 2 3 +After: [3, 1, 2, 0] + +Before: [1, 0, 2, 0] +2 0 1 3 +After: [1, 0, 2, 1] + +Before: [1, 1, 2, 2] +9 0 2 3 +After: [1, 1, 2, 0] + +Before: [2, 0, 2, 3] +6 2 3 0 +After: [0, 0, 2, 3] + +Before: [1, 3, 1, 2] +14 3 3 1 +After: [1, 0, 1, 2] + +Before: [0, 2, 1, 3] +6 1 3 1 +After: [0, 0, 1, 3] + +Before: [1, 1, 1, 2] +1 1 3 1 +After: [1, 0, 1, 2] + +Before: [3, 1, 2, 1] +0 1 2 1 +After: [3, 0, 2, 1] + +Before: [2, 1, 1, 3] +6 2 3 3 +After: [2, 1, 1, 0] + +Before: [1, 1, 2, 3] +0 1 2 1 +After: [1, 0, 2, 3] + +Before: [0, 1, 3, 1] +12 1 0 1 +After: [0, 1, 3, 1] + +Before: [3, 3, 2, 2] +14 3 3 1 +After: [3, 0, 2, 2] + +Before: [0, 2, 3, 0] +7 0 0 0 +After: [0, 2, 3, 0] + +Before: [0, 1, 0, 3] +6 1 3 3 +After: [0, 1, 0, 0] + +Before: [1, 1, 2, 3] +9 0 2 3 +After: [1, 1, 2, 0] + +Before: [1, 1, 2, 0] +9 0 2 2 +After: [1, 1, 0, 0] + +Before: [1, 0, 3, 1] +2 3 1 2 +After: [1, 0, 1, 1] + +Before: [2, 0, 3, 2] +4 0 2 1 +After: [2, 2, 3, 2] + +Before: [3, 1, 3, 1] +5 2 3 3 +After: [3, 1, 3, 0] + +Before: [2, 0, 1, 1] +14 2 3 1 +After: [2, 0, 1, 1] + +Before: [2, 0, 3, 3] +11 0 2 0 +After: [1, 0, 3, 3] + +Before: [3, 1, 2, 1] +0 1 2 0 +After: [0, 1, 2, 1] + +Before: [3, 3, 1, 3] +13 3 3 2 +After: [3, 3, 3, 3] + +Before: [0, 1, 0, 3] +12 1 0 0 +After: [1, 1, 0, 3] + +Before: [2, 1, 1, 0] +8 0 2 1 +After: [2, 1, 1, 0] + +Before: [0, 1, 3, 2] +1 1 3 3 +After: [0, 1, 3, 0] + +Before: [3, 2, 3, 2] +8 0 3 0 +After: [1, 2, 3, 2] + +Before: [2, 0, 3, 2] +11 0 2 1 +After: [2, 1, 3, 2] + +Before: [0, 1, 1, 1] +12 1 0 1 +After: [0, 1, 1, 1] + +Before: [2, 0, 3, 1] +4 0 2 1 +After: [2, 2, 3, 1] + +Before: [2, 1, 2, 1] +0 1 2 0 +After: [0, 1, 2, 1] + +Before: [3, 2, 0, 1] +11 2 0 2 +After: [3, 2, 1, 1] + +Before: [0, 1, 0, 0] +15 1 3 1 +After: [0, 1, 0, 0] + +Before: [3, 1, 2, 3] +6 1 3 0 +After: [0, 1, 2, 3] + +Before: [0, 1, 2, 0] +0 1 2 2 +After: [0, 1, 0, 0] + +Before: [1, 2, 2, 1] +9 0 2 2 +After: [1, 2, 0, 1] + +Before: [3, 3, 2, 1] +3 3 2 2 +After: [3, 3, 1, 1] + +Before: [0, 2, 1, 3] +13 3 3 1 +After: [0, 3, 1, 3] + +Before: [0, 2, 2, 2] +7 0 0 0 +After: [0, 2, 2, 2] + +Before: [1, 3, 3, 2] +14 3 3 2 +After: [1, 3, 0, 2] + +Before: [3, 1, 0, 2] +1 1 3 1 +After: [3, 0, 0, 2] + +Before: [0, 2, 3, 3] +6 1 3 3 +After: [0, 2, 3, 0] + +Before: [3, 1, 2, 0] +15 1 3 2 +After: [3, 1, 1, 0] + +Before: [0, 0, 2, 3] +5 2 2 3 +After: [0, 0, 2, 1] + +Before: [1, 0, 2, 1] +9 0 2 0 +After: [0, 0, 2, 1] + +Before: [0, 1, 1, 2] +7 0 0 0 +After: [0, 1, 1, 2] + +Before: [2, 3, 1, 3] +5 3 2 1 +After: [2, 0, 1, 3] + +Before: [2, 1, 2, 3] +0 1 2 0 +After: [0, 1, 2, 3] + +Before: [2, 2, 3, 2] +4 0 2 1 +After: [2, 2, 3, 2] + +Before: [0, 3, 2, 2] +7 0 0 2 +After: [0, 3, 0, 2] + +Before: [3, 0, 3, 3] +5 3 0 3 +After: [3, 0, 3, 1] + +Before: [1, 1, 3, 3] +13 3 3 0 +After: [3, 1, 3, 3] + +Before: [3, 2, 3, 3] +4 1 2 3 +After: [3, 2, 3, 2] + +Before: [0, 1, 2, 2] +13 2 2 0 +After: [2, 1, 2, 2] + +Before: [0, 3, 2, 3] +5 0 0 2 +After: [0, 3, 1, 3] + +Before: [3, 3, 3, 2] +4 3 2 2 +After: [3, 3, 2, 2] + +Before: [0, 3, 0, 3] +5 3 3 0 +After: [1, 3, 0, 3] + +Before: [3, 3, 2, 2] +13 2 2 2 +After: [3, 3, 2, 2] + +Before: [2, 1, 0, 2] +1 1 3 0 +After: [0, 1, 0, 2] + +Before: [3, 3, 0, 1] +14 3 3 1 +After: [3, 0, 0, 1] + +Before: [0, 0, 3, 0] +7 0 0 2 +After: [0, 0, 0, 0] + +Before: [1, 0, 1, 1] +2 0 1 2 +After: [1, 0, 1, 1] + +Before: [1, 2, 3, 3] +13 3 3 0 +After: [3, 2, 3, 3] + +Before: [3, 2, 1, 3] +6 2 3 3 +After: [3, 2, 1, 0] + +Before: [3, 1, 2, 1] +10 0 2 1 +After: [3, 1, 2, 1] + +Before: [1, 2, 2, 0] +9 0 2 3 +After: [1, 2, 2, 0] + +Before: [3, 1, 2, 2] +0 1 2 0 +After: [0, 1, 2, 2] + +Before: [0, 1, 0, 0] +12 1 0 0 +After: [1, 1, 0, 0] + +Before: [2, 0, 2, 1] +2 3 1 2 +After: [2, 0, 1, 1] + +Before: [2, 3, 2, 1] +3 3 2 1 +After: [2, 1, 2, 1] + +Before: [3, 2, 3, 1] +14 3 3 3 +After: [3, 2, 3, 0] + +Before: [1, 0, 2, 1] +3 3 2 0 +After: [1, 0, 2, 1] + +Before: [1, 1, 2, 0] +0 1 2 2 +After: [1, 1, 0, 0] + +Before: [2, 2, 3, 2] +11 0 2 3 +After: [2, 2, 3, 1] + +Before: [3, 0, 2, 3] +10 0 2 0 +After: [1, 0, 2, 3] + +Before: [3, 2, 3, 2] +4 3 2 1 +After: [3, 2, 3, 2] + +Before: [3, 1, 2, 2] +10 0 2 2 +After: [3, 1, 1, 2] + +Before: [2, 1, 3, 3] +6 1 3 2 +After: [2, 1, 0, 3] + +Before: [3, 2, 2, 2] +8 0 3 2 +After: [3, 2, 1, 2] + +Before: [0, 1, 0, 0] +7 0 0 3 +After: [0, 1, 0, 0] + +Before: [2, 3, 3, 2] +11 0 2 3 +After: [2, 3, 3, 1] + +Before: [0, 2, 3, 2] +7 0 0 3 +After: [0, 2, 3, 0] + +Before: [1, 3, 3, 3] +5 3 2 0 +After: [1, 3, 3, 3] + +Before: [3, 2, 0, 3] +11 2 0 3 +After: [3, 2, 0, 1] + +Before: [3, 2, 2, 2] +14 3 3 3 +After: [3, 2, 2, 0] + +Before: [2, 3, 2, 3] +13 2 2 3 +After: [2, 3, 2, 2] + +Before: [3, 2, 3, 2] +14 3 3 0 +After: [0, 2, 3, 2] + +Before: [1, 3, 1, 1] +14 3 3 0 +After: [0, 3, 1, 1] + +Before: [3, 1, 2, 1] +0 1 2 2 +After: [3, 1, 0, 1] + +Before: [0, 1, 1, 2] +1 1 3 1 +After: [0, 0, 1, 2] + +Before: [3, 3, 3, 2] +8 0 3 0 +After: [1, 3, 3, 2] + +Before: [2, 0, 3, 3] +4 0 2 0 +After: [2, 0, 3, 3] + +Before: [1, 2, 2, 1] +3 3 2 1 +After: [1, 1, 2, 1] + +Before: [0, 1, 3, 0] +7 0 0 2 +After: [0, 1, 0, 0] + +Before: [0, 0, 3, 2] +14 3 3 2 +After: [0, 0, 0, 2] + +Before: [2, 3, 2, 1] +5 2 0 3 +After: [2, 3, 2, 1] + +Before: [0, 1, 0, 1] +12 1 0 2 +After: [0, 1, 1, 1] + +Before: [0, 1, 2, 0] +15 1 3 3 +After: [0, 1, 2, 1] + +Before: [1, 3, 2, 3] +6 2 3 0 +After: [0, 3, 2, 3] + +Before: [1, 1, 1, 3] +13 3 3 1 +After: [1, 3, 1, 3] + +Before: [2, 1, 3, 3] +4 0 2 3 +After: [2, 1, 3, 2] + +Before: [0, 1, 2, 3] +0 1 2 1 +After: [0, 0, 2, 3] + +Before: [2, 1, 1, 2] +1 1 3 3 +After: [2, 1, 1, 0] + +Before: [3, 0, 2, 0] +10 0 2 3 +After: [3, 0, 2, 1] + +Before: [1, 2, 2, 1] +9 0 2 3 +After: [1, 2, 2, 0] + +Before: [2, 1, 3, 2] +4 0 2 1 +After: [2, 2, 3, 2] + +Before: [3, 3, 0, 1] +11 2 0 3 +After: [3, 3, 0, 1] + +Before: [3, 1, 2, 0] +0 1 2 0 +After: [0, 1, 2, 0] + +Before: [0, 1, 3, 3] +12 1 0 1 +After: [0, 1, 3, 3] + +Before: [1, 0, 0, 1] +2 3 1 1 +After: [1, 1, 0, 1] + +Before: [1, 1, 2, 3] +9 0 2 1 +After: [1, 0, 2, 3] + +Before: [3, 2, 0, 2] +11 2 0 1 +After: [3, 1, 0, 2] + +Before: [0, 3, 1, 1] +7 0 0 1 +After: [0, 0, 1, 1] + +Before: [0, 1, 2, 2] +7 0 0 1 +After: [0, 0, 2, 2] + +Before: [0, 3, 2, 0] +7 0 0 0 +After: [0, 3, 2, 0] + +Before: [2, 3, 2, 1] +3 3 2 0 +After: [1, 3, 2, 1] + +Before: [3, 3, 0, 2] +8 0 3 1 +After: [3, 1, 0, 2] + +Before: [0, 1, 2, 1] +12 1 0 3 +After: [0, 1, 2, 1] + +Before: [0, 2, 3, 3] +5 0 0 3 +After: [0, 2, 3, 1] + +Before: [0, 0, 0, 1] +2 3 1 1 +After: [0, 1, 0, 1] + +Before: [2, 0, 3, 2] +11 0 2 2 +After: [2, 0, 1, 2] + +Before: [0, 1, 3, 0] +15 1 3 1 +After: [0, 1, 3, 0] + +Before: [0, 2, 1, 3] +7 0 0 0 +After: [0, 2, 1, 3] + +Before: [0, 3, 3, 3] +7 0 0 2 +After: [0, 3, 0, 3] + +Before: [3, 1, 2, 2] +1 1 3 0 +After: [0, 1, 2, 2] + +Before: [3, 0, 0, 2] +14 3 3 3 +After: [3, 0, 0, 0] + +Before: [3, 1, 3, 0] +15 1 3 1 +After: [3, 1, 3, 0] + +Before: [3, 0, 2, 1] +3 3 2 3 +After: [3, 0, 2, 1] + +Before: [0, 1, 0, 3] +12 1 0 2 +After: [0, 1, 1, 3] + +Before: [2, 3, 2, 2] +5 2 0 0 +After: [1, 3, 2, 2] + +Before: [0, 1, 2, 2] +0 1 2 0 +After: [0, 1, 2, 2] + +Before: [2, 0, 1, 0] +8 0 2 1 +After: [2, 1, 1, 0] + +Before: [3, 1, 3, 3] +6 1 3 0 +After: [0, 1, 3, 3] + +Before: [1, 1, 1, 2] +1 1 3 2 +After: [1, 1, 0, 2] + +Before: [2, 1, 0, 2] +1 1 3 3 +After: [2, 1, 0, 0] + +Before: [2, 1, 3, 2] +11 0 2 3 +After: [2, 1, 3, 1] + +Before: [3, 1, 2, 2] +14 3 3 3 +After: [3, 1, 2, 0] + +Before: [3, 0, 1, 2] +2 2 1 1 +After: [3, 1, 1, 2] + +Before: [3, 1, 1, 0] +15 1 3 1 +After: [3, 1, 1, 0] + +Before: [2, 0, 3, 0] +4 0 2 3 +After: [2, 0, 3, 2] + +Before: [0, 2, 0, 3] +7 0 0 2 +After: [0, 2, 0, 3] + +Before: [1, 0, 2, 2] +9 0 2 2 +After: [1, 0, 0, 2] + +Before: [0, 3, 2, 1] +3 3 2 3 +After: [0, 3, 2, 1] + +Before: [2, 1, 1, 0] +15 1 3 0 +After: [1, 1, 1, 0] + +Before: [3, 1, 3, 2] +8 0 3 1 +After: [3, 1, 3, 2] + +Before: [0, 0, 2, 1] +2 3 1 3 +After: [0, 0, 2, 1] + +Before: [3, 1, 2, 2] +10 0 2 0 +After: [1, 1, 2, 2] + +Before: [1, 3, 2, 1] +3 3 2 0 +After: [1, 3, 2, 1] + +Before: [1, 3, 2, 1] +3 3 2 3 +After: [1, 3, 2, 1] + +Before: [3, 2, 3, 2] +4 3 2 0 +After: [2, 2, 3, 2] + +Before: [2, 1, 3, 0] +4 0 2 0 +After: [2, 1, 3, 0] + +Before: [3, 1, 2, 1] +3 3 2 1 +After: [3, 1, 2, 1] + +Before: [1, 3, 2, 0] +9 0 2 1 +After: [1, 0, 2, 0] + +Before: [3, 2, 0, 1] +14 3 3 2 +After: [3, 2, 0, 1] + +Before: [2, 3, 3, 3] +11 0 2 1 +After: [2, 1, 3, 3] + +Before: [0, 1, 2, 0] +0 1 2 3 +After: [0, 1, 2, 0] + +Before: [2, 1, 3, 2] +1 1 3 0 +After: [0, 1, 3, 2] + +Before: [1, 1, 2, 0] +9 0 2 3 +After: [1, 1, 2, 0] + +Before: [0, 1, 2, 2] +12 1 0 2 +After: [0, 1, 1, 2] + +Before: [0, 0, 3, 3] +5 0 0 2 +After: [0, 0, 1, 3] + +Before: [1, 0, 1, 3] +2 2 1 0 +After: [1, 0, 1, 3] + +Before: [2, 0, 3, 0] +11 0 2 3 +After: [2, 0, 3, 1] + +Before: [2, 3, 2, 1] +14 3 3 1 +After: [2, 0, 2, 1] + +Before: [3, 2, 2, 3] +10 0 2 0 +After: [1, 2, 2, 3] + +Before: [2, 0, 1, 1] +8 0 2 3 +After: [2, 0, 1, 1] + +Before: [0, 1, 2, 1] +0 1 2 1 +After: [0, 0, 2, 1] + +Before: [0, 1, 2, 3] +5 3 1 1 +After: [0, 0, 2, 3] + +Before: [3, 0, 0, 3] +13 3 3 2 +After: [3, 0, 3, 3] + +Before: [1, 1, 2, 2] +1 1 3 3 +After: [1, 1, 2, 0] + +Before: [3, 0, 0, 3] +13 3 3 3 +After: [3, 0, 0, 3] + +Before: [0, 1, 1, 2] +1 1 3 0 +After: [0, 1, 1, 2] + +Before: [0, 1, 2, 3] +13 2 2 1 +After: [0, 2, 2, 3] + +Before: [1, 1, 2, 3] +9 0 2 2 +After: [1, 1, 0, 3] + +Before: [3, 0, 0, 3] +11 2 0 0 +After: [1, 0, 0, 3] + +Before: [0, 1, 0, 2] +12 1 0 2 +After: [0, 1, 1, 2] + +Before: [0, 1, 2, 0] +5 0 0 3 +After: [0, 1, 2, 1] + +Before: [3, 3, 2, 1] +10 0 2 3 +After: [3, 3, 2, 1] + +Before: [2, 2, 3, 0] +4 1 2 3 +After: [2, 2, 3, 2] + +Before: [2, 0, 2, 0] +5 2 2 3 +After: [2, 0, 2, 1] + +Before: [1, 1, 2, 0] +15 1 3 0 +After: [1, 1, 2, 0] + +Before: [1, 3, 2, 3] +9 0 2 0 +After: [0, 3, 2, 3] + +Before: [3, 1, 3, 0] +15 1 3 3 +After: [3, 1, 3, 1] + +Before: [3, 0, 1, 3] +2 2 1 3 +After: [3, 0, 1, 1] + +Before: [0, 1, 1, 0] +15 1 3 1 +After: [0, 1, 1, 0] + +Before: [1, 3, 2, 1] +3 3 2 2 +After: [1, 3, 1, 1] + +Before: [2, 2, 3, 0] +11 0 2 3 +After: [2, 2, 3, 1] + +Before: [1, 1, 2, 3] +5 3 2 1 +After: [1, 0, 2, 3] + +Before: [3, 0, 1, 1] +2 3 1 0 +After: [1, 0, 1, 1] + +Before: [2, 1, 2, 3] +5 2 0 1 +After: [2, 1, 2, 3] + +Before: [2, 1, 2, 0] +10 0 1 0 +After: [1, 1, 2, 0] + +Before: [2, 2, 3, 3] +4 1 2 1 +After: [2, 2, 3, 3] + +Before: [3, 0, 2, 1] +3 3 2 0 +After: [1, 0, 2, 1] + +Before: [3, 2, 2, 0] +10 0 2 3 +After: [3, 2, 2, 1] + +Before: [3, 0, 1, 3] +5 3 0 3 +After: [3, 0, 1, 1] + +Before: [1, 1, 2, 0] +0 1 2 3 +After: [1, 1, 2, 0] + +Before: [3, 1, 1, 2] +1 1 3 1 +After: [3, 0, 1, 2] + +Before: [1, 3, 2, 1] +3 3 2 1 +After: [1, 1, 2, 1] + +Before: [0, 1, 1, 0] +7 0 0 0 +After: [0, 1, 1, 0] + +Before: [3, 1, 3, 2] +1 1 3 3 +After: [3, 1, 3, 0] + +Before: [0, 3, 2, 3] +6 2 3 1 +After: [0, 0, 2, 3] + +Before: [3, 2, 2, 3] +6 2 3 0 +After: [0, 2, 2, 3] + +Before: [3, 1, 2, 1] +3 3 2 2 +After: [3, 1, 1, 1] + +Before: [2, 0, 2, 3] +6 2 3 1 +After: [2, 0, 2, 3] + +Before: [3, 1, 0, 2] +11 2 0 2 +After: [3, 1, 1, 2] + +Before: [1, 1, 0, 2] +1 1 3 1 +After: [1, 0, 0, 2] + +Before: [2, 2, 3, 3] +11 0 2 2 +After: [2, 2, 1, 3] + +Before: [0, 0, 2, 3] +13 2 2 1 +After: [0, 2, 2, 3] + +Before: [2, 1, 3, 0] +10 0 1 1 +After: [2, 1, 3, 0] + +Before: [0, 1, 2, 2] +5 2 2 0 +After: [1, 1, 2, 2] + +Before: [1, 1, 3, 2] +4 3 2 3 +After: [1, 1, 3, 2] + +Before: [3, 1, 2, 0] +15 1 3 3 +After: [3, 1, 2, 1] + +Before: [0, 1, 3, 1] +12 1 0 3 +After: [0, 1, 3, 1] + +Before: [0, 1, 2, 2] +0 1 2 3 +After: [0, 1, 2, 0] + +Before: [3, 2, 2, 3] +10 0 2 1 +After: [3, 1, 2, 3] + +Before: [0, 3, 1, 1] +14 3 3 0 +After: [0, 3, 1, 1] + +Before: [3, 0, 2, 1] +2 3 1 1 +After: [3, 1, 2, 1] + +Before: [0, 3, 2, 3] +13 2 2 3 +After: [0, 3, 2, 2] + +Before: [3, 0, 2, 0] +10 0 2 2 +After: [3, 0, 1, 0] + +Before: [2, 3, 0, 3] +13 3 3 3 +After: [2, 3, 0, 3] + +Before: [3, 0, 1, 3] +2 2 1 0 +After: [1, 0, 1, 3] + +Before: [0, 1, 1, 0] +12 1 0 3 +After: [0, 1, 1, 1] + +Before: [0, 1, 2, 3] +12 1 0 1 +After: [0, 1, 2, 3] + +Before: [0, 1, 3, 0] +5 0 0 1 +After: [0, 1, 3, 0] + +Before: [3, 2, 2, 1] +10 0 2 2 +After: [3, 2, 1, 1] + +Before: [3, 1, 3, 1] +5 2 1 0 +After: [0, 1, 3, 1] + +Before: [0, 1, 2, 0] +15 1 3 0 +After: [1, 1, 2, 0] + +Before: [0, 1, 0, 2] +1 1 3 1 +After: [0, 0, 0, 2] + +Before: [3, 0, 2, 1] +10 0 2 2 +After: [3, 0, 1, 1] + +Before: [0, 1, 0, 0] +12 1 0 2 +After: [0, 1, 1, 0] + +Before: [3, 0, 2, 1] +10 0 2 3 +After: [3, 0, 2, 1] + +Before: [0, 3, 2, 1] +3 3 2 1 +After: [0, 1, 2, 1] + +Before: [1, 1, 2, 2] +9 0 2 1 +After: [1, 0, 2, 2] + +Before: [2, 1, 3, 0] +15 1 3 2 +After: [2, 1, 1, 0] + +Before: [0, 0, 2, 1] +13 2 2 2 +After: [0, 0, 2, 1] + +Before: [0, 3, 3, 2] +4 3 2 2 +After: [0, 3, 2, 2] + +Before: [2, 1, 2, 0] +15 1 3 2 +After: [2, 1, 1, 0] + +Before: [1, 0, 2, 2] +9 0 2 3 +After: [1, 0, 2, 0] + +Before: [0, 1, 1, 0] +15 1 3 3 +After: [0, 1, 1, 1] + +Before: [0, 1, 0, 0] +15 1 3 2 +After: [0, 1, 1, 0] + +Before: [0, 1, 1, 3] +12 1 0 2 +After: [0, 1, 1, 3] + +Before: [3, 1, 2, 2] +10 0 2 3 +After: [3, 1, 2, 1] + +Before: [3, 3, 2, 3] +10 0 2 3 +After: [3, 3, 2, 1] + +Before: [0, 0, 1, 3] +2 2 1 1 +After: [0, 1, 1, 3] + +Before: [0, 1, 3, 0] +15 1 3 2 +After: [0, 1, 1, 0] + +Before: [1, 3, 2, 2] +9 0 2 1 +After: [1, 0, 2, 2] + +Before: [3, 3, 0, 0] +11 2 0 0 +After: [1, 3, 0, 0] + +Before: [0, 1, 0, 0] +12 1 0 1 +After: [0, 1, 0, 0] + +Before: [3, 2, 0, 2] +14 3 3 2 +After: [3, 2, 0, 2] + +Before: [3, 3, 0, 2] +11 2 0 2 +After: [3, 3, 1, 2] + +Before: [1, 2, 2, 3] +9 0 2 3 +After: [1, 2, 2, 0] + +Before: [1, 3, 3, 3] +5 3 3 2 +After: [1, 3, 1, 3] + +Before: [2, 0, 1, 1] +14 3 3 0 +After: [0, 0, 1, 1] + +Before: [1, 3, 2, 2] +9 0 2 0 +After: [0, 3, 2, 2] + +Before: [2, 1, 1, 3] +8 0 2 1 +After: [2, 1, 1, 3] + +Before: [2, 1, 1, 2] +8 0 2 3 +After: [2, 1, 1, 1] + +Before: [2, 2, 1, 0] +8 0 2 2 +After: [2, 2, 1, 0] + +Before: [3, 1, 2, 1] +10 0 2 2 +After: [3, 1, 1, 1] + +Before: [0, 2, 3, 0] +7 0 0 1 +After: [0, 0, 3, 0] + +Before: [3, 3, 3, 3] +5 3 0 2 +After: [3, 3, 1, 3] + +Before: [3, 0, 2, 1] +13 2 2 1 +After: [3, 2, 2, 1] + +Before: [1, 1, 2, 3] +0 1 2 3 +After: [1, 1, 2, 0] + +Before: [2, 1, 2, 3] +6 2 3 1 +After: [2, 0, 2, 3] + +Before: [0, 0, 1, 2] +2 2 1 2 +After: [0, 0, 1, 2] + +Before: [1, 2, 1, 3] +5 3 1 2 +After: [1, 2, 0, 3] + +Before: [3, 0, 0, 2] +8 0 3 0 +After: [1, 0, 0, 2] + +Before: [1, 3, 2, 1] +9 0 2 1 +After: [1, 0, 2, 1] + +Before: [3, 1, 2, 1] +0 1 2 3 +After: [3, 1, 2, 0] + +Before: [0, 1, 2, 3] +12 1 0 0 +After: [1, 1, 2, 3] + +Before: [2, 3, 3, 3] +11 0 2 3 +After: [2, 3, 3, 1] + +Before: [0, 2, 0, 3] +7 0 0 3 +After: [0, 2, 0, 0] + +Before: [1, 1, 3, 2] +1 1 3 3 +After: [1, 1, 3, 0] + +Before: [3, 2, 3, 3] +5 3 2 1 +After: [3, 1, 3, 3] + +Before: [1, 0, 2, 3] +13 3 3 1 +After: [1, 3, 2, 3] + +Before: [2, 1, 3, 0] +15 1 3 3 +After: [2, 1, 3, 1] + +Before: [2, 0, 2, 3] +6 2 3 2 +After: [2, 0, 0, 3] + +Before: [2, 1, 1, 3] +6 1 3 0 +After: [0, 1, 1, 3] + +Before: [0, 0, 2, 1] +2 3 1 2 +After: [0, 0, 1, 1] + +Before: [1, 0, 1, 0] +2 0 1 3 +After: [1, 0, 1, 1] + +Before: [2, 1, 1, 3] +13 3 3 2 +After: [2, 1, 3, 3] + +Before: [0, 2, 1, 0] +7 0 0 2 +After: [0, 2, 0, 0] + +Before: [1, 0, 2, 0] +2 0 1 2 +After: [1, 0, 1, 0] + +Before: [0, 0, 3, 1] +2 3 1 0 +After: [1, 0, 3, 1] + +Before: [2, 0, 1, 0] +8 0 2 3 +After: [2, 0, 1, 1] + +Before: [3, 1, 1, 2] +1 1 3 3 +After: [3, 1, 1, 0] + +Before: [0, 1, 1, 2] +12 1 0 0 +After: [1, 1, 1, 2] + +Before: [1, 1, 2, 1] +9 0 2 3 +After: [1, 1, 2, 0] + +Before: [0, 0, 0, 2] +14 3 3 2 +After: [0, 0, 0, 2] + +Before: [3, 1, 0, 2] +1 1 3 2 +After: [3, 1, 0, 2] + +Before: [0, 1, 3, 2] +4 3 2 0 +After: [2, 1, 3, 2] + +Before: [1, 0, 2, 1] +2 0 1 2 +After: [1, 0, 1, 1] + +Before: [1, 3, 2, 1] +9 0 2 0 +After: [0, 3, 2, 1] + +Before: [0, 0, 2, 1] +3 3 2 1 +After: [0, 1, 2, 1] + +Before: [2, 2, 2, 3] +6 1 3 3 +After: [2, 2, 2, 0] + +Before: [3, 2, 2, 2] +10 0 2 2 +After: [3, 2, 1, 2] + +Before: [1, 0, 3, 2] +14 3 3 1 +After: [1, 0, 3, 2] + +Before: [2, 0, 3, 0] +4 0 2 1 +After: [2, 2, 3, 0] + +Before: [2, 1, 1, 2] +10 0 1 3 +After: [2, 1, 1, 1] + +Before: [2, 1, 2, 0] +10 0 1 3 +After: [2, 1, 2, 1] + +Before: [2, 3, 3, 3] +11 0 2 2 +After: [2, 3, 1, 3] + +Before: [2, 1, 2, 1] +10 0 1 1 +After: [2, 1, 2, 1] + +Before: [2, 2, 3, 3] +4 1 2 3 +After: [2, 2, 3, 2] + +Before: [3, 1, 2, 3] +10 0 2 3 +After: [3, 1, 2, 1] + +Before: [1, 2, 2, 0] +9 0 2 1 +After: [1, 0, 2, 0] + +Before: [1, 3, 2, 2] +9 0 2 3 +After: [1, 3, 2, 0] + +Before: [1, 1, 2, 3] +5 3 2 2 +After: [1, 1, 0, 3] + +Before: [1, 0, 3, 0] +2 0 1 1 +After: [1, 1, 3, 0] + +Before: [1, 1, 1, 0] +15 1 3 0 +After: [1, 1, 1, 0] + +Before: [0, 2, 3, 3] +4 1 2 2 +After: [0, 2, 2, 3] + +Before: [2, 1, 3, 2] +5 2 1 2 +After: [2, 1, 0, 2] + +Before: [2, 1, 2, 0] +0 1 2 1 +After: [2, 0, 2, 0] + +Before: [1, 1, 3, 2] +1 1 3 0 +After: [0, 1, 3, 2] + +Before: [3, 3, 2, 1] +10 0 2 2 +After: [3, 3, 1, 1] + +Before: [0, 1, 2, 1] +3 3 2 2 +After: [0, 1, 1, 1] + +Before: [0, 1, 3, 3] +7 0 0 0 +After: [0, 1, 3, 3] + +Before: [2, 0, 2, 1] +3 3 2 1 +After: [2, 1, 2, 1] + +Before: [1, 1, 2, 1] +0 1 2 1 +After: [1, 0, 2, 1] + +Before: [3, 0, 1, 2] +8 0 3 1 +After: [3, 1, 1, 2] + +Before: [1, 0, 2, 2] +2 0 1 2 +After: [1, 0, 1, 2] + +Before: [3, 1, 2, 3] +6 2 3 1 +After: [3, 0, 2, 3] + +Before: [0, 0, 2, 1] +2 3 1 0 +After: [1, 0, 2, 1] + +Before: [0, 1, 0, 3] +12 1 0 3 +After: [0, 1, 0, 1] + +Before: [2, 1, 1, 3] +5 3 2 3 +After: [2, 1, 1, 0] + +Before: [2, 0, 3, 2] +14 3 3 1 +After: [2, 0, 3, 2] + +Before: [1, 2, 2, 2] +9 0 2 1 +After: [1, 0, 2, 2] + +Before: [0, 1, 1, 1] +12 1 0 0 +After: [1, 1, 1, 1] + +Before: [0, 2, 0, 1] +7 0 0 2 +After: [0, 2, 0, 1] + +Before: [2, 2, 1, 2] +8 0 2 3 +After: [2, 2, 1, 1] + +Before: [1, 0, 1, 1] +2 0 1 3 +After: [1, 0, 1, 1] + +Before: [2, 1, 1, 2] +10 0 1 2 +After: [2, 1, 1, 2] + +Before: [2, 1, 1, 1] +8 0 2 2 +After: [2, 1, 1, 1] + +Before: [3, 3, 2, 2] +10 0 2 2 +After: [3, 3, 1, 2] + +Before: [2, 3, 2, 0] +13 2 2 1 +After: [2, 2, 2, 0] + +Before: [1, 0, 2, 3] +2 0 1 2 +After: [1, 0, 1, 3] + +Before: [2, 1, 3, 3] +4 0 2 0 +After: [2, 1, 3, 3] + +Before: [1, 2, 2, 0] +5 2 1 2 +After: [1, 2, 1, 0] + +Before: [0, 1, 0, 2] +12 1 0 1 +After: [0, 1, 0, 2] + +Before: [3, 1, 1, 2] +8 0 3 0 +After: [1, 1, 1, 2] + +Before: [0, 1, 3, 0] +15 1 3 0 +After: [1, 1, 3, 0] + +Before: [2, 1, 3, 2] +4 3 2 2 +After: [2, 1, 2, 2] + +Before: [3, 1, 0, 2] +8 0 3 3 +After: [3, 1, 0, 1] + +Before: [2, 3, 3, 3] +11 0 2 0 +After: [1, 3, 3, 3] + +Before: [0, 1, 1, 3] +6 2 3 2 +After: [0, 1, 0, 3] + +Before: [2, 3, 3, 1] +11 0 2 2 +After: [2, 3, 1, 1] + +Before: [3, 1, 1, 2] +8 0 3 2 +After: [3, 1, 1, 2] + +Before: [1, 2, 2, 3] +9 0 2 0 +After: [0, 2, 2, 3] + +Before: [1, 1, 0, 2] +1 1 3 0 +After: [0, 1, 0, 2] + +Before: [1, 1, 0, 2] +1 1 3 3 +After: [1, 1, 0, 0] + +Before: [0, 1, 2, 3] +12 1 0 3 +After: [0, 1, 2, 1] + +Before: [3, 0, 1, 2] +8 0 3 3 +After: [3, 0, 1, 1] + +Before: [2, 1, 2, 3] +0 1 2 1 +After: [2, 0, 2, 3] + +Before: [3, 0, 0, 0] +11 2 0 3 +After: [3, 0, 0, 1] + +Before: [3, 2, 2, 2] +8 0 3 3 +After: [3, 2, 2, 1] + +Before: [1, 1, 3, 3] +6 1 3 1 +After: [1, 0, 3, 3] + +Before: [3, 1, 0, 1] +11 2 0 0 +After: [1, 1, 0, 1] + +Before: [1, 1, 1, 0] +15 1 3 3 +After: [1, 1, 1, 1] + +Before: [2, 2, 3, 2] +4 0 2 3 +After: [2, 2, 3, 2] + +Before: [2, 2, 3, 2] +11 0 2 1 +After: [2, 1, 3, 2] + +Before: [0, 0, 1, 1] +7 0 0 0 +After: [0, 0, 1, 1] + +Before: [0, 3, 1, 3] +7 0 0 1 +After: [0, 0, 1, 3] + +Before: [2, 1, 3, 1] +10 0 1 0 +After: [1, 1, 3, 1] + +Before: [3, 1, 2, 2] +0 1 2 2 +After: [3, 1, 0, 2] + +Before: [1, 0, 3, 2] +2 0 1 0 +After: [1, 0, 3, 2] + +Before: [3, 0, 3, 1] +2 3 1 1 +After: [3, 1, 3, 1] + +Before: [3, 1, 2, 1] +3 3 2 0 +After: [1, 1, 2, 1] + +Before: [3, 1, 2, 1] +10 0 2 0 +After: [1, 1, 2, 1] + +Before: [3, 3, 2, 1] +3 3 2 1 +After: [3, 1, 2, 1] + +Before: [0, 1, 0, 2] +1 1 3 0 +After: [0, 1, 0, 2] + +Before: [2, 1, 3, 1] +11 0 2 1 +After: [2, 1, 3, 1] + +Before: [2, 3, 1, 1] +8 0 2 3 +After: [2, 3, 1, 1] + +Before: [2, 2, 2, 1] +5 2 2 1 +After: [2, 1, 2, 1] + +Before: [3, 0, 1, 1] +2 3 1 2 +After: [3, 0, 1, 1] + +Before: [2, 2, 2, 1] +14 3 3 0 +After: [0, 2, 2, 1] + +Before: [2, 3, 3, 2] +4 0 2 0 +After: [2, 3, 3, 2] + +Before: [2, 2, 3, 1] +11 0 2 2 +After: [2, 2, 1, 1] + +Before: [0, 1, 1, 1] +7 0 0 3 +After: [0, 1, 1, 0] + +Before: [3, 3, 0, 1] +11 2 0 2 +After: [3, 3, 1, 1] + +Before: [2, 2, 3, 3] +4 0 2 2 +After: [2, 2, 2, 3] + +Before: [2, 2, 3, 0] +4 0 2 3 +After: [2, 2, 3, 2] + +Before: [1, 1, 2, 1] +0 1 2 3 +After: [1, 1, 2, 0] + +Before: [2, 1, 0, 2] +10 0 1 1 +After: [2, 1, 0, 2] + +Before: [1, 3, 2, 0] +9 0 2 0 +After: [0, 3, 2, 0] + +Before: [3, 2, 0, 2] +11 2 0 2 +After: [3, 2, 1, 2] + +Before: [0, 1, 1, 2] +1 1 3 3 +After: [0, 1, 1, 0] + +Before: [1, 1, 3, 2] +1 1 3 1 +After: [1, 0, 3, 2] + +Before: [0, 2, 2, 1] +3 3 2 2 +After: [0, 2, 1, 1] + +Before: [2, 1, 1, 3] +10 0 1 2 +After: [2, 1, 1, 3] + +Before: [0, 1, 1, 3] +7 0 0 2 +After: [0, 1, 0, 3] + +Before: [3, 1, 2, 1] +5 2 2 0 +After: [1, 1, 2, 1] + +Before: [1, 1, 2, 0] +15 1 3 2 +After: [1, 1, 1, 0] + +Before: [0, 1, 2, 2] +0 1 2 2 +After: [0, 1, 0, 2] + +Before: [2, 0, 1, 1] +2 2 1 2 +After: [2, 0, 1, 1] + +Before: [1, 1, 2, 2] +1 1 3 1 +After: [1, 0, 2, 2] + +Before: [3, 1, 2, 0] +10 0 2 2 +After: [3, 1, 1, 0] + +Before: [3, 2, 0, 3] +11 2 0 2 +After: [3, 2, 1, 3] + + + +9 1 1 1 +9 1 1 2 +9 3 3 3 +0 3 2 1 +2 1 3 1 +15 0 1 0 +3 0 3 1 +9 2 0 3 +9 3 0 0 +9 2 3 2 +4 2 3 2 +2 2 1 2 +2 2 2 2 +15 2 1 1 +3 1 1 3 +9 1 2 0 +9 3 1 1 +9 2 0 2 +3 0 2 0 +2 0 3 0 +15 3 0 3 +3 3 1 1 +9 3 0 2 +9 2 3 3 +9 2 0 0 +11 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1 +2 1 0 2 +12 2 3 2 +9 2 2 0 +5 0 3 2 +2 2 2 2 +15 1 2 1 +3 1 2 0 +9 3 3 1 +2 2 0 3 +12 3 0 3 +9 3 0 2 +14 3 2 2 +2 2 3 2 +15 2 0 0 +3 0 3 1 +9 0 2 0 +9 1 0 2 +9 2 0 3 +2 3 2 3 +2 3 1 3 +15 1 3 1 +3 1 1 3 +9 3 1 1 +9 2 0 0 +9 3 0 2 +13 0 2 0 +2 0 1 0 +15 0 3 3 +3 3 3 2 +9 1 0 0 +9 2 1 3 +7 0 3 0 +2 0 1 0 +2 0 1 0 +15 0 2 2 +3 2 0 0 +9 0 2 3 +9 2 2 2 +6 3 2 2 +2 2 1 2 +15 0 2 0 +3 0 1 1 +9 3 1 0 +2 1 0 2 +12 2 1 2 +9 3 0 3 +9 2 3 0 +2 0 3 0 +15 0 1 1 +3 1 3 3 +9 3 1 0 +9 3 3 2 +9 3 1 1 +0 1 2 2 +2 2 2 2 +15 3 2 3 +3 3 2 1 +9 2 0 2 +9 2 1 3 +1 0 3 0 +2 0 3 0 +15 0 1 1 +3 1 2 2 +9 2 0 1 +2 1 0 0 +12 0 1 0 +7 0 3 0 +2 0 1 0 +15 0 2 2 +3 2 0 1 +9 2 2 0 +9 3 1 2 +2 3 0 3 +12 3 1 3 +7 3 0 0 +2 0 1 0 +15 1 0 1 +9 3 2 0 +9 1 2 2 +0 0 2 2 +2 2 3 2 +15 2 1 1 +3 1 0 3 +9 0 1 2 +2 1 0 1 +12 1 0 1 +0 0 2 0 +2 0 3 0 +15 3 0 3 +3 3 0 0 +9 2 1 1 +9 3 0 2 +9 2 2 3 +4 1 3 2 +2 2 1 2 +2 2 1 2 +15 2 0 0 diff --git a/problems/day15.html b/problems/day15.html new file mode 100644 index 0000000..6e78a68 --- /dev/null +++ b/problems/day15.html @@ -0,0 +1,451 @@ + + + + +Day 15 - Advent of Code 2018 + + + + + + + +

Advent of Code

Neil Smith (AoC++) 30*

          2018

+ + + +
+

--- Day 15: Beverage Bandits ---

Having perfected their hot chocolate, the Elves have a new problem: the Goblins that live in these caves will do anything to steal it. Looks like they're here for a fight.

+

You scan the area, generating a map of the walls (#), open cavern (.), and starting position of every Goblin (G) and Elf (E) (your puzzle input).

+

Combat proceeds in rounds; in each round, each unit that is still alive takes a turn, resolving all of its actions before the next unit's turn begins. On each unit's turn, it tries to move into range of an enemy (if it isn't already) and then attack (if it is in range).

+

All units are very disciplined and always follow very strict combat rules. Units never move or attack diagonally, as doing so would be dishonorable. When multiple choices are equally valid, ties are broken in reading order: top-to-bottom, then left-to-right. For instance, the order in which units take their turns within a round is the reading order of their starting positions in that round, regardless of the type of unit or whether other units have moved after the round started. For example:

+
                 would take their
+These units:   turns in this order:
+  #######           #######
+  #.G.E.#           #.1.2.#
+  #E.G.E#           #3.4.5#
+  #.G.E.#           #.6.7.#
+  #######           #######
+
+

Each unit begins its turn by identifying all possible targets (enemy units). If no targets remain, combat ends.

+

Then, the unit identifies all of the open squares (.) that are in range of each target; these are the squares which are adjacent (immediately up, down, left, or right) to any target and which aren't already occupied by a wall or another unit. Alternatively, the unit might already be in range of a target. If the unit is not already in range of a target, and there are no open squares which are in range of a target, the unit ends its turn.

+

If the unit is already in range of a target, it does not move, but continues its turn with an attack. Otherwise, since it is not in range of a target, it moves.

+

To move, the unit first considers the squares that are in range and determines which of those squares it could reach in the fewest steps. A step is a single movement to any adjacent (immediately up, down, left, or right) open (.) square. Units cannot move into walls or other units. The unit does this while considering the current positions of units and does not do any prediction about where units will be later. If the unit cannot reach (find an open path to) any of the squares that are in range, it ends its turn. If multiple squares are in range and tied for being reachable in the fewest steps, the square which is first in reading order is chosen. For example:

+
Targets:      In range:     Reachable:    Nearest:      Chosen:
+#######       #######       #######       #######       #######
+#E..G.#       #E.?G?#       #E.@G.#       #E.!G.#       #E.+G.#
+#...#.#  -->  #.?.#?#  -->  #.@.#.#  -->  #.!.#.#  -->  #...#.#
+#.G.#G#       #?G?#G#       #@G@#G#       #!G.#G#       #.G.#G#
+#######       #######       #######       #######       #######
+
+

In the above scenario, the Elf has three targets (the three Goblins):

+
    +
  • Each of the Goblins has open, adjacent squares which are in range (marked with a ? on the map).
  • +
  • Of those squares, four are reachable (marked @); the other two (on the right) would require moving through a wall or unit to reach.
  • +
  • Three of these reachable squares are nearest, requiring the fewest steps (only 2) to reach (marked !).
  • +
  • Of those, the square which is first in reading order is chosen (+).
  • +
+

The unit then takes a single step toward the chosen square along the shortest path to that square. If multiple steps would put the unit equally closer to its destination, the unit chooses the step which is first in reading order. (This requires knowing when there is more than one shortest path so that you can consider the first step of each such path.) For example:

+
In range:     Nearest:      Chosen:       Distance:     Step:
+#######       #######       #######       #######       #######
+#.E...#       #.E...#       #.E...#       #4E212#       #..E..#
+#...?.#  -->  #...!.#  -->  #...+.#  -->  #32101#  -->  #.....#
+#..?G?#       #..!G.#       #...G.#       #432G2#       #...G.#
+#######       #######       #######       #######       #######
+
+

The Elf sees three squares in range of a target (?), two of which are nearest (!), and so the first in reading order is chosen (+). Under "Distance", each open square is marked with its distance from the destination square; the two squares to which the Elf could move on this turn (down and to the right) are both equally good moves and would leave the Elf 2 steps from being in range of the Goblin. Because the step which is first in reading order is chosen, the Elf moves right one square.

+

Here's a larger example of movement:

+
Initially:
+#########
+#G..G..G#
+#.......#
+#.......#
+#G..E..G#
+#.......#
+#.......#
+#G..G..G#
+#########
+
+After 1 round:
+#########
+#.G...G.#
+#...G...#
+#...E..G#
+#.G.....#
+#.......#
+#G..G..G#
+#.......#
+#########
+
+After 2 rounds:
+#########
+#..G.G..#
+#...G...#
+#.G.E.G.#
+#.......#
+#G..G..G#
+#.......#
+#.......#
+#########
+
+After 3 rounds:
+#########
+#.......#
+#..GGG..#
+#..GEG..#
+#G..G...#
+#......G#
+#.......#
+#.......#
+#########
+
+

Once the Goblins and Elf reach the positions above, they all are either in range of a target or cannot find any square in range of a target, and so none of the units can move until a unit dies.

+

After moving (or if the unit began its turn in range of a target), the unit attacks.

+

To attack, the unit first determines all of the targets that are in range of it by being immediately adjacent to it. If there are no such targets, the unit ends its turn. Otherwise, the adjacent target with the fewest hit points is selected; in a tie, the adjacent target with the fewest hit points which is first in reading order is selected.

+

The unit deals damage equal to its attack power to the selected target, reducing its hit points by that amount. If this reduces its hit points to 0 or fewer, the selected target dies: its square becomes . and it takes no further turns.

+

Each unit, either Goblin or Elf, has 3 attack power and starts with 200 hit points.

+

For example, suppose the only Elf is about to attack:

+
       HP:            HP:
+G....  9       G....  9  
+..G..  4       ..G..  4  
+..EG.  2  -->  ..E..     
+..G..  2       ..G..  2  
+...G.  1       ...G.  1  
+
+

The "HP" column shows the hit points of the Goblin to the left in the corresponding row. The Elf is in range of three targets: the Goblin above it (with 4 hit points), the Goblin to its right (with 2 hit points), and the Goblin below it (also with 2 hit points). Because three targets are in range, the ones with the lowest hit points are selected: the two Goblins with 2 hit points each (one to the right of the Elf and one below the Elf). Of those, the Goblin first in reading order (the one to the right of the Elf) is selected. The selected Goblin's hit points (2) are reduced by the Elf's attack power (3), reducing its hit points to -1, killing it.

+

After attacking, the unit's turn ends. Regardless of how the unit's turn ends, the next unit in the round takes its turn. If all units have taken turns in this round, the round ends, and a new round begins.

+

The Elves look quite outnumbered. You need to determine the outcome of the battle: the number of full rounds that were completed (not counting the round in which combat ends) multiplied by the sum of the hit points of all remaining units at the moment combat ends. (Combat only ends when a unit finds no targets during its turn.)

+

Below is an entire sample combat. Next to each map, each row's units' hit points are listed from left to right.

+
Initially:
+#######   
+#.G...#   G(200)
+#...EG#   E(200), G(200)
+#.#.#G#   G(200)
+#..G#E#   G(200), E(200)
+#.....#   
+#######   
+
+After 1 round:
+#######   
+#..G..#   G(200)
+#...EG#   E(197), G(197)
+#.#G#G#   G(200), G(197)
+#...#E#   E(197)
+#.....#   
+#######   
+
+After 2 rounds:
+#######   
+#...G.#   G(200)
+#..GEG#   G(200), E(188), G(194)
+#.#.#G#   G(194)
+#...#E#   E(194)
+#.....#   
+#######   
+
+Combat ensues; eventually, the top Elf dies:
+
+After 23 rounds:
+#######   
+#...G.#   G(200)
+#..G.G#   G(200), G(131)
+#.#.#G#   G(131)
+#...#E#   E(131)
+#.....#   
+#######   
+
+After 24 rounds:
+#######   
+#..G..#   G(200)
+#...G.#   G(131)
+#.#G#G#   G(200), G(128)
+#...#E#   E(128)
+#.....#   
+#######   
+
+After 25 rounds:
+#######   
+#.G...#   G(200)
+#..G..#   G(131)
+#.#.#G#   G(125)
+#..G#E#   G(200), E(125)
+#.....#   
+#######   
+
+After 26 rounds:
+#######   
+#G....#   G(200)
+#.G...#   G(131)
+#.#.#G#   G(122)
+#...#E#   E(122)
+#..G..#   G(200)
+#######   
+
+After 27 rounds:
+#######   
+#G....#   G(200)
+#.G...#   G(131)
+#.#.#G#   G(119)
+#...#E#   E(119)
+#...G.#   G(200)
+#######   
+
+After 28 rounds:
+#######   
+#G....#   G(200)
+#.G...#   G(131)
+#.#.#G#   G(116)
+#...#E#   E(113)
+#....G#   G(200)
+#######   
+
+More combat ensues; eventually, the bottom Elf dies:
+
+After 47 rounds:
+#######   
+#G....#   G(200)
+#.G...#   G(131)
+#.#.#G#   G(59)
+#...#.#   
+#....G#   G(200)
+#######   
+
+

Before the 48th round can finish, the top-left Goblin finds that there are no targets remaining, and so combat ends. So, the number of full rounds that were completed is 47, and the sum of the hit points of all remaining units is 200+131+59+200 = 590. From these, the outcome of the battle is 47 * 590 = 27730.

+

Here are a few example summarized combats:

+
#######       #######
+#G..#E#       #...#E#   E(200)
+#E#E.E#       #E#...#   E(197)
+#G.##.#  -->  #.E##.#   E(185)
+#...#E#       #E..#E#   E(200), E(200)
+#...E.#       #.....#
+#######       #######
+
+Combat ends after 37 full rounds
+Elves win with 982 total hit points left
+Outcome: 37 * 982 = 36334
+
+
#######       #######   
+#E..EG#       #.E.E.#   E(164), E(197)
+#.#G.E#       #.#E..#   E(200)
+#E.##E#  -->  #E.##.#   E(98)
+#G..#.#       #.E.#.#   E(200)
+#..E#.#       #...#.#   
+#######       #######   
+
+Combat ends after 46 full rounds
+Elves win with 859 total hit points left
+Outcome: 46 * 859 = 39514
+
+
#######       #######   
+#E.G#.#       #G.G#.#   G(200), G(98)
+#.#G..#       #.#G..#   G(200)
+#G.#.G#  -->  #..#..#   
+#G..#.#       #...#G#   G(95)
+#...E.#       #...G.#   G(200)
+#######       #######   
+
+Combat ends after 35 full rounds
+Goblins win with 793 total hit points left
+Outcome: 35 * 793 = 27755
+
+
#######       #######   
+#.E...#       #.....#   
+#.#..G#       #.#G..#   G(200)
+#.###.#  -->  #.###.#   
+#E#G#G#       #.#.#.#   
+#...#G#       #G.G#G#   G(98), G(38), G(200)
+#######       #######   
+
+Combat ends after 54 full rounds
+Goblins win with 536 total hit points left
+Outcome: 54 * 536 = 28944
+
+
#########       #########   
+#G......#       #.G.....#   G(137)
+#.E.#...#       #G.G#...#   G(200), G(200)
+#..##..G#       #.G##...#   G(200)
+#...##..#  -->  #...##..#   
+#...#...#       #.G.#...#   G(200)
+#.G...G.#       #.......#   
+#.....G.#       #.......#   
+#########       #########   
+
+Combat ends after 20 full rounds
+Goblins win with 937 total hit points left
+Outcome: 20 * 937 = 18740
+
+

What is the outcome of the combat described in your puzzle input?

+
+

Your puzzle answer was 196200.

--- Part Two ---

According to your calculations, the Elves are going to lose badly. Surely, you won't mess up the timeline too much if you give them just a little advanced technology, right?

+

You need to make sure the Elves not only win, but also suffer no losses: even the death of a single Elf is unacceptable.

+

However, you can't go too far: larger changes will be more likely to permanently alter spacetime.

+

So, you need to find the outcome of the battle in which the Elves have the lowest integer attack power (at least 4) that allows them to win without a single death. The Goblins always have an attack power of 3.

+

In the first summarized example above, the lowest attack power the Elves need to win without losses is 15:

+
#######       #######
+#.G...#       #..E..#   E(158)
+#...EG#       #...E.#   E(14)
+#.#.#G#  -->  #.#.#.#
+#..G#E#       #...#.#
+#.....#       #.....#
+#######       #######
+
+Combat ends after 29 full rounds
+Elves win with 172 total hit points left
+Outcome: 29 * 172 = 4988
+
+

In the second example above, the Elves need only 4 attack power:

+
#######       #######
+#E..EG#       #.E.E.#   E(200), E(23)
+#.#G.E#       #.#E..#   E(200)
+#E.##E#  -->  #E.##E#   E(125), E(200)
+#G..#.#       #.E.#.#   E(200)
+#..E#.#       #...#.#
+#######       #######
+
+Combat ends after 33 full rounds
+Elves win with 948 total hit points left
+Outcome: 33 * 948 = 31284
+
+

In the third example above, the Elves need 15 attack power:

+
#######       #######
+#E.G#.#       #.E.#.#   E(8)
+#.#G..#       #.#E..#   E(86)
+#G.#.G#  -->  #..#..#
+#G..#.#       #...#.#
+#...E.#       #.....#
+#######       #######
+
+Combat ends after 37 full rounds
+Elves win with 94 total hit points left
+Outcome: 37 * 94 = 3478
+
+

In the fourth example above, the Elves need 12 attack power:

+
#######       #######
+#.E...#       #...E.#   E(14)
+#.#..G#       #.#..E#   E(152)
+#.###.#  -->  #.###.#
+#E#G#G#       #.#.#.#
+#...#G#       #...#.#
+#######       #######
+
+Combat ends after 39 full rounds
+Elves win with 166 total hit points left
+Outcome: 39 * 166 = 6474
+
+

In the last example above, the lone Elf needs 34 attack power:

+
#########       #########   
+#G......#       #.......#   
+#.E.#...#       #.E.#...#   E(38)
+#..##..G#       #..##...#   
+#...##..#  -->  #...##..#   
+#...#...#       #...#...#   
+#.G...G.#       #.......#   
+#.....G.#       #.......#   
+#########       #########   
+
+Combat ends after 30 full rounds
+Elves win with 38 total hit points left
+Outcome: 30 * 38 = 1140
+
+

After increasing the Elves' attack power until it is just barely enough for them to win without any Elves dying, what is the outcome of the combat described in your puzzle input?

+
+

Your puzzle answer was 61750.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also this puzzle.

+
+ + + + + + \ No newline at end of file diff --git a/problems/day16.html b/problems/day16.html new file mode 100644 index 0000000..8b5ecf5 --- /dev/null +++ b/problems/day16.html @@ -0,0 +1,179 @@ + + + + +Day 16 - Advent of Code 2018 + + + + + + + +

Advent of Code

Neil Smith (AoC++) 32*

   0xffff&2018

+ + + +
+

--- Day 16: Chronal Classification ---

As you see the Elves defend their hot chocolate successfully, you go back to falling through time. This is going to become a problem.

+

If you're ever going to return to your own time, you need to understand how this device on your wrist works. You have a little while before you reach your next destination, and with a bit of trial and error, you manage to pull up a programming manual on the device's tiny screen.

+

According to the manual, the device has four registers (numbered 0 through 3) that can be manipulated by instructions containing one of 16 opcodes. The registers start with the value 0.

+

Every instruction consists of four values: an opcode, two inputs (named A and B), and an output (named C), in that order. The opcode specifies the behavior of the instruction and how the inputs are interpreted. The output, C, is always treated as a register.

+

In the opcode descriptions below, if something says "value A", it means to take the number given as A literally. (This is also called an "immediate" value.) If something says "register A", it means to use the number given as A to read from (or write to) the register with that number. So, if the opcode addi adds register A and value B, storing the result in register C, and the instruction addi 0 7 3 is encountered, it would add 7 to the value contained by register 0 and store the sum in register 3, never modifying registers 0, 1, or 2 in the process.

+

Many opcodes are similar except for how they interpret their arguments. The opcodes fall into seven general categories:

+

Addition:

+
    +
  • addr (add register) stores into register C the result of adding register A and register B.
  • +
  • addi (add immediate) stores into register C the result of adding register A and value B.
  • +
+

Multiplication:

+
    +
  • mulr (multiply register) stores into register C the result of multiplying register A and register B.
  • +
  • muli (multiply immediate) stores into register C the result of multiplying register A and value B.
  • +
+

Bitwise AND:

+
    +
  • banr (bitwise AND register) stores into register C the result of the bitwise AND of register A and register B.
  • +
  • bani (bitwise AND immediate) stores into register C the result of the bitwise AND of register A and value B.
  • +
+

Bitwise OR:

+
    +
  • borr (bitwise OR register) stores into register C the result of the bitwise OR of register A and register B.
  • +
  • bori (bitwise OR immediate) stores into register C the result of the bitwise OR of register A and value B.
  • +
+

Assignment:

+
    +
  • setr (set register) copies the contents of register A into register C. (Input B is ignored.)
  • +
  • seti (set immediate) stores value A into register C. (Input B is ignored.)
  • +
+

Greater-than testing:

+
    +
  • gtir (greater-than immediate/register) sets register C to 1 if value A is greater than register B. Otherwise, register C is set to 0.
  • +
  • gtri (greater-than register/immediate) sets register C to 1 if register A is greater than value B. Otherwise, register C is set to 0.
  • +
  • gtrr (greater-than register/register) sets register C to 1 if register A is greater than register B. Otherwise, register C is set to 0.
  • +
+

Equality testing:

+
    +
  • eqir (equal immediate/register) sets register C to 1 if value A is equal to register B. Otherwise, register C is set to 0.
  • +
  • eqri (equal register/immediate) sets register C to 1 if register A is equal to value B. Otherwise, register C is set to 0.
  • +
  • eqrr (equal register/register) sets register C to 1 if register A is equal to register B. Otherwise, register C is set to 0.
  • +
+

Unfortunately, while the manual gives the name of each opcode, it doesn't seem to indicate the number. However, you can monitor the CPU to see the contents of the registers before and after instructions are executed to try to work them out. Each opcode has a number from 0 through 15, but the manual doesn't say which is which. For example, suppose you capture the following sample:

+
Before: [3, 2, 1, 1]
+9 2 1 2
+After:  [3, 2, 2, 1]
+
+

This sample shows the effect of the instruction 9 2 1 2 on the registers. Before the instruction is executed, register 0 has value 3, register 1 has value 2, and registers 2 and 3 have value 1. After the instruction is executed, register 2's value becomes 2.

+

The instruction itself, 9 2 1 2, means that opcode 9 was executed with A=2, B=1, and C=2. Opcode 9 could be any of the 16 opcodes listed above, but only three of them behave in a way that would cause the result shown in the sample:

+
    +
  • Opcode 9 could be mulr: register 2 (which has a value of 1) times register 1 (which has a value of 2) produces 2, which matches the value stored in the output register, register 2.
  • +
  • Opcode 9 could be addi: register 2 (which has a value of 1) plus value 1 produces 2, which matches the value stored in the output register, register 2.
  • +
  • Opcode 9 could be seti: value 2 matches the value stored in the output register, register 2; the number given for B is irrelevant.
  • +
+

None of the other opcodes produce the result captured in the sample. Because of this, the sample above behaves like three opcodes.

+

You collect many of these samples (the first section of your puzzle input). The manual also includes a small test program (the second section of your puzzle input) - you can ignore it for now.

+

Ignoring the opcode numbers, how many samples in your puzzle input behave like three or more opcodes?

+
+

Your puzzle answer was 580.

--- Part Two ---

Using the samples you collected, work out the number of each opcode and execute the test program (the second section of your puzzle input).

+

What value is contained in register 0 after executing the test program?

+
+

Your puzzle answer was 537.

Both parts of this puzzle are complete! They provide two gold stars: **

+

At this point, you should return to your advent calendar and try another puzzle.

+

If you still want to see it, you can get your puzzle input.

+

You can also this puzzle.

+
+ + + + + + \ No newline at end of file diff --git a/src/advent16/advent16.hs b/src/advent16/advent16.hs new file mode 100644 index 0000000..b7745a9 --- /dev/null +++ b/src/advent16/advent16.hs @@ -0,0 +1,151 @@ +{-# LANGUAGE OverloadedStrings #-} + +import Data.Text (Text) +import qualified Data.Text as T +import qualified Data.Text.IO as TIO + +import Data.Void (Void) + +import Text.Megaparsec +import Text.Megaparsec.Char +import qualified Text.Megaparsec.Char.Lexer as L +import qualified Control.Applicative as CA + +import Data.List +import qualified Data.Set as S + +import qualified Data.Map.Strict as M +import Data.Map.Strict ((!)) +import Data.Bits ((.&.), (.|.)) + +type Memory = M.Map Int Int +data Operation = + Addr + | Addi + | Mulr + | Muli + | Banr + | Bani + | Borr + | Bori + | Setr + | Seti + | Gtir + | Gtri + | Gtrr + | Eqir + | Eqri + | Eqrr + deriving (Eq, Show, Enum, Bounded, Ord) +data RawOperation = RawOperation {_opcode :: Int, _a :: Int, _b :: Int, _c :: Int} deriving (Eq, Show) +data Test = Test {_preMemory :: Memory, _testOperation :: RawOperation, _postMemory :: Memory} deriving (Eq, Show) +type Candidates = M.Map Int (S.Set Operation) +type OpcodeAssignments = M.Map Int Operation + +main :: IO () +main = do + text <- TIO.readFile "data/advent16.txt" + let (tests, program) = successfulParse text + print $ part1 tests + print $ part2 tests program + +part1 :: [Test] -> Int +part1 = length . filter (>= 3) . map S.size . map matches + +part2 :: [Test] -> [RawOperation] -> Int +part2 tests program = finalMemory!0 + where candidates = candidateOpcodes tests + opcodes = findOpcodes candidates + finalMemory = foldl' (\m op -> execute op opcodes m) (M.singleton 0 0) program + + +execute :: RawOperation -> OpcodeAssignments -> Memory -> Memory +execute op codes m = perform o (_a op) (_b op) (_c op) m + where o = codes!(_opcode op) + +perform :: Operation -> Int -> Int -> Int -> Memory -> Memory +perform Addr a b c memory = M.insert c (memory!a + memory!b) memory +perform Addi a b c memory = M.insert c (memory!a + b) memory +perform Mulr a b c memory = M.insert c (memory!a * memory!b) memory +perform Muli a b c memory = M.insert c (memory!a * b) memory +perform Banr a b c memory = M.insert c (memory!a .&. memory!b) memory +perform Bani a b c memory = M.insert c (memory!a .&. b) memory +perform Borr a b c memory = M.insert c (memory!a .|. memory!b) memory +perform Bori a b c memory = M.insert c (memory!a .|. b) memory +perform Setr a b c memory = M.insert c (memory!a) memory +perform Seti a b c memory = M.insert c a memory +perform Gtir a b c memory = M.insert c (if a > (memory!b) then 1 else 0) memory +perform Gtri a b c memory = M.insert c (if (memory!a) > b then 1 else 0) memory +perform Gtrr a b c memory = M.insert c (if (memory!a) > (memory!b) then 1 else 0) memory +perform Eqir a b c memory = M.insert c (if a == memory!b then 1 else 0) memory +perform Eqri a b c memory = M.insert c (if (memory!a) == b then 1 else 0) memory +perform Eqrr a b c memory = M.insert c (if (memory!a) == (memory!b) then 1 else 0) memory + +doTest :: Test -> Operation -> Bool +doTest test operation = calculatedMemory == (_postMemory test) + where rawOp = _testOperation test + calculatedMemory = perform operation (_a rawOp) (_b rawOp) (_c rawOp) (_preMemory test) + +matches :: Test -> S.Set Operation +matches test = S.fromList $ filter (doTest test) [minBound..maxBound] + + + +candidateOpcodes :: [Test] -> Candidates +candidateOpcodes tests = foldl' restrict M.empty tests + +restrict :: Candidates -> Test -> Candidates +restrict candidates test = M.insertWith S.intersection opcode possibles candidates + where opcode = _opcode $ _testOperation test + possibles = matches test + +findOpcodes :: Candidates -> OpcodeAssignments +findOpcodes candidates = findOpcodes' candidates M.empty + +findOpcodes' :: Candidates -> OpcodeAssignments -> OpcodeAssignments +findOpcodes' candidates assignments + | M.null candidates = assignments + | otherwise = findOpcodes' candidates'' assignments' + where singletons = M.map S.findMin $ M.filter (\c -> S.size c == 1) candidates + assignments' = assignments `M.union` singletons + candidates' = candidates `M.difference` singletons + founds = S.fromList $ M.elems assignments + candidates'' = M.map (\cs -> S.filter (\c -> c `S.notMember` founds) cs) candidates' + + +-- allOps :: S.Set Operation +-- allOps = S.fromList [minBound..maxBound] + +-- Parse the input file + +type Parser = Parsec Void Text + +sc :: Parser () +sc = L.space (skipSome spaceChar) CA.empty CA.empty + +lexeme = L.lexeme sc +integer = lexeme L.decimal +symb = L.symbol sc + +memoryP = (M.fromList . zip [0..] . map fromIntegral) <$> between (symb "[") (symb "]") (integer `sepBy` (symb ",")) + +beforeP = symb "Before:" *> memoryP +afterP = symb "After:" *> memoryP + +rawOpP = opify <$> integer <*> integer <*> integer <*> integer + where opify o a b c = RawOperation { _opcode = fromIntegral o + , _a = fromIntegral a + , _b = fromIntegral b + , _c = fromIntegral c + } + +testP = testify <$> beforeP <*> rawOpP <*> afterP + where testify b o a = Test {_preMemory = b, _testOperation = o, _postMemory = a} + +fileP = (,) <$> (many testP) <*> (many rawOpP) + +successfulParse :: Text -> ([Test], [RawOperation]) +successfulParse input = + case parse fileP "input" input of + Left _error -> ([], []) -- TIO.putStr $ T.pack $ parseErrorPretty err + Right world -> world \ No newline at end of file -- 2.34.1