diff options
-rw-r--r-- | 2018/input/16.txt | 4024 | ||||
-rw-r--r-- | 2018/src/day16.rs | 191 | ||||
-rw-r--r-- | 2018/src/main.rs | 4 |
3 files changed, 4218 insertions, 1 deletions
diff --git a/2018/input/16.txt b/2018/input/16.txt new file mode 100644 index 0000000..0f7f4d1 --- /dev/null +++ b/2018/input/16.txt @@ -0,0 +1,4024 @@ +Before: [3, 0, 1, 3] +15 2 1 3 +After: [3, 0, 1, 1] + +Before: [1, 3, 2, 0] +11 2 2 0 +After: [4, 3, 2, 0] + +Before: [0, 3, 3, 1] +14 3 2 0 +After: [3, 3, 3, 1] + +Before: [2, 3, 1, 3] +9 2 1 1 +After: [2, 1, 1, 3] + +Before: [1, 2, 3, 0] +0 2 1 2 +After: [1, 2, 2, 0] + +Before: [3, 2, 1, 3] +8 2 3 2 +After: [3, 2, 3, 3] + +Before: [1, 0, 1, 3] +15 2 1 2 +After: [1, 0, 1, 3] + +Before: [0, 0, 1, 1] +15 3 1 1 +After: [0, 1, 1, 1] + +Before: [1, 3, 2, 3] +9 0 1 0 +After: [1, 3, 2, 3] + +Before: [1, 0, 0, 1] +15 3 1 1 +After: [1, 1, 0, 1] + +Before: [0, 2, 2, 0] +4 0 1 3 +After: [0, 2, 2, 1] + +Before: [0, 0, 3, 1] +5 0 2 0 +After: [0, 0, 3, 1] + +Before: [0, 1, 0, 2] +14 3 1 0 +After: [3, 1, 0, 2] + +Before: [0, 2, 2, 0] +5 0 2 3 +After: [0, 2, 2, 0] + +Before: [1, 1, 2, 3] +10 3 2 0 +After: [2, 1, 2, 3] + +Before: [1, 2, 3, 2] +13 0 1 1 +After: [1, 2, 3, 2] + +Before: [0, 3, 2, 0] +1 1 2 1 +After: [0, 6, 2, 0] + +Before: [1, 2, 2, 3] +1 0 2 1 +After: [1, 2, 2, 3] + +Before: [3, 1, 2, 2] +13 0 3 2 +After: [3, 1, 6, 2] + +Before: [3, 3, 2, 1] +14 3 2 3 +After: [3, 3, 2, 3] + +Before: [0, 3, 1, 0] +5 0 1 0 +After: [0, 3, 1, 0] + +Before: [1, 0, 2, 3] +12 0 1 0 +After: [1, 0, 2, 3] + +Before: [3, 0, 2, 2] +3 2 2 0 +After: [2, 0, 2, 2] + +Before: [0, 1, 1, 3] +6 0 0 1 +After: [0, 0, 1, 3] + +Before: [0, 0, 2, 2] +6 0 0 2 +After: [0, 0, 0, 2] + +Before: [2, 3, 1, 3] +9 2 1 0 +After: [1, 3, 1, 3] + +Before: [3, 0, 1, 1] +15 2 1 1 +After: [3, 1, 1, 1] + +Before: [1, 2, 1, 2] +8 0 3 1 +After: [1, 3, 1, 2] + +Before: [3, 2, 3, 2] +13 0 3 2 +After: [3, 2, 6, 2] + +Before: [0, 0, 0, 2] +6 0 0 1 +After: [0, 0, 0, 2] + +Before: [1, 2, 3, 3] +1 1 2 3 +After: [1, 2, 3, 4] + +Before: [3, 1, 2, 2] +10 0 2 3 +After: [3, 1, 2, 2] + +Before: [0, 2, 3, 3] +5 0 2 3 +After: [0, 2, 3, 0] + +Before: [1, 0, 3, 0] +10 2 2 2 +After: [1, 0, 2, 0] + +Before: [1, 0, 3, 3] +12 0 1 1 +After: [1, 1, 3, 3] + +Before: [0, 1, 3, 2] +6 0 0 1 +After: [0, 0, 3, 2] + +Before: [2, 1, 2, 2] +2 2 3 0 +After: [3, 1, 2, 2] + +Before: [1, 2, 1, 0] +4 1 1 0 +After: [3, 2, 1, 0] + +Before: [3, 1, 0, 3] +7 2 1 0 +After: [1, 1, 0, 3] + +Before: [0, 2, 0, 2] +6 0 0 3 +After: [0, 2, 0, 0] + +Before: [0, 0, 1, 3] +5 0 3 1 +After: [0, 0, 1, 3] + +Before: [1, 3, 2, 0] +10 1 2 2 +After: [1, 3, 2, 0] + +Before: [1, 0, 3, 3] +3 3 1 2 +After: [1, 0, 3, 3] + +Before: [0, 1, 1, 3] +6 0 0 2 +After: [0, 1, 0, 3] + +Before: [2, 0, 3, 1] +0 2 0 2 +After: [2, 0, 2, 1] + +Before: [1, 1, 0, 2] +7 2 1 0 +After: [1, 1, 0, 2] + +Before: [2, 1, 3, 3] +0 2 0 1 +After: [2, 2, 3, 3] + +Before: [0, 2, 2, 1] +6 0 0 0 +After: [0, 2, 2, 1] + +Before: [1, 0, 1, 0] +15 2 1 1 +After: [1, 1, 1, 0] + +Before: [2, 3, 0, 0] +4 2 3 0 +After: [3, 3, 0, 0] + +Before: [3, 1, 1, 2] +13 0 3 3 +After: [3, 1, 1, 6] + +Before: [2, 3, 2, 1] +11 0 2 1 +After: [2, 4, 2, 1] + +Before: [0, 0, 2, 1] +4 0 3 1 +After: [0, 3, 2, 1] + +Before: [2, 3, 1, 2] +13 1 3 3 +After: [2, 3, 1, 6] + +Before: [1, 3, 3, 2] +9 0 1 1 +After: [1, 1, 3, 2] + +Before: [2, 0, 3, 2] +13 2 3 0 +After: [6, 0, 3, 2] + +Before: [0, 0, 2, 0] +3 2 2 2 +After: [0, 0, 2, 0] + +Before: [2, 2, 3, 3] +0 2 1 3 +After: [2, 2, 3, 2] + +Before: [1, 0, 3, 2] +8 0 3 0 +After: [3, 0, 3, 2] + +Before: [0, 2, 3, 2] +6 0 0 1 +After: [0, 0, 3, 2] + +Before: [0, 0, 2, 0] +6 0 0 0 +After: [0, 0, 2, 0] + +Before: [0, 2, 3, 1] +0 2 1 3 +After: [0, 2, 3, 2] + +Before: [1, 2, 1, 2] +4 1 1 0 +After: [3, 2, 1, 2] + +Before: [2, 1, 1, 2] +2 0 3 0 +After: [3, 1, 1, 2] + +Before: [0, 2, 1, 3] +6 0 0 2 +After: [0, 2, 0, 3] + +Before: [1, 0, 0, 1] +15 3 1 2 +After: [1, 0, 1, 1] + +Before: [2, 3, 3, 0] +10 2 2 1 +After: [2, 2, 3, 0] + +Before: [0, 1, 3, 1] +10 2 2 3 +After: [0, 1, 3, 2] + +Before: [0, 0, 0, 2] +6 0 0 2 +After: [0, 0, 0, 2] + +Before: [1, 2, 2, 1] +8 0 2 2 +After: [1, 2, 3, 1] + +Before: [2, 3, 3, 3] +0 2 0 0 +After: [2, 3, 3, 3] + +Before: [0, 3, 1, 2] +9 2 1 2 +After: [0, 3, 1, 2] + +Before: [0, 1, 2, 3] +5 0 2 1 +After: [0, 0, 2, 3] + +Before: [0, 3, 0, 3] +6 0 0 0 +After: [0, 3, 0, 3] + +Before: [0, 2, 2, 1] +13 3 1 2 +After: [0, 2, 2, 1] + +Before: [1, 3, 1, 3] +3 3 1 0 +After: [3, 3, 1, 3] + +Before: [3, 3, 2, 3] +10 1 2 2 +After: [3, 3, 2, 3] + +Before: [2, 2, 0, 3] +4 1 1 0 +After: [3, 2, 0, 3] + +Before: [1, 1, 2, 3] +10 3 2 2 +After: [1, 1, 2, 3] + +Before: [0, 2, 2, 1] +11 2 2 3 +After: [0, 2, 2, 4] + +Before: [0, 1, 0, 2] +4 0 2 1 +After: [0, 2, 0, 2] + +Before: [3, 1, 3, 0] +10 2 2 1 +After: [3, 2, 3, 0] + +Before: [3, 3, 1, 1] +9 2 1 3 +After: [3, 3, 1, 1] + +Before: [1, 3, 0, 3] +3 3 3 3 +After: [1, 3, 0, 3] + +Before: [3, 0, 2, 1] +8 1 2 2 +After: [3, 0, 2, 1] + +Before: [1, 0, 1, 3] +3 3 1 2 +After: [1, 0, 3, 3] + +Before: [3, 2, 3, 2] +1 1 2 1 +After: [3, 4, 3, 2] + +Before: [1, 0, 0, 1] +12 0 1 3 +After: [1, 0, 0, 1] + +Before: [3, 0, 2, 3] +1 3 3 2 +After: [3, 0, 9, 3] + +Before: [3, 2, 3, 2] +13 2 3 3 +After: [3, 2, 3, 6] + +Before: [0, 0, 3, 3] +1 3 3 1 +After: [0, 9, 3, 3] + +Before: [0, 2, 1, 3] +1 1 3 3 +After: [0, 2, 1, 6] + +Before: [3, 1, 2, 3] +10 3 2 3 +After: [3, 1, 2, 2] + +Before: [1, 3, 2, 0] +9 0 1 1 +After: [1, 1, 2, 0] + +Before: [1, 0, 3, 1] +12 0 1 3 +After: [1, 0, 3, 1] + +Before: [0, 2, 2, 3] +11 1 2 1 +After: [0, 4, 2, 3] + +Before: [2, 0, 3, 0] +10 2 2 1 +After: [2, 2, 3, 0] + +Before: [2, 1, 1, 2] +8 1 3 3 +After: [2, 1, 1, 3] + +Before: [0, 0, 0, 0] +6 0 0 3 +After: [0, 0, 0, 0] + +Before: [0, 0, 1, 0] +6 0 0 3 +After: [0, 0, 1, 0] + +Before: [0, 1, 1, 0] +4 2 2 0 +After: [3, 1, 1, 0] + +Before: [1, 0, 2, 1] +12 0 1 0 +After: [1, 0, 2, 1] + +Before: [2, 3, 1, 3] +3 3 1 1 +After: [2, 3, 1, 3] + +Before: [1, 0, 0, 3] +3 3 1 0 +After: [3, 0, 0, 3] + +Before: [0, 3, 3, 3] +4 0 1 0 +After: [1, 3, 3, 3] + +Before: [1, 3, 2, 0] +3 2 2 3 +After: [1, 3, 2, 2] + +Before: [3, 1, 0, 2] +14 3 1 0 +After: [3, 1, 0, 2] + +Before: [0, 2, 3, 3] +0 2 1 1 +After: [0, 2, 3, 3] + +Before: [3, 2, 3, 2] +10 2 2 3 +After: [3, 2, 3, 2] + +Before: [1, 1, 2, 1] +8 2 1 3 +After: [1, 1, 2, 3] + +Before: [0, 3, 2, 3] +10 3 2 2 +After: [0, 3, 2, 3] + +Before: [0, 3, 1, 0] +6 0 0 2 +After: [0, 3, 0, 0] + +Before: [3, 0, 1, 1] +15 3 1 0 +After: [1, 0, 1, 1] + +Before: [1, 2, 3, 3] +0 2 1 1 +After: [1, 2, 3, 3] + +Before: [0, 0, 3, 1] +10 2 2 0 +After: [2, 0, 3, 1] + +Before: [0, 1, 3, 1] +6 0 0 1 +After: [0, 0, 3, 1] + +Before: [0, 2, 0, 1] +6 0 0 1 +After: [0, 0, 0, 1] + +Before: [1, 0, 2, 1] +15 3 1 2 +After: [1, 0, 1, 1] + +Before: [1, 2, 0, 3] +13 0 1 2 +After: [1, 2, 2, 3] + +Before: [1, 0, 2, 0] +12 0 1 2 +After: [1, 0, 1, 0] + +Before: [3, 3, 0, 2] +13 0 3 0 +After: [6, 3, 0, 2] + +Before: [1, 2, 2, 1] +11 1 2 1 +After: [1, 4, 2, 1] + +Before: [0, 3, 3, 0] +5 0 1 1 +After: [0, 0, 3, 0] + +Before: [1, 1, 2, 2] +14 3 1 0 +After: [3, 1, 2, 2] + +Before: [0, 2, 2, 2] +11 1 2 3 +After: [0, 2, 2, 4] + +Before: [2, 1, 3, 3] +1 3 3 1 +After: [2, 9, 3, 3] + +Before: [0, 2, 3, 0] +2 1 3 3 +After: [0, 2, 3, 3] + +Before: [1, 2, 0, 2] +4 1 1 1 +After: [1, 3, 0, 2] + +Before: [1, 0, 0, 1] +12 0 1 0 +After: [1, 0, 0, 1] + +Before: [1, 1, 0, 0] +7 3 1 2 +After: [1, 1, 1, 0] + +Before: [2, 1, 0, 0] +7 3 1 1 +After: [2, 1, 0, 0] + +Before: [2, 3, 0, 3] +3 3 1 0 +After: [3, 3, 0, 3] + +Before: [2, 0, 2, 1] +14 3 2 3 +After: [2, 0, 2, 3] + +Before: [2, 3, 2, 3] +11 0 2 2 +After: [2, 3, 4, 3] + +Before: [2, 0, 2, 1] +11 0 2 3 +After: [2, 0, 2, 4] + +Before: [3, 3, 3, 2] +13 2 3 0 +After: [6, 3, 3, 2] + +Before: [2, 2, 2, 1] +3 2 2 2 +After: [2, 2, 2, 1] + +Before: [0, 1, 2, 3] +10 3 2 3 +After: [0, 1, 2, 2] + +Before: [0, 3, 2, 3] +5 0 2 1 +After: [0, 0, 2, 3] + +Before: [1, 0, 0, 2] +12 0 1 3 +After: [1, 0, 0, 1] + +Before: [2, 1, 0, 1] +7 2 1 2 +After: [2, 1, 1, 1] + +Before: [2, 0, 2, 1] +15 3 1 3 +After: [2, 0, 2, 1] + +Before: [3, 2, 2, 1] +11 1 2 1 +After: [3, 4, 2, 1] + +Before: [0, 1, 1, 2] +14 3 1 0 +After: [3, 1, 1, 2] + +Before: [2, 2, 1, 2] +2 1 3 1 +After: [2, 3, 1, 2] + +Before: [1, 1, 2, 0] +1 0 3 1 +After: [1, 3, 2, 0] + +Before: [0, 0, 2, 2] +8 1 2 3 +After: [0, 0, 2, 2] + +Before: [1, 0, 3, 0] +12 0 1 3 +After: [1, 0, 3, 1] + +Before: [3, 0, 1, 2] +15 2 1 1 +After: [3, 1, 1, 2] + +Before: [0, 3, 1, 3] +6 0 0 1 +After: [0, 0, 1, 3] + +Before: [0, 1, 2, 0] +5 0 2 1 +After: [0, 0, 2, 0] + +Before: [0, 0, 3, 0] +6 0 0 2 +After: [0, 0, 0, 0] + +Before: [1, 1, 2, 0] +7 3 1 2 +After: [1, 1, 1, 0] + +Before: [0, 2, 2, 2] +11 2 2 0 +After: [4, 2, 2, 2] + +Before: [0, 2, 1, 3] +3 3 0 0 +After: [3, 2, 1, 3] + +Before: [1, 2, 3, 1] +0 2 1 3 +After: [1, 2, 3, 2] + +Before: [2, 1, 0, 2] +7 2 1 3 +After: [2, 1, 0, 1] + +Before: [3, 0, 1, 2] +13 0 3 0 +After: [6, 0, 1, 2] + +Before: [2, 2, 3, 2] +0 2 0 3 +After: [2, 2, 3, 2] + +Before: [0, 2, 1, 3] +5 0 3 1 +After: [0, 0, 1, 3] + +Before: [2, 1, 2, 0] +8 3 2 0 +After: [2, 1, 2, 0] + +Before: [2, 2, 0, 1] +9 3 1 2 +After: [2, 2, 1, 1] + +Before: [1, 1, 1, 0] +1 2 3 1 +After: [1, 3, 1, 0] + +Before: [2, 0, 2, 0] +5 1 0 3 +After: [2, 0, 2, 0] + +Before: [0, 2, 1, 2] +6 0 0 1 +After: [0, 0, 1, 2] + +Before: [0, 1, 1, 2] +6 0 0 3 +After: [0, 1, 1, 0] + +Before: [3, 0, 3, 3] +10 2 2 0 +After: [2, 0, 3, 3] + +Before: [0, 3, 2, 2] +1 1 2 2 +After: [0, 3, 6, 2] + +Before: [3, 3, 2, 0] +10 1 2 3 +After: [3, 3, 2, 2] + +Before: [2, 3, 1, 3] +8 2 3 2 +After: [2, 3, 3, 3] + +Before: [1, 0, 0, 1] +12 0 1 1 +After: [1, 1, 0, 1] + +Before: [1, 0, 0, 2] +12 0 1 0 +After: [1, 0, 0, 2] + +Before: [1, 3, 1, 2] +13 1 3 0 +After: [6, 3, 1, 2] + +Before: [3, 1, 0, 2] +7 2 1 2 +After: [3, 1, 1, 2] + +Before: [3, 0, 1, 1] +5 1 0 2 +After: [3, 0, 0, 1] + +Before: [3, 1, 2, 0] +11 2 2 2 +After: [3, 1, 4, 0] + +Before: [3, 3, 3, 2] +0 2 3 2 +After: [3, 3, 2, 2] + +Before: [1, 3, 3, 3] +10 2 2 1 +After: [1, 2, 3, 3] + +Before: [0, 0, 1, 0] +15 2 1 1 +After: [0, 1, 1, 0] + +Before: [3, 2, 1, 1] +9 3 1 3 +After: [3, 2, 1, 1] + +Before: [0, 3, 1, 0] +9 2 1 2 +After: [0, 3, 1, 0] + +Before: [0, 1, 3, 3] +10 2 2 3 +After: [0, 1, 3, 2] + +Before: [1, 2, 1, 0] +2 1 3 3 +After: [1, 2, 1, 3] + +Before: [0, 1, 3, 2] +14 3 1 0 +After: [3, 1, 3, 2] + +Before: [3, 1, 2, 0] +1 1 2 1 +After: [3, 2, 2, 0] + +Before: [1, 0, 0, 0] +12 0 1 3 +After: [1, 0, 0, 1] + +Before: [0, 1, 2, 1] +1 1 3 1 +After: [0, 3, 2, 1] + +Before: [3, 2, 2, 1] +11 2 2 3 +After: [3, 2, 2, 4] + +Before: [3, 0, 2, 0] +8 1 2 1 +After: [3, 2, 2, 0] + +Before: [1, 0, 1, 3] +15 2 1 0 +After: [1, 0, 1, 3] + +Before: [0, 2, 2, 2] +8 0 2 2 +After: [0, 2, 2, 2] + +Before: [3, 0, 2, 1] +11 2 2 2 +After: [3, 0, 4, 1] + +Before: [3, 2, 3, 1] +14 3 2 2 +After: [3, 2, 3, 1] + +Before: [0, 2, 1, 1] +6 0 0 1 +After: [0, 0, 1, 1] + +Before: [3, 2, 0, 1] +9 3 1 2 +After: [3, 2, 1, 1] + +Before: [2, 0, 3, 1] +15 3 1 3 +After: [2, 0, 3, 1] + +Before: [0, 1, 0, 3] +6 0 0 3 +After: [0, 1, 0, 0] + +Before: [1, 0, 2, 3] +1 0 2 1 +After: [1, 2, 2, 3] + +Before: [1, 3, 3, 2] +0 2 3 2 +After: [1, 3, 2, 2] + +Before: [0, 0, 1, 3] +6 0 0 3 +After: [0, 0, 1, 0] + +Before: [3, 3, 2, 0] +11 2 2 0 +After: [4, 3, 2, 0] + +Before: [0, 0, 0, 3] +4 0 2 2 +After: [0, 0, 2, 3] + +Before: [0, 3, 2, 2] +11 2 2 0 +After: [4, 3, 2, 2] + +Before: [2, 3, 1, 3] +1 3 3 0 +After: [9, 3, 1, 3] + +Before: [2, 0, 3, 3] +0 2 0 2 +After: [2, 0, 2, 3] + +Before: [2, 3, 0, 2] +4 2 3 2 +After: [2, 3, 3, 2] + +Before: [0, 2, 3, 3] +5 0 1 2 +After: [0, 2, 0, 3] + +Before: [1, 0, 3, 1] +10 2 2 2 +After: [1, 0, 2, 1] + +Before: [2, 0, 0, 3] +1 0 3 3 +After: [2, 0, 0, 6] + +Before: [1, 3, 3, 0] +9 0 1 1 +After: [1, 1, 3, 0] + +Before: [0, 3, 1, 2] +6 0 0 3 +After: [0, 3, 1, 0] + +Before: [0, 0, 2, 0] +11 2 2 2 +After: [0, 0, 4, 0] + +Before: [2, 1, 3, 2] +13 2 3 0 +After: [6, 1, 3, 2] + +Before: [1, 0, 3, 2] +12 0 1 2 +After: [1, 0, 1, 2] + +Before: [3, 1, 3, 2] +13 2 3 3 +After: [3, 1, 3, 6] + +Before: [0, 3, 2, 0] +4 0 1 3 +After: [0, 3, 2, 1] + +Before: [3, 3, 2, 2] +10 0 2 2 +After: [3, 3, 2, 2] + +Before: [0, 2, 2, 0] +8 0 2 1 +After: [0, 2, 2, 0] + +Before: [0, 0, 0, 3] +5 0 3 2 +After: [0, 0, 0, 3] + +Before: [2, 2, 3, 1] +0 2 0 2 +After: [2, 2, 2, 1] + +Before: [1, 0, 2, 1] +14 3 2 3 +After: [1, 0, 2, 3] + +Before: [1, 0, 2, 2] +12 0 1 0 +After: [1, 0, 2, 2] + +Before: [3, 0, 3, 0] +10 2 2 3 +After: [3, 0, 3, 2] + +Before: [0, 1, 0, 1] +7 2 1 0 +After: [1, 1, 0, 1] + +Before: [0, 1, 0, 0] +7 2 1 3 +After: [0, 1, 0, 1] + +Before: [1, 1, 0, 3] +1 3 3 1 +After: [1, 9, 0, 3] + +Before: [3, 0, 1, 0] +15 2 1 1 +After: [3, 1, 1, 0] + +Before: [0, 3, 0, 3] +5 0 3 0 +After: [0, 3, 0, 3] + +Before: [3, 1, 0, 1] +7 2 1 3 +After: [3, 1, 0, 1] + +Before: [0, 3, 3, 1] +5 0 3 2 +After: [0, 3, 0, 1] + +Before: [1, 1, 2, 1] +14 3 2 3 +After: [1, 1, 2, 3] + +Before: [1, 2, 2, 0] +11 1 2 1 +After: [1, 4, 2, 0] + +Before: [2, 2, 1, 3] +1 1 3 2 +After: [2, 2, 6, 3] + +Before: [0, 2, 1, 0] +6 0 0 0 +After: [0, 2, 1, 0] + +Before: [0, 0, 3, 3] +6 0 0 3 +After: [0, 0, 3, 0] + +Before: [0, 0, 3, 1] +14 3 2 0 +After: [3, 0, 3, 1] + +Before: [0, 0, 2, 1] +6 0 0 2 +After: [0, 0, 0, 1] + +Before: [1, 0, 2, 1] +14 3 2 2 +After: [1, 0, 3, 1] + +Before: [0, 2, 2, 1] +11 2 2 0 +After: [4, 2, 2, 1] + +Before: [3, 0, 3, 3] +10 2 2 1 +After: [3, 2, 3, 3] + +Before: [2, 0, 1, 0] +2 0 3 0 +After: [3, 0, 1, 0] + +Before: [3, 3, 2, 3] +3 3 1 0 +After: [3, 3, 2, 3] + +Before: [1, 3, 2, 1] +14 3 2 2 +After: [1, 3, 3, 1] + +Before: [3, 0, 3, 2] +0 2 3 1 +After: [3, 2, 3, 2] + +Before: [0, 0, 0, 1] +15 3 1 2 +After: [0, 0, 1, 1] + +Before: [1, 1, 3, 1] +14 3 2 0 +After: [3, 1, 3, 1] + +Before: [0, 2, 3, 2] +5 0 1 1 +After: [0, 0, 3, 2] + +Before: [3, 1, 3, 3] +1 2 3 3 +After: [3, 1, 3, 9] + +Before: [2, 0, 1, 1] +1 2 3 2 +After: [2, 0, 3, 1] + +Before: [1, 0, 2, 3] +10 3 2 2 +After: [1, 0, 2, 3] + +Before: [0, 2, 1, 2] +4 0 3 2 +After: [0, 2, 3, 2] + +Before: [0, 3, 2, 0] +3 2 0 0 +After: [2, 3, 2, 0] + +Before: [3, 2, 2, 2] +11 1 2 3 +After: [3, 2, 2, 4] + +Before: [1, 0, 1, 2] +15 2 1 3 +After: [1, 0, 1, 1] + +Before: [2, 1, 1, 2] +14 3 1 0 +After: [3, 1, 1, 2] + +Before: [1, 3, 2, 3] +11 2 2 3 +After: [1, 3, 2, 4] + +Before: [0, 2, 2, 1] +3 2 2 3 +After: [0, 2, 2, 2] + +Before: [1, 0, 2, 3] +12 0 1 1 +After: [1, 1, 2, 3] + +Before: [1, 3, 0, 3] +8 2 3 1 +After: [1, 3, 0, 3] + +Before: [0, 2, 2, 3] +10 3 2 2 +After: [0, 2, 2, 3] + +Before: [0, 1, 3, 2] +5 0 3 1 +After: [0, 0, 3, 2] + +Before: [3, 1, 1, 2] +8 1 3 1 +After: [3, 3, 1, 2] + +Before: [2, 3, 1, 3] +1 0 3 2 +After: [2, 3, 6, 3] + +Before: [2, 0, 3, 1] +14 3 2 0 +After: [3, 0, 3, 1] + +Before: [1, 2, 2, 1] +13 0 1 0 +After: [2, 2, 2, 1] + +Before: [1, 2, 3, 3] +10 2 2 2 +After: [1, 2, 2, 3] + +Before: [3, 1, 0, 0] +7 2 1 3 +After: [3, 1, 0, 1] + +Before: [2, 3, 2, 2] +13 1 3 0 +After: [6, 3, 2, 2] + +Before: [0, 1, 3, 3] +10 2 2 2 +After: [0, 1, 2, 3] + +Before: [2, 1, 2, 2] +14 3 1 0 +After: [3, 1, 2, 2] + +Before: [2, 3, 3, 2] +0 2 3 3 +After: [2, 3, 3, 2] + +Before: [2, 3, 0, 1] +4 2 3 1 +After: [2, 3, 0, 1] + +Before: [0, 1, 2, 0] +4 0 3 1 +After: [0, 3, 2, 0] + +Before: [0, 1, 2, 0] +6 0 0 2 +After: [0, 1, 0, 0] + +Before: [2, 1, 0, 2] +2 0 3 3 +After: [2, 1, 0, 3] + +Before: [0, 3, 3, 0] +4 0 2 1 +After: [0, 2, 3, 0] + +Before: [0, 1, 3, 3] +3 3 0 0 +After: [3, 1, 3, 3] + +Before: [3, 1, 1, 0] +7 3 1 0 +After: [1, 1, 1, 0] + +Before: [1, 3, 1, 1] +9 0 1 1 +After: [1, 1, 1, 1] + +Before: [0, 2, 0, 1] +9 3 1 2 +After: [0, 2, 1, 1] + +Before: [0, 0, 2, 3] +11 2 2 3 +After: [0, 0, 2, 4] + +Before: [1, 2, 2, 1] +1 0 2 1 +After: [1, 2, 2, 1] + +Before: [0, 2, 2, 2] +11 3 2 2 +After: [0, 2, 4, 2] + +Before: [0, 1, 1, 0] +7 3 1 3 +After: [0, 1, 1, 1] + +Before: [2, 3, 2, 0] +11 2 2 3 +After: [2, 3, 2, 4] + +Before: [2, 0, 2, 0] +2 0 3 1 +After: [2, 3, 2, 0] + +Before: [0, 3, 3, 3] +6 0 0 0 +After: [0, 3, 3, 3] + +Before: [1, 1, 3, 1] +8 1 2 1 +After: [1, 3, 3, 1] + +Before: [2, 3, 0, 3] +8 2 3 1 +After: [2, 3, 0, 3] + +Before: [2, 2, 3, 2] +0 2 3 2 +After: [2, 2, 2, 2] + +Before: [1, 2, 1, 1] +13 0 1 1 +After: [1, 2, 1, 1] + +Before: [2, 3, 2, 2] +2 2 3 1 +After: [2, 3, 2, 2] + +Before: [0, 1, 2, 0] +3 2 0 2 +After: [0, 1, 2, 0] + +Before: [1, 3, 0, 3] +9 0 1 0 +After: [1, 3, 0, 3] + +Before: [1, 1, 0, 3] +7 2 1 1 +After: [1, 1, 0, 3] + +Before: [1, 0, 2, 1] +12 0 1 1 +After: [1, 1, 2, 1] + +Before: [0, 0, 2, 0] +8 0 2 1 +After: [0, 2, 2, 0] + +Before: [0, 2, 1, 0] +5 0 1 3 +After: [0, 2, 1, 0] + +Before: [1, 2, 3, 0] +8 0 2 0 +After: [3, 2, 3, 0] + +Before: [1, 0, 2, 2] +12 0 1 2 +After: [1, 0, 1, 2] + +Before: [2, 3, 2, 0] +2 2 3 1 +After: [2, 3, 2, 0] + +Before: [1, 3, 3, 2] +13 1 3 1 +After: [1, 6, 3, 2] + +Before: [2, 0, 2, 1] +15 3 1 1 +After: [2, 1, 2, 1] + +Before: [0, 3, 1, 3] +9 2 1 2 +After: [0, 3, 1, 3] + +Before: [3, 3, 1, 0] +4 3 2 1 +After: [3, 2, 1, 0] + +Before: [2, 1, 0, 2] +7 2 1 2 +After: [2, 1, 1, 2] + +Before: [0, 2, 2, 3] +4 0 1 2 +After: [0, 2, 1, 3] + +Before: [2, 0, 2, 1] +5 1 0 0 +After: [0, 0, 2, 1] + +Before: [2, 0, 3, 0] +0 2 0 1 +After: [2, 2, 3, 0] + +Before: [1, 3, 2, 3] +9 0 1 2 +After: [1, 3, 1, 3] + +Before: [3, 1, 1, 3] +3 3 1 2 +After: [3, 1, 3, 3] + +Before: [0, 1, 0, 2] +14 3 1 2 +After: [0, 1, 3, 2] + +Before: [3, 0, 1, 2] +15 2 1 0 +After: [1, 0, 1, 2] + +Before: [2, 2, 2, 3] +10 3 2 0 +After: [2, 2, 2, 3] + +Before: [1, 2, 0, 1] +13 3 1 0 +After: [2, 2, 0, 1] + +Before: [0, 3, 0, 3] +6 0 0 2 +After: [0, 3, 0, 3] + +Before: [0, 2, 2, 1] +14 3 2 3 +After: [0, 2, 2, 3] + +Before: [2, 1, 0, 3] +7 2 1 3 +After: [2, 1, 0, 1] + +Before: [0, 1, 0, 3] +7 2 1 0 +After: [1, 1, 0, 3] + +Before: [3, 0, 2, 3] +1 2 3 1 +After: [3, 6, 2, 3] + +Before: [0, 2, 3, 2] +5 0 3 3 +After: [0, 2, 3, 0] + +Before: [1, 3, 3, 2] +13 1 3 0 +After: [6, 3, 3, 2] + +Before: [1, 1, 1, 3] +1 3 3 2 +After: [1, 1, 9, 3] + +Before: [3, 2, 2, 0] +4 1 1 0 +After: [3, 2, 2, 0] + +Before: [1, 1, 3, 2] +0 2 3 1 +After: [1, 2, 3, 2] + +Before: [1, 0, 2, 0] +12 0 1 1 +After: [1, 1, 2, 0] + +Before: [0, 0, 2, 1] +14 3 2 2 +After: [0, 0, 3, 1] + +Before: [3, 1, 3, 0] +4 3 2 1 +After: [3, 2, 3, 0] + +Before: [2, 0, 0, 3] +1 0 2 0 +After: [4, 0, 0, 3] + +Before: [1, 2, 3, 0] +13 0 1 1 +After: [1, 2, 3, 0] + +Before: [0, 1, 3, 0] +7 3 1 2 +After: [0, 1, 1, 0] + +Before: [0, 1, 2, 0] +2 2 3 0 +After: [3, 1, 2, 0] + +Before: [1, 0, 3, 2] +0 2 3 3 +After: [1, 0, 3, 2] + +Before: [1, 3, 2, 3] +1 1 3 2 +After: [1, 3, 9, 3] + +Before: [1, 0, 2, 3] +12 0 1 3 +After: [1, 0, 2, 1] + +Before: [3, 2, 2, 2] +2 1 3 3 +After: [3, 2, 2, 3] + +Before: [0, 1, 0, 1] +7 2 1 3 +After: [0, 1, 0, 1] + +Before: [3, 0, 2, 3] +10 0 2 0 +After: [2, 0, 2, 3] + +Before: [0, 3, 3, 3] +5 0 3 1 +After: [0, 0, 3, 3] + +Before: [2, 1, 3, 1] +0 2 0 2 +After: [2, 1, 2, 1] + +Before: [2, 1, 2, 1] +3 2 0 2 +After: [2, 1, 2, 1] + +Before: [1, 2, 0, 0] +2 1 3 3 +After: [1, 2, 0, 3] + +Before: [3, 0, 0, 1] +15 3 1 0 +After: [1, 0, 0, 1] + +Before: [2, 2, 3, 0] +10 2 2 2 +After: [2, 2, 2, 0] + +Before: [1, 1, 3, 0] +8 0 2 3 +After: [1, 1, 3, 3] + +Before: [2, 1, 2, 2] +14 3 1 2 +After: [2, 1, 3, 2] + +Before: [3, 1, 2, 2] +11 3 2 3 +After: [3, 1, 2, 4] + +Before: [1, 1, 3, 0] +10 2 2 3 +After: [1, 1, 3, 2] + +Before: [1, 2, 0, 1] +9 3 1 0 +After: [1, 2, 0, 1] + +Before: [1, 3, 3, 2] +13 1 3 2 +After: [1, 3, 6, 2] + +Before: [3, 3, 3, 2] +13 2 3 3 +After: [3, 3, 3, 6] + +Before: [2, 1, 0, 2] +7 2 1 1 +After: [2, 1, 0, 2] + +Before: [3, 2, 3, 1] +0 2 1 2 +After: [3, 2, 2, 1] + +Before: [0, 0, 1, 1] +5 0 3 2 +After: [0, 0, 0, 1] + +Before: [0, 1, 1, 0] +5 0 1 1 +After: [0, 0, 1, 0] + +Before: [3, 1, 0, 1] +7 2 1 0 +After: [1, 1, 0, 1] + +Before: [1, 1, 1, 3] +8 2 3 3 +After: [1, 1, 1, 3] + +Before: [1, 0, 2, 1] +12 0 1 2 +After: [1, 0, 1, 1] + +Before: [2, 2, 1, 0] +2 0 3 3 +After: [2, 2, 1, 3] + +Before: [3, 0, 2, 2] +3 2 2 2 +After: [3, 0, 2, 2] + +Before: [0, 2, 0, 0] +2 1 3 3 +After: [0, 2, 0, 3] + +Before: [2, 2, 2, 1] +14 3 2 1 +After: [2, 3, 2, 1] + +Before: [0, 1, 2, 3] +11 2 2 1 +After: [0, 4, 2, 3] + +Before: [3, 2, 0, 0] +4 1 1 1 +After: [3, 3, 0, 0] + +Before: [1, 1, 3, 3] +8 1 3 1 +After: [1, 3, 3, 3] + +Before: [1, 0, 3, 2] +8 0 2 3 +After: [1, 0, 3, 3] + +Before: [3, 1, 2, 3] +11 2 2 0 +After: [4, 1, 2, 3] + +Before: [3, 1, 2, 1] +10 0 2 1 +After: [3, 2, 2, 1] + +Before: [3, 1, 2, 1] +3 2 2 0 +After: [2, 1, 2, 1] + +Before: [0, 1, 0, 0] +6 0 0 2 +After: [0, 1, 0, 0] + +Before: [1, 0, 1, 2] +8 2 3 0 +After: [3, 0, 1, 2] + +Before: [3, 0, 3, 2] +13 0 3 1 +After: [3, 6, 3, 2] + +Before: [1, 2, 2, 1] +11 1 2 3 +After: [1, 2, 2, 4] + +Before: [0, 2, 0, 3] +6 0 0 3 +After: [0, 2, 0, 0] + +Before: [1, 0, 3, 3] +12 0 1 2 +After: [1, 0, 1, 3] + +Before: [0, 1, 2, 2] +6 0 0 3 +After: [0, 1, 2, 0] + +Before: [2, 2, 0, 0] +2 1 3 3 +After: [2, 2, 0, 3] + +Before: [0, 1, 3, 2] +6 0 0 0 +After: [0, 1, 3, 2] + +Before: [3, 0, 3, 1] +15 3 1 1 +After: [3, 1, 3, 1] + +Before: [0, 0, 2, 1] +14 3 2 3 +After: [0, 0, 2, 3] + +Before: [0, 3, 0, 1] +6 0 0 3 +After: [0, 3, 0, 0] + +Before: [1, 3, 1, 1] +9 2 1 1 +After: [1, 1, 1, 1] + +Before: [1, 0, 1, 0] +12 0 1 3 +After: [1, 0, 1, 1] + +Before: [3, 0, 1, 1] +1 2 3 3 +After: [3, 0, 1, 3] + +Before: [3, 3, 3, 1] +14 3 2 0 +After: [3, 3, 3, 1] + +Before: [2, 2, 1, 1] +9 3 1 3 +After: [2, 2, 1, 1] + +Before: [1, 1, 3, 2] +14 3 1 2 +After: [1, 1, 3, 2] + +Before: [1, 0, 2, 2] +1 0 2 3 +After: [1, 0, 2, 2] + +Before: [1, 2, 3, 3] +4 1 1 1 +After: [1, 3, 3, 3] + +Before: [2, 2, 3, 1] +9 3 1 0 +After: [1, 2, 3, 1] + +Before: [2, 2, 3, 0] +0 2 0 0 +After: [2, 2, 3, 0] + +Before: [0, 1, 3, 1] +10 2 2 1 +After: [0, 2, 3, 1] + +Before: [3, 1, 2, 3] +8 2 1 1 +After: [3, 3, 2, 3] + +Before: [1, 0, 0, 3] +12 0 1 0 +After: [1, 0, 0, 3] + +Before: [1, 0, 1, 0] +12 0 1 1 +After: [1, 1, 1, 0] + +Before: [2, 2, 2, 2] +2 0 3 1 +After: [2, 3, 2, 2] + +Before: [2, 1, 3, 0] +7 3 1 3 +After: [2, 1, 3, 1] + +Before: [3, 2, 2, 0] +11 1 2 2 +After: [3, 2, 4, 0] + +Before: [1, 0, 1, 3] +3 3 0 2 +After: [1, 0, 3, 3] + +Before: [3, 3, 3, 1] +10 2 2 0 +After: [2, 3, 3, 1] + +Before: [2, 0, 1, 1] +15 2 1 0 +After: [1, 0, 1, 1] + +Before: [2, 0, 2, 2] +11 2 2 3 +After: [2, 0, 2, 4] + +Before: [0, 0, 1, 1] +15 3 1 0 +After: [1, 0, 1, 1] + +Before: [3, 2, 3, 0] +2 1 3 3 +After: [3, 2, 3, 3] + +Before: [2, 1, 1, 2] +1 0 2 3 +After: [2, 1, 1, 4] + +Before: [3, 2, 3, 1] +10 2 2 1 +After: [3, 2, 3, 1] + +Before: [2, 2, 3, 2] +13 2 3 0 +After: [6, 2, 3, 2] + +Before: [1, 3, 2, 1] +14 3 2 0 +After: [3, 3, 2, 1] + +Before: [1, 0, 0, 3] +8 0 3 3 +After: [1, 0, 0, 3] + +Before: [3, 1, 1, 2] +14 3 1 2 +After: [3, 1, 3, 2] + +Before: [2, 3, 0, 3] +1 3 3 3 +After: [2, 3, 0, 9] + +Before: [0, 3, 1, 3] +3 3 3 3 +After: [0, 3, 1, 3] + +Before: [0, 2, 0, 1] +9 3 1 0 +After: [1, 2, 0, 1] + +Before: [1, 2, 2, 1] +1 0 2 3 +After: [1, 2, 2, 2] + +Before: [2, 0, 1, 0] +15 2 1 3 +After: [2, 0, 1, 1] + +Before: [0, 1, 2, 3] +10 3 2 2 +After: [0, 1, 2, 3] + +Before: [1, 1, 3, 2] +14 3 1 0 +After: [3, 1, 3, 2] + +Before: [0, 0, 1, 3] +15 2 1 0 +After: [1, 0, 1, 3] + +Before: [0, 1, 0, 1] +5 0 1 0 +After: [0, 1, 0, 1] + +Before: [3, 0, 3, 2] +13 0 3 3 +After: [3, 0, 3, 6] + +Before: [2, 3, 3, 1] +14 3 2 1 +After: [2, 3, 3, 1] + +Before: [3, 0, 3, 1] +15 3 1 0 +After: [1, 0, 3, 1] + +Before: [0, 2, 2, 3] +5 0 1 1 +After: [0, 0, 2, 3] + +Before: [0, 3, 1, 0] +4 0 3 0 +After: [3, 3, 1, 0] + +Before: [1, 0, 2, 3] +12 0 1 2 +After: [1, 0, 1, 3] + +Before: [3, 0, 1, 1] +15 3 1 3 +After: [3, 0, 1, 1] + +Before: [0, 3, 3, 3] +5 0 2 2 +After: [0, 3, 0, 3] + +Before: [2, 0, 0, 3] +4 1 2 3 +After: [2, 0, 0, 2] + +Before: [1, 3, 1, 0] +9 0 1 3 +After: [1, 3, 1, 1] + +Before: [0, 0, 1, 2] +15 2 1 0 +After: [1, 0, 1, 2] + +Before: [1, 0, 0, 3] +8 0 3 0 +After: [3, 0, 0, 3] + +Before: [0, 2, 3, 2] +10 2 2 0 +After: [2, 2, 3, 2] + +Before: [0, 1, 0, 2] +5 0 3 0 +After: [0, 1, 0, 2] + +Before: [0, 0, 3, 0] +5 0 2 0 +After: [0, 0, 3, 0] + +Before: [3, 2, 2, 2] +13 0 3 0 +After: [6, 2, 2, 2] + +Before: [3, 0, 2, 1] +4 2 1 1 +After: [3, 3, 2, 1] + +Before: [1, 3, 3, 1] +9 0 1 2 +After: [1, 3, 1, 1] + +Before: [1, 0, 3, 3] +3 3 0 2 +After: [1, 0, 3, 3] + +Before: [0, 1, 0, 2] +14 3 1 1 +After: [0, 3, 0, 2] + +Before: [0, 0, 2, 3] +4 2 1 3 +After: [0, 0, 2, 3] + +Before: [1, 2, 2, 3] +13 0 1 3 +After: [1, 2, 2, 2] + +Before: [1, 1, 2, 0] +8 0 2 1 +After: [1, 3, 2, 0] + +Before: [0, 0, 2, 2] +6 0 0 1 +After: [0, 0, 2, 2] + +Before: [2, 2, 2, 3] +3 2 2 3 +After: [2, 2, 2, 2] + +Before: [3, 0, 2, 2] +13 0 3 2 +After: [3, 0, 6, 2] + +Before: [0, 2, 0, 2] +5 0 1 3 +After: [0, 2, 0, 0] + +Before: [2, 0, 0, 3] +3 3 3 3 +After: [2, 0, 0, 3] + +Before: [1, 3, 2, 1] +10 1 2 0 +After: [2, 3, 2, 1] + +Before: [0, 1, 3, 2] +0 2 3 0 +After: [2, 1, 3, 2] + +Before: [2, 0, 1, 3] +1 0 3 1 +After: [2, 6, 1, 3] + +Before: [0, 3, 1, 2] +6 0 0 2 +After: [0, 3, 0, 2] + +Before: [3, 1, 3, 0] +10 2 2 2 +After: [3, 1, 2, 0] + +Before: [3, 1, 3, 2] +14 3 1 1 +After: [3, 3, 3, 2] + +Before: [0, 1, 3, 2] +0 2 3 3 +After: [0, 1, 3, 2] + +Before: [0, 1, 2, 1] +11 2 2 3 +After: [0, 1, 2, 4] + +Before: [0, 2, 1, 0] +4 2 2 0 +After: [3, 2, 1, 0] + +Before: [1, 1, 3, 1] +14 3 2 1 +After: [1, 3, 3, 1] + +Before: [3, 3, 3, 3] +1 1 3 3 +After: [3, 3, 3, 9] + +Before: [2, 3, 1, 1] +9 2 1 0 +After: [1, 3, 1, 1] + +Before: [2, 1, 3, 2] +2 0 3 3 +After: [2, 1, 3, 3] + +Before: [0, 1, 0, 2] +8 1 3 3 +After: [0, 1, 0, 3] + +Before: [2, 3, 3, 2] +13 2 3 2 +After: [2, 3, 6, 2] + +Before: [2, 3, 1, 2] +9 2 1 2 +After: [2, 3, 1, 2] + +Before: [3, 2, 2, 0] +2 1 3 2 +After: [3, 2, 3, 0] + +Before: [3, 2, 1, 1] +13 3 1 0 +After: [2, 2, 1, 1] + +Before: [0, 0, 1, 3] +15 2 1 1 +After: [0, 1, 1, 3] + +Before: [1, 3, 2, 1] +9 0 1 0 +After: [1, 3, 2, 1] + +Before: [0, 0, 1, 2] +5 0 2 0 +After: [0, 0, 1, 2] + +Before: [0, 1, 3, 1] +6 0 0 3 +After: [0, 1, 3, 0] + +Before: [3, 1, 3, 0] +7 3 1 2 +After: [3, 1, 1, 0] + +Before: [0, 3, 2, 1] +1 1 2 1 +After: [0, 6, 2, 1] + +Before: [0, 2, 1, 3] +3 3 3 3 +After: [0, 2, 1, 3] + +Before: [0, 0, 3, 3] +5 0 2 2 +After: [0, 0, 0, 3] + +Before: [0, 2, 2, 0] +3 2 2 3 +After: [0, 2, 2, 2] + +Before: [2, 0, 1, 0] +15 2 1 2 +After: [2, 0, 1, 0] + +Before: [3, 2, 2, 3] +3 3 3 0 +After: [3, 2, 2, 3] + +Before: [1, 0, 3, 0] +12 0 1 2 +After: [1, 0, 1, 0] + +Before: [0, 1, 2, 0] +7 3 1 1 +After: [0, 1, 2, 0] + +Before: [2, 0, 3, 1] +0 2 0 1 +After: [2, 2, 3, 1] + +Before: [3, 3, 2, 2] +11 2 2 2 +After: [3, 3, 4, 2] + +Before: [0, 0, 2, 3] +6 0 0 0 +After: [0, 0, 2, 3] + +Before: [0, 3, 0, 2] +6 0 0 2 +After: [0, 3, 0, 2] + +Before: [2, 1, 0, 2] +2 0 3 2 +After: [2, 1, 3, 2] + +Before: [0, 3, 1, 0] +5 0 1 2 +After: [0, 3, 0, 0] + +Before: [3, 1, 1, 1] +1 1 3 2 +After: [3, 1, 3, 1] + +Before: [2, 0, 3, 1] +0 2 0 3 +After: [2, 0, 3, 2] + +Before: [1, 0, 1, 1] +15 3 1 3 +After: [1, 0, 1, 1] + +Before: [1, 0, 2, 1] +12 0 1 3 +After: [1, 0, 2, 1] + +Before: [3, 2, 2, 3] +11 2 2 1 +After: [3, 4, 2, 3] + +Before: [1, 3, 0, 0] +9 0 1 1 +After: [1, 1, 0, 0] + +Before: [2, 1, 2, 0] +7 3 1 0 +After: [1, 1, 2, 0] + +Before: [0, 3, 0, 3] +3 3 1 1 +After: [0, 3, 0, 3] + +Before: [0, 1, 1, 3] +8 2 3 2 +After: [0, 1, 3, 3] + +Before: [2, 1, 0, 3] +7 2 1 1 +After: [2, 1, 0, 3] + +Before: [2, 2, 3, 1] +0 2 1 3 +After: [2, 2, 3, 2] + +Before: [1, 0, 1, 1] +12 0 1 1 +After: [1, 1, 1, 1] + +Before: [0, 3, 1, 0] +9 2 1 3 +After: [0, 3, 1, 1] + +Before: [1, 0, 3, 0] +12 0 1 0 +After: [1, 0, 3, 0] + +Before: [0, 0, 3, 2] +4 0 2 1 +After: [0, 2, 3, 2] + +Before: [0, 0, 1, 1] +15 2 1 2 +After: [0, 0, 1, 1] + +Before: [2, 2, 2, 2] +2 2 3 0 +After: [3, 2, 2, 2] + +Before: [0, 0, 1, 1] +15 3 1 3 +After: [0, 0, 1, 1] + +Before: [1, 0, 3, 3] +3 3 3 1 +After: [1, 3, 3, 3] + +Before: [2, 0, 2, 2] +2 2 3 3 +After: [2, 0, 2, 3] + +Before: [0, 1, 0, 1] +7 2 1 1 +After: [0, 1, 0, 1] + +Before: [0, 2, 3, 1] +10 2 2 3 +After: [0, 2, 3, 2] + +Before: [1, 0, 1, 2] +12 0 1 2 +After: [1, 0, 1, 2] + +Before: [3, 1, 2, 0] +1 1 3 3 +After: [3, 1, 2, 3] + +Before: [0, 3, 1, 0] +9 2 1 0 +After: [1, 3, 1, 0] + +Before: [2, 0, 1, 2] +15 2 1 3 +After: [2, 0, 1, 1] + +Before: [2, 3, 1, 0] +9 2 1 1 +After: [2, 1, 1, 0] + +Before: [1, 0, 0, 0] +12 0 1 1 +After: [1, 1, 0, 0] + +Before: [2, 2, 3, 3] +3 3 3 2 +After: [2, 2, 3, 3] + +Before: [3, 3, 1, 1] +1 2 3 2 +After: [3, 3, 3, 1] + +Before: [3, 3, 2, 2] +13 0 3 0 +After: [6, 3, 2, 2] + +Before: [0, 1, 1, 0] +4 1 2 2 +After: [0, 1, 3, 0] + +Before: [1, 3, 2, 0] +2 2 3 3 +After: [1, 3, 2, 3] + +Before: [0, 3, 1, 1] +9 2 1 1 +After: [0, 1, 1, 1] + +Before: [0, 2, 3, 1] +5 0 1 0 +After: [0, 2, 3, 1] + +Before: [0, 2, 2, 2] +5 0 3 3 +After: [0, 2, 2, 0] + +Before: [0, 3, 3, 3] +10 2 2 2 +After: [0, 3, 2, 3] + +Before: [1, 3, 1, 3] +3 3 1 3 +After: [1, 3, 1, 3] + +Before: [3, 3, 3, 2] +0 2 3 1 +After: [3, 2, 3, 2] + +Before: [3, 3, 0, 1] +4 2 3 0 +After: [3, 3, 0, 1] + +Before: [0, 0, 0, 3] +6 0 0 3 +After: [0, 0, 0, 0] + +Before: [3, 0, 2, 1] +14 3 2 3 +After: [3, 0, 2, 3] + +Before: [1, 0, 3, 2] +13 2 3 2 +After: [1, 0, 6, 2] + +Before: [0, 1, 2, 0] +7 3 1 2 +After: [0, 1, 1, 0] + +Before: [3, 3, 2, 2] +11 3 2 1 +After: [3, 4, 2, 2] + +Before: [2, 2, 2, 3] +1 3 2 3 +After: [2, 2, 2, 6] + +Before: [2, 0, 2, 2] +11 3 2 1 +After: [2, 4, 2, 2] + +Before: [0, 2, 3, 2] +0 2 1 1 +After: [0, 2, 3, 2] + +Before: [1, 0, 2, 0] +12 0 1 3 +After: [1, 0, 2, 1] + +Before: [3, 3, 1, 2] +13 0 3 3 +After: [3, 3, 1, 6] + +Before: [3, 2, 3, 1] +9 3 1 2 +After: [3, 2, 1, 1] + +Before: [2, 2, 2, 0] +11 2 2 3 +After: [2, 2, 2, 4] + +Before: [1, 0, 1, 1] +4 2 2 1 +After: [1, 3, 1, 1] + +Before: [2, 2, 2, 1] +14 3 2 2 +After: [2, 2, 3, 1] + +Before: [1, 1, 2, 2] +11 3 2 0 +After: [4, 1, 2, 2] + +Before: [2, 2, 3, 2] +0 2 0 2 +After: [2, 2, 2, 2] + +Before: [1, 1, 0, 1] +1 1 3 0 +After: [3, 1, 0, 1] + +Before: [2, 3, 1, 0] +2 0 3 3 +After: [2, 3, 1, 3] + +Before: [1, 3, 3, 1] +9 0 1 1 +After: [1, 1, 3, 1] + +Before: [3, 3, 2, 2] +10 1 2 1 +After: [3, 2, 2, 2] + +Before: [0, 2, 3, 0] +0 2 1 2 +After: [0, 2, 2, 0] + +Before: [0, 3, 3, 1] +6 0 0 0 +After: [0, 3, 3, 1] + +Before: [3, 2, 2, 2] +2 2 3 0 +After: [3, 2, 2, 2] + +Before: [1, 0, 0, 2] +12 0 1 1 +After: [1, 1, 0, 2] + +Before: [1, 0, 0, 2] +12 0 1 2 +After: [1, 0, 1, 2] + +Before: [0, 2, 1, 2] +5 0 3 1 +After: [0, 0, 1, 2] + +Before: [0, 0, 3, 3] +5 0 3 2 +After: [0, 0, 0, 3] + +Before: [0, 1, 1, 0] +1 2 3 0 +After: [3, 1, 1, 0] + +Before: [0, 1, 1, 2] +5 0 3 3 +After: [0, 1, 1, 0] + +Before: [3, 3, 2, 0] +10 0 2 0 +After: [2, 3, 2, 0] + +Before: [1, 0, 0, 1] +12 0 1 2 +After: [1, 0, 1, 1] + +Before: [1, 3, 1, 1] +9 0 1 3 +After: [1, 3, 1, 1] + +Before: [1, 0, 2, 1] +14 3 2 1 +After: [1, 3, 2, 1] + +Before: [0, 0, 1, 1] +5 0 2 3 +After: [0, 0, 1, 0] + +Before: [2, 3, 2, 3] +3 3 3 1 +After: [2, 3, 2, 3] + +Before: [1, 2, 2, 0] +2 2 3 3 +After: [1, 2, 2, 3] + +Before: [3, 3, 1, 0] +9 2 1 1 +After: [3, 1, 1, 0] + +Before: [1, 0, 3, 3] +12 0 1 0 +After: [1, 0, 3, 3] + +Before: [3, 0, 3, 0] +10 2 2 2 +After: [3, 0, 2, 0] + +Before: [2, 2, 3, 2] +0 2 3 0 +After: [2, 2, 3, 2] + +Before: [2, 0, 0, 2] +2 0 3 2 +After: [2, 0, 3, 2] + +Before: [2, 1, 2, 3] +11 2 2 2 +After: [2, 1, 4, 3] + +Before: [3, 3, 2, 2] +2 2 3 1 +After: [3, 3, 2, 2] + +Before: [0, 0, 2, 1] +11 2 2 2 +After: [0, 0, 4, 1] + +Before: [0, 3, 3, 1] +14 3 2 1 +After: [0, 3, 3, 1] + +Before: [3, 2, 0, 2] +13 0 3 2 +After: [3, 2, 6, 2] + +Before: [2, 2, 2, 0] +4 2 1 0 +After: [3, 2, 2, 0] + +Before: [3, 0, 1, 1] +15 2 1 3 +After: [3, 0, 1, 1] + +Before: [2, 1, 3, 2] +0 2 0 1 +After: [2, 2, 3, 2] + +Before: [1, 3, 1, 0] +9 0 1 0 +After: [1, 3, 1, 0] + +Before: [1, 1, 1, 0] +4 1 2 3 +After: [1, 1, 1, 3] + +Before: [1, 1, 2, 0] +7 3 1 3 +After: [1, 1, 2, 1] + +Before: [2, 3, 1, 3] +9 2 1 3 +After: [2, 3, 1, 1] + +Before: [3, 3, 1, 0] +9 2 1 3 +After: [3, 3, 1, 1] + +Before: [2, 3, 2, 3] +3 3 1 3 +After: [2, 3, 2, 3] + +Before: [3, 1, 2, 2] +8 2 1 2 +After: [3, 1, 3, 2] + +Before: [0, 0, 1, 0] +15 2 1 2 +After: [0, 0, 1, 0] + +Before: [1, 0, 2, 2] +4 1 3 1 +After: [1, 3, 2, 2] + +Before: [0, 3, 2, 1] +5 0 1 2 +After: [0, 3, 0, 1] + +Before: [1, 3, 0, 3] +9 0 1 3 +After: [1, 3, 0, 1] + +Before: [1, 2, 3, 2] +1 3 2 0 +After: [4, 2, 3, 2] + +Before: [1, 1, 0, 0] +4 0 2 0 +After: [3, 1, 0, 0] + +Before: [1, 0, 1, 0] +4 1 2 1 +After: [1, 2, 1, 0] + +Before: [1, 3, 3, 2] +10 2 2 0 +After: [2, 3, 3, 2] + +Before: [3, 2, 3, 2] +2 1 3 2 +After: [3, 2, 3, 2] + +Before: [1, 2, 1, 1] +9 3 1 3 +After: [1, 2, 1, 1] + +Before: [0, 1, 2, 2] +14 3 1 0 +After: [3, 1, 2, 2] + +Before: [3, 3, 0, 2] +13 1 3 0 +After: [6, 3, 0, 2] + +Before: [3, 0, 2, 0] +1 0 2 3 +After: [3, 0, 2, 6] + +Before: [0, 3, 3, 2] +13 2 3 1 +After: [0, 6, 3, 2] + +Before: [1, 0, 3, 1] +12 0 1 0 +After: [1, 0, 3, 1] + +Before: [0, 0, 0, 1] +4 0 3 2 +After: [0, 0, 3, 1] + +Before: [2, 0, 1, 1] +15 3 1 3 +After: [2, 0, 1, 1] + +Before: [3, 0, 2, 1] +15 3 1 2 +After: [3, 0, 1, 1] + +Before: [3, 3, 2, 3] +1 3 2 3 +After: [3, 3, 2, 6] + +Before: [2, 1, 1, 3] +8 2 3 2 +After: [2, 1, 3, 3] + +Before: [0, 0, 1, 3] +15 2 1 2 +After: [0, 0, 1, 3] + +Before: [3, 1, 3, 1] +10 2 2 2 +After: [3, 1, 2, 1] + +Before: [2, 3, 1, 0] +9 2 1 2 +After: [2, 3, 1, 0] + +Before: [0, 0, 2, 2] +6 0 0 3 +After: [0, 0, 2, 0] + +Before: [0, 0, 2, 0] +8 0 2 0 +After: [2, 0, 2, 0] + +Before: [0, 0, 2, 1] +3 2 2 1 +After: [0, 2, 2, 1] + +Before: [3, 2, 2, 0] +2 2 3 0 +After: [3, 2, 2, 0] + +Before: [3, 2, 3, 2] +0 2 3 3 +After: [3, 2, 3, 2] + +Before: [2, 0, 2, 3] +11 2 2 3 +After: [2, 0, 2, 4] + +Before: [1, 2, 2, 2] +11 2 2 3 +After: [1, 2, 2, 4] + +Before: [0, 1, 0, 1] +8 0 1 2 +After: [0, 1, 1, 1] + +Before: [1, 0, 1, 2] +15 2 1 2 +After: [1, 0, 1, 2] + +Before: [1, 2, 1, 1] +9 3 1 2 +After: [1, 2, 1, 1] + +Before: [3, 1, 3, 0] +7 3 1 1 +After: [3, 1, 3, 0] + +Before: [0, 1, 1, 3] +8 1 3 0 +After: [3, 1, 1, 3] + +Before: [2, 2, 3, 0] +0 2 1 0 +After: [2, 2, 3, 0] + +Before: [2, 0, 0, 3] +5 1 0 3 +After: [2, 0, 0, 0] + +Before: [2, 0, 2, 2] +2 2 3 0 +After: [3, 0, 2, 2] + +Before: [0, 2, 3, 3] +10 2 2 0 +After: [2, 2, 3, 3] + +Before: [3, 0, 1, 2] +15 2 1 3 +After: [3, 0, 1, 1] + +Before: [3, 1, 2, 0] +2 2 3 1 +After: [3, 3, 2, 0] + +Before: [0, 1, 3, 2] +4 0 2 1 +After: [0, 2, 3, 2] + +Before: [1, 0, 0, 3] +12 0 1 3 +After: [1, 0, 0, 1] + +Before: [2, 2, 3, 3] +0 2 1 0 +After: [2, 2, 3, 3] + +Before: [0, 1, 1, 1] +5 0 1 3 +After: [0, 1, 1, 0] + +Before: [1, 0, 1, 2] +15 2 1 0 +After: [1, 0, 1, 2] + +Before: [2, 1, 3, 0] +10 2 2 2 +After: [2, 1, 2, 0] + +Before: [0, 2, 3, 2] +1 1 2 3 +After: [0, 2, 3, 4] + +Before: [1, 1, 0, 1] +7 2 1 0 +After: [1, 1, 0, 1] + +Before: [0, 3, 1, 0] +6 0 0 0 +After: [0, 3, 1, 0] + +Before: [3, 1, 0, 0] +7 3 1 3 +After: [3, 1, 0, 1] + +Before: [1, 0, 1, 3] +12 0 1 0 +After: [1, 0, 1, 3] + +Before: [1, 0, 1, 1] +12 0 1 2 +After: [1, 0, 1, 1] + +Before: [0, 3, 3, 3] +1 1 3 0 +After: [9, 3, 3, 3] + +Before: [3, 0, 3, 2] +5 1 0 0 +After: [0, 0, 3, 2] + +Before: [1, 2, 1, 1] +13 3 1 2 +After: [1, 2, 2, 1] + +Before: [1, 3, 0, 3] +9 0 1 1 +After: [1, 1, 0, 3] + +Before: [0, 3, 2, 3] +8 0 2 1 +After: [0, 2, 2, 3] + +Before: [2, 1, 0, 1] +7 2 1 0 +After: [1, 1, 0, 1] + +Before: [0, 0, 3, 2] +6 0 0 2 +After: [0, 0, 0, 2] + +Before: [0, 3, 0, 2] +4 2 1 0 +After: [1, 3, 0, 2] + +Before: [0, 1, 2, 1] +5 0 3 3 +After: [0, 1, 2, 0] + +Before: [2, 3, 1, 2] +9 2 1 0 +After: [1, 3, 1, 2] + +Before: [0, 3, 1, 2] +9 2 1 3 +After: [0, 3, 1, 1] + +Before: [0, 2, 1, 2] +4 0 1 2 +After: [0, 2, 1, 2] + +Before: [1, 0, 2, 2] +12 0 1 1 +After: [1, 1, 2, 2] + +Before: [3, 3, 1, 2] +9 2 1 3 +After: [3, 3, 1, 1] + +Before: [2, 2, 0, 2] +2 0 3 2 +After: [2, 2, 3, 2] + +Before: [3, 2, 2, 0] +1 0 2 2 +After: [3, 2, 6, 0] + +Before: [0, 3, 2, 0] +2 2 3 2 +After: [0, 3, 3, 0] + +Before: [1, 2, 3, 2] +0 2 3 0 +After: [2, 2, 3, 2] + +Before: [0, 1, 2, 3] +3 3 0 2 +After: [0, 1, 3, 3] + +Before: [0, 3, 1, 2] +6 0 0 1 +After: [0, 0, 1, 2] + +Before: [1, 2, 2, 0] +2 2 3 1 +After: [1, 3, 2, 0] + +Before: [1, 3, 1, 0] +9 2 1 3 +After: [1, 3, 1, 1] + +Before: [2, 1, 0, 0] +4 1 2 0 +After: [3, 1, 0, 0] + +Before: [0, 1, 3, 2] +8 0 1 2 +After: [0, 1, 1, 2] + +Before: [0, 2, 3, 2] +1 3 2 2 +After: [0, 2, 4, 2] + +Before: [0, 1, 0, 0] +7 2 1 1 +After: [0, 1, 0, 0] + +Before: [0, 2, 3, 1] +0 2 1 2 +After: [0, 2, 2, 1] + +Before: [3, 3, 2, 2] +11 2 2 0 +After: [4, 3, 2, 2] + +Before: [3, 0, 0, 3] +1 0 3 3 +After: [3, 0, 0, 9] + +Before: [1, 1, 0, 3] +7 2 1 0 +After: [1, 1, 0, 3] + +Before: [3, 1, 0, 2] +7 2 1 0 +After: [1, 1, 0, 2] + +Before: [1, 0, 2, 0] +2 2 3 0 +After: [3, 0, 2, 0] + +Before: [2, 1, 0, 0] +7 3 1 2 +After: [2, 1, 1, 0] + +Before: [2, 2, 1, 2] +1 3 2 3 +After: [2, 2, 1, 4] + +Before: [2, 0, 3, 0] +0 2 0 0 +After: [2, 0, 3, 0] + +Before: [3, 0, 3, 2] +0 2 3 3 +After: [3, 0, 3, 2] + +Before: [0, 1, 2, 2] +11 3 2 0 +After: [4, 1, 2, 2] + +Before: [1, 1, 2, 0] +7 3 1 0 +After: [1, 1, 2, 0] + +Before: [0, 1, 2, 0] +2 2 3 2 +After: [0, 1, 3, 0] + +Before: [2, 0, 1, 1] +1 0 2 3 +After: [2, 0, 1, 4] + +Before: [0, 1, 3, 1] +5 0 2 2 +After: [0, 1, 0, 1] + +Before: [0, 2, 2, 0] +2 2 3 3 +After: [0, 2, 2, 3] + +Before: [1, 3, 0, 3] +9 0 1 2 +After: [1, 3, 1, 3] + +Before: [2, 0, 3, 3] +10 2 2 1 +After: [2, 2, 3, 3] + +Before: [2, 2, 3, 1] +0 2 1 1 +After: [2, 2, 3, 1] + +Before: [0, 0, 1, 2] +6 0 0 2 +After: [0, 0, 0, 2] + +Before: [0, 0, 2, 3] +10 3 2 2 +After: [0, 0, 2, 3] + +Before: [3, 2, 2, 1] +3 2 2 3 +After: [3, 2, 2, 2] + +Before: [0, 0, 0, 2] +1 3 2 1 +After: [0, 4, 0, 2] + +Before: [1, 0, 3, 3] +12 0 1 3 +After: [1, 0, 3, 1] + +Before: [2, 1, 2, 2] +11 0 2 1 +After: [2, 4, 2, 2] + +Before: [1, 3, 2, 3] +10 3 2 1 +After: [1, 2, 2, 3] + +Before: [0, 0, 1, 2] +5 0 3 3 +After: [0, 0, 1, 0] + +Before: [0, 0, 2, 0] +11 2 2 3 +After: [0, 0, 2, 4] + +Before: [1, 1, 2, 0] +11 2 2 0 +After: [4, 1, 2, 0] + +Before: [3, 1, 1, 3] +3 3 3 2 +After: [3, 1, 3, 3] + +Before: [1, 3, 0, 2] +13 1 3 2 +After: [1, 3, 6, 2] + +Before: [1, 1, 0, 0] +1 0 3 0 +After: [3, 1, 0, 0] + +Before: [1, 0, 1, 1] +12 0 1 3 +After: [1, 0, 1, 1] + +Before: [1, 0, 3, 2] +12 0 1 3 +After: [1, 0, 3, 1] + +Before: [0, 0, 3, 3] +10 2 2 0 +After: [2, 0, 3, 3] + +Before: [0, 2, 3, 3] +0 2 1 3 +After: [0, 2, 3, 2] + +Before: [2, 2, 1, 1] +9 3 1 0 +After: [1, 2, 1, 1] + +Before: [1, 3, 3, 2] +10 2 2 1 +After: [1, 2, 3, 2] + +Before: [1, 3, 1, 3] +3 3 0 3 +After: [1, 3, 1, 3] + +Before: [0, 0, 2, 3] +6 0 0 2 +After: [0, 0, 0, 3] + +Before: [1, 1, 1, 0] +7 3 1 2 +After: [1, 1, 1, 0] + +Before: [1, 1, 0, 1] +7 2 1 3 +After: [1, 1, 0, 1] + +Before: [3, 3, 0, 0] +4 3 2 0 +After: [2, 3, 0, 0] + +Before: [2, 1, 1, 1] +4 1 2 3 +After: [2, 1, 1, 3] + +Before: [3, 0, 2, 3] +4 2 1 3 +After: [3, 0, 2, 3] + +Before: [1, 0, 2, 0] +4 2 1 2 +After: [1, 0, 3, 0] + +Before: [1, 0, 1, 2] +12 0 1 1 +After: [1, 1, 1, 2] + +Before: [0, 1, 0, 0] +5 0 1 0 +After: [0, 1, 0, 0] + +Before: [1, 1, 2, 0] +7 3 1 1 +After: [1, 1, 2, 0] + +Before: [0, 2, 1, 0] +2 1 3 0 +After: [3, 2, 1, 0] + +Before: [2, 1, 2, 0] +2 0 3 1 +After: [2, 3, 2, 0] + +Before: [0, 3, 2, 2] +10 1 2 3 +After: [0, 3, 2, 2] + +Before: [1, 0, 0, 0] +12 0 1 0 +After: [1, 0, 0, 0] + +Before: [2, 1, 0, 2] +14 3 1 0 +After: [3, 1, 0, 2] + +Before: [3, 2, 2, 1] +9 3 1 2 +After: [3, 2, 1, 1] + +Before: [1, 0, 1, 2] +15 2 1 1 +After: [1, 1, 1, 2] + +Before: [2, 0, 1, 1] +15 2 1 1 +After: [2, 1, 1, 1] + +Before: [3, 0, 3, 3] +3 3 3 0 +After: [3, 0, 3, 3] + +Before: [1, 1, 1, 0] +1 1 3 1 +After: [1, 3, 1, 0] + +Before: [2, 2, 0, 1] +9 3 1 1 +After: [2, 1, 0, 1] + +Before: [1, 3, 1, 2] +9 2 1 3 +After: [1, 3, 1, 1] + +Before: [0, 3, 1, 1] +6 0 0 2 +After: [0, 3, 0, 1] + +Before: [3, 1, 3, 1] +8 1 2 2 +After: [3, 1, 3, 1] + +Before: [1, 2, 2, 1] +4 1 1 1 +After: [1, 3, 2, 1] + +Before: [2, 3, 3, 0] +0 2 0 0 +After: [2, 3, 3, 0] + +Before: [0, 2, 1, 1] +9 3 1 1 +After: [0, 1, 1, 1] + +Before: [0, 3, 3, 0] +5 0 1 2 +After: [0, 3, 0, 0] + +Before: [0, 3, 1, 0] +9 2 1 1 +After: [0, 1, 1, 0] + +Before: [3, 2, 3, 2] +2 1 3 3 +After: [3, 2, 3, 3] + +Before: [1, 1, 2, 2] +11 3 2 3 +After: [1, 1, 2, 4] + +Before: [0, 3, 3, 3] +5 0 2 0 +After: [0, 3, 3, 3] + +Before: [1, 0, 2, 2] +11 2 2 1 +After: [1, 4, 2, 2] + +Before: [3, 2, 3, 1] +14 3 2 0 +After: [3, 2, 3, 1] + +Before: [0, 3, 2, 0] +6 0 0 0 +After: [0, 3, 2, 0] + +Before: [1, 1, 1, 3] +3 3 1 2 +After: [1, 1, 3, 3] + +Before: [3, 1, 3, 2] +0 2 3 3 +After: [3, 1, 3, 2] + +Before: [2, 1, 2, 2] +2 2 3 3 +After: [2, 1, 2, 3] + +Before: [0, 3, 0, 3] +6 0 0 3 +After: [0, 3, 0, 0] + +Before: [0, 2, 2, 3] +6 0 0 2 +After: [0, 2, 0, 3] + +Before: [0, 1, 3, 3] +6 0 0 2 +After: [0, 1, 0, 3] + +Before: [1, 1, 2, 2] +8 2 1 2 +After: [1, 1, 3, 2] + +Before: [2, 2, 1, 1] +1 2 3 2 +After: [2, 2, 3, 1] + +Before: [2, 0, 1, 2] +15 2 1 2 +After: [2, 0, 1, 2] + +Before: [2, 1, 2, 3] +1 3 3 2 +After: [2, 1, 9, 3] + +Before: [0, 1, 0, 0] +7 2 1 2 +After: [0, 1, 1, 0] + +Before: [2, 1, 0, 3] +8 2 3 0 +After: [3, 1, 0, 3] + +Before: [0, 3, 2, 1] +14 3 2 0 +After: [3, 3, 2, 1] + +Before: [2, 0, 1, 2] +15 2 1 0 +After: [1, 0, 1, 2] + +Before: [1, 2, 2, 1] +13 3 1 3 +After: [1, 2, 2, 2] + +Before: [1, 0, 1, 0] +12 0 1 0 +After: [1, 0, 1, 0] + +Before: [2, 2, 3, 0] +0 2 1 3 +After: [2, 2, 3, 2] + +Before: [0, 0, 1, 1] +15 2 1 3 +After: [0, 0, 1, 1] + +Before: [0, 3, 0, 3] +3 3 0 0 +After: [3, 3, 0, 3] + +Before: [2, 2, 2, 1] +11 2 2 2 +After: [2, 2, 4, 1] + +Before: [2, 1, 2, 0] +2 0 3 0 +After: [3, 1, 2, 0] + +Before: [1, 2, 2, 0] +13 0 1 0 +After: [2, 2, 2, 0] + +Before: [1, 0, 3, 0] +12 0 1 1 +After: [1, 1, 3, 0] + +Before: [3, 1, 0, 3] +5 2 0 3 +After: [3, 1, 0, 0] + +Before: [1, 2, 1, 0] +1 2 3 0 +After: [3, 2, 1, 0] + +Before: [0, 1, 3, 2] +13 2 3 0 +After: [6, 1, 3, 2] + +Before: [1, 0, 1, 2] +12 0 1 0 +After: [1, 0, 1, 2] + +Before: [0, 0, 1, 1] +1 2 3 3 +After: [0, 0, 1, 3] + +Before: [1, 3, 0, 2] +9 0 1 2 +After: [1, 3, 1, 2] + +Before: [2, 3, 2, 2] +11 3 2 0 +After: [4, 3, 2, 2] + +Before: [2, 2, 3, 1] +10 2 2 0 +After: [2, 2, 3, 1] + +Before: [3, 0, 3, 2] +10 2 2 3 +After: [3, 0, 3, 2] + +Before: [2, 1, 2, 2] +11 3 2 2 +After: [2, 1, 4, 2] + +Before: [0, 3, 3, 1] +10 2 2 1 +After: [0, 2, 3, 1] + +Before: [0, 0, 2, 1] +15 3 1 3 +After: [0, 0, 2, 1] + +Before: [1, 2, 3, 2] +13 2 3 1 +After: [1, 6, 3, 2] + +Before: [2, 3, 2, 1] +14 3 2 2 +After: [2, 3, 3, 1] + +Before: [1, 0, 1, 3] +12 0 1 2 +After: [1, 0, 1, 3] + +Before: [0, 2, 2, 3] +8 0 3 0 +After: [3, 2, 2, 3] + +Before: [0, 1, 1, 2] +14 3 1 3 +After: [0, 1, 1, 3] + +Before: [1, 3, 3, 2] +9 0 1 2 +After: [1, 3, 1, 2] + +Before: [2, 2, 2, 1] +11 2 2 1 +After: [2, 4, 2, 1] + +Before: [1, 3, 3, 3] +9 0 1 0 +After: [1, 3, 3, 3] + +Before: [3, 3, 2, 1] +1 3 2 0 +After: [2, 3, 2, 1] + +Before: [0, 1, 3, 1] +14 3 2 3 +After: [0, 1, 3, 3] + +Before: [2, 0, 3, 3] +0 2 0 0 +After: [2, 0, 3, 3] + +Before: [3, 2, 3, 2] +13 2 3 0 +After: [6, 2, 3, 2] + +Before: [2, 3, 2, 1] +11 2 2 2 +After: [2, 3, 4, 1] + +Before: [3, 0, 0, 2] +5 2 0 2 +After: [3, 0, 0, 2] + +Before: [1, 1, 1, 3] +3 3 3 1 +After: [1, 3, 1, 3] + +Before: [2, 1, 2, 0] +3 2 0 0 +After: [2, 1, 2, 0] + +Before: [0, 3, 1, 3] +6 0 0 0 +After: [0, 3, 1, 3] + +Before: [2, 1, 0, 0] +2 0 3 3 +After: [2, 1, 0, 3] + +Before: [0, 1, 0, 3] +5 0 1 3 +After: [0, 1, 0, 0] + +Before: [3, 0, 2, 1] +15 3 1 0 +After: [1, 0, 2, 1] + +Before: [2, 2, 2, 2] +2 1 3 0 +After: [3, 2, 2, 2] + +Before: [2, 1, 0, 2] +14 3 1 3 +After: [2, 1, 0, 3] + +Before: [0, 0, 2, 1] +11 2 2 3 +After: [0, 0, 2, 4] + +Before: [2, 3, 1, 2] +9 2 1 3 +After: [2, 3, 1, 1] + +Before: [0, 3, 1, 1] +6 0 0 3 +After: [0, 3, 1, 0] + + + +1 0 0 1 +4 1 1 1 +14 0 0 3 +14 3 2 2 +12 3 2 1 +1 1 2 1 +11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 2 +3 0 2 3 +1 3 3 3 +11 3 1 1 +14 2 3 3 +14 2 3 0 +5 0 3 3 +1 3 1 3 +1 3 2 3 +11 1 3 1 +3 1 3 3 +14 1 2 0 +1 3 0 1 +4 1 1 1 +14 3 1 2 +1 0 2 0 +1 0 2 0 +11 0 3 3 +14 2 0 2 +1 1 0 0 +4 0 1 0 +14 3 0 1 +4 0 1 1 +1 1 1 1 +1 1 2 1 +11 1 3 3 +3 3 3 0 +14 0 3 3 +14 3 0 1 +7 3 2 1 +1 1 2 1 +1 1 2 1 +11 0 1 0 +3 0 2 1 +14 1 3 2 +14 2 1 0 +14 1 1 3 +13 3 0 2 +1 2 3 2 +11 2 1 1 +3 1 1 3 +14 2 2 2 +14 2 2 1 +14 1 3 0 +3 0 2 1 +1 1 2 1 +11 3 1 3 +3 3 2 0 diff --git a/2018/src/day16.rs b/2018/src/day16.rs new file mode 100644 index 0000000..cc68949 --- /dev/null +++ b/2018/src/day16.rs @@ -0,0 +1,191 @@ +use std::io; +use std::io::BufRead; + +#[derive(Copy, Clone)] +enum Opcode { + Addr, Addi, + Mulr, Muli, + Banr, Bani, + Borr, Bori, + Setr, Seti, + Gtir, Gtri, Gtrr, + Eqir, Eqri, Eqrr, +} + +impl Opcode { + fn from_id(id: u16) -> Opcode { + use self::Opcode::*; + static VALUES: [Opcode; 16] = [Addr, Addi, Mulr, Muli, Banr, Bani, Borr, Bori, Setr, Seti, Gtir, Gtri, Gtrr, Eqir, Eqri, Eqrr]; + VALUES[id as usize] + } +} + +struct Instr { + op: usize, + a: usize, + b: usize, + c: usize, +} + +impl Instr { + fn from(line: &str) -> Self { + let mut iter = line.split(' ').map(|s| s.parse().unwrap()); + let op = iter.next().unwrap(); + let a = iter.next().unwrap(); + let b = iter.next().unwrap(); + let c = iter.next().unwrap(); + Instr { op, a, b, c } + } +} + +#[derive(PartialEq, Eq, Clone)] +struct Machine { + regs: [usize; 4], +} + +impl Machine { + fn from(line: &str) -> Self { + let mut machine = Machine { regs: [0; 4] }; + let mut i = 0; + for num in line.split(", ").map(|s| s.parse().unwrap()) { + machine.regs[i] = num; + i += 1; + } + machine + } + + fn exec(&mut self, op: Opcode, a: usize, b: usize, c: usize) { + match op { + Opcode::Addr => self.regs[c] = self.regs[a] + self.regs[b], + Opcode::Addi => self.regs[c] = self.regs[a] + b, + Opcode::Mulr => self.regs[c] = self.regs[a] * self.regs[b], + Opcode::Muli => self.regs[c] = self.regs[a] * b, + Opcode::Banr => self.regs[c] = self.regs[a] & self.regs[b], + Opcode::Bani => self.regs[c] = self.regs[a] & b, + Opcode::Borr => self.regs[c] = self.regs[a] | self.regs[b], + Opcode::Bori => self.regs[c] = self.regs[a] | b, + Opcode::Setr => self.regs[c] = self.regs[a], + Opcode::Seti => self.regs[c] = a, + Opcode::Gtir => self.regs[c] = if a > self.regs[b] { 1 } else { 0 }, + Opcode::Gtri => self.regs[c] = if self.regs[a] > b { 1 } else { 0 }, + Opcode::Gtrr => self.regs[c] = if self.regs[a] > self.regs[b] { 1 } else { 0 }, + Opcode::Eqir => self.regs[c] = if a == self.regs[b] { 1 } else { 0 }, + Opcode::Eqri => self.regs[c] = if self.regs[a] == b { 1 } else { 0 }, + Opcode::Eqrr => self.regs[c] = if self.regs[a] == self.regs[b] { 1 } else { 0 }, + } + } +} + +struct Sample { + before: Machine, + after: Machine, + instr: Instr, +} + +impl Sample { + fn behaves_as(&self) -> u16 { + let mut r = 0; + + for id in 0..16 { + let op = Opcode::from_id(id); + + let mut m = self.before.clone(); + m.exec(op, self.instr.a, self.instr.b, self.instr.c); + if m == self.after { + r |= 1 << id; + } + } + + r + } +} + +fn parse_input<T: BufRead>(reader: T) -> io::Result<(Vec<Sample>, Vec<Instr>)> { + let mut line_iter = reader.lines(); + let mut samples = Vec::new(); + let program; + + loop { + let line = line_iter.next().unwrap()?; + if line.len() == 0 { + line_iter.next(); + + program = line_iter.map(|l| Instr::from(&l.unwrap())).collect::<Vec<_>>(); + break; + } else if &line[..1] == "B" { + let before = Machine::from(&line[9..line.len()-1]); + + let line = line_iter.next().unwrap()?; + let instr = Instr::from(&line); + + let line = line_iter.next().unwrap()?; + let after = Machine::from(&line[9..line.len()-1]); + + samples.push(Sample { before, after, instr }); + + line_iter.next(); + } else { + assert!(false); + } + } + + Ok((samples, program)) +} + +fn resolve_helper(masks: &[u16; 16], res: &mut [u16; 16], at: usize, available: u16) -> bool { + if at == 16 { + return true; + } + + let mut walker = available; + + while walker != 0 { + let n = walker.trailing_zeros(); + let bit = 1 << n; + walker &= !bit; + + if (masks[at] & bit) != 0 { + res[at] = n as u16; + if resolve_helper(masks, res, at + 1, available & !bit) { + return true; + } + } + } + + false +} + +fn resolve_mapping(masks: &[u16; 16]) -> [u16; 16] { + let mut res = [0; 16]; + assert!(resolve_helper(masks, &mut res, 0, 0xffff)); + res +} + +pub fn main<T: BufRead>(reader: T) -> io::Result<(String, String)> { + let (samples, program) = parse_input(reader)?; + + let mut num_geq_3 = 0; + let mut code_masks = [0xffff; 16]; + + for sample in samples { + let mask = sample.behaves_as(); + if mask.count_ones() >= 3 { + num_geq_3 += 1; + } + + code_masks[sample.instr.op] &= mask; + } + + let part1 = num_geq_3; + + let mapping = resolve_mapping(&code_masks); + + let mut m = Machine { regs: [0; 4] }; + for instr in program { + m.exec(Opcode::from_id(mapping[instr.op]), instr.a, instr.b, instr.c); + } + + let part2 = m.regs[0]; + + Ok((part1.to_string(), part2.to_string())) +} diff --git a/2018/src/main.rs b/2018/src/main.rs index 6154c99..4bc8d50 100644 --- a/2018/src/main.rs +++ b/2018/src/main.rs @@ -20,8 +20,9 @@ mod day12; mod day13; mod day14; mod day15; +mod day16; -static NUM_DAYS: i32 = 15; +static NUM_DAYS: i32 = 16; fn day_switch<T: BufRead>(day: i32, reader: T) -> io::Result<(String, String)> { match day { @@ -40,6 +41,7 @@ fn day_switch<T: BufRead>(day: i32, reader: T) -> io::Result<(String, String)> { 13 => day13::main(reader), 14 => day14::main(reader), 15 => day15::main(reader), + 16 => day16::main(reader), _ => Err(Error::new(ErrorKind::Other, "Invalid day")) } } |