diff --git a/AoC2018.Runner/AoC2018.Runner.csproj b/AoC2018.Runner/AoC2018.Runner.csproj index ef630c3..856690c 100644 --- a/AoC2018.Runner/AoC2018.Runner.csproj +++ b/AoC2018.Runner/AoC2018.Runner.csproj @@ -67,6 +67,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + diff --git a/AoC2018.Runner/Input/day16.txt b/AoC2018.Runner/Input/day16.txt new file mode 100644 index 0000000..b78c9b2 --- /dev/null +++ b/AoC2018.Runner/Input/day16.txt @@ -0,0 +1,3863 @@ +Before: [1, 0, 2, 0] +4 1 0 1 +After: [1, 1, 2, 0] + +Before: [2, 3, 1, 2] +2 1 0 1 +After: [2, 1, 1, 2] + +Before: [0, 3, 2, 0] +2 1 2 0 +After: [1, 3, 2, 0] + +Before: [3, 2, 2, 0] +6 1 1 1 +After: [3, 3, 2, 0] + +Before: [0, 1, 0, 0] +0 1 0 0 +After: [1, 1, 0, 0] + +Before: [0, 1, 0, 0] +5 0 1 2 +After: [0, 1, 1, 0] + +Before: [3, 3, 1, 3] +7 0 0 2 +After: [3, 3, 9, 3] + +Before: [2, 1, 0, 0] +5 0 1 2 +After: [2, 1, 3, 0] + +Before: [1, 3, 2, 3] +2 1 2 1 +After: [1, 1, 2, 3] + +Before: [1, 2, 0, 3] +3 1 3 0 +After: [6, 2, 0, 3] + +Before: [3, 2, 3, 1] +7 2 0 1 +After: [3, 9, 3, 1] + +Before: [1, 3, 2, 1] +2 1 2 3 +After: [1, 3, 2, 1] + +Before: [3, 3, 0, 2] +8 1 3 2 +After: [3, 3, 1, 2] + +Before: [0, 1, 0, 2] +0 1 0 2 +After: [0, 1, 1, 2] + +Before: [0, 2, 3, 1] +14 3 1 3 +After: [0, 2, 3, 2] + +Before: [0, 2, 0, 3] +5 2 3 0 +After: [3, 2, 0, 3] + +Before: [3, 3, 0, 3] +3 1 3 0 +After: [9, 3, 0, 3] + +Before: [1, 0, 0, 1] +15 3 1 3 +After: [1, 0, 0, 1] + +Before: [0, 3, 1, 2] +14 1 3 3 +After: [0, 3, 1, 6] + +Before: [0, 3, 2, 3] +2 1 2 3 +After: [0, 3, 2, 1] + +Before: [0, 1, 3, 2] +0 1 0 1 +After: [0, 1, 3, 2] + +Before: [0, 0, 2, 3] +1 0 1 0 +After: [1, 0, 2, 3] + +Before: [3, 0, 1, 2] +14 0 3 2 +After: [3, 0, 6, 2] + +Before: [1, 0, 0, 1] +4 1 0 2 +After: [1, 0, 1, 1] + +Before: [0, 0, 2, 3] +12 2 2 2 +After: [0, 0, 4, 3] + +Before: [3, 2, 3, 0] +7 2 2 3 +After: [3, 2, 3, 9] + +Before: [2, 2, 3, 0] +11 1 2 3 +After: [2, 2, 3, 1] + +Before: [0, 1, 2, 2] +0 1 0 2 +After: [0, 1, 1, 2] + +Before: [0, 0, 3, 2] +1 0 1 0 +After: [1, 0, 3, 2] + +Before: [2, 0, 1, 3] +13 0 3 3 +After: [2, 0, 1, 0] + +Before: [1, 1, 3, 2] +9 3 1 1 +After: [1, 3, 3, 2] + +Before: [0, 3, 1, 2] +8 1 3 1 +After: [0, 1, 1, 2] + +Before: [2, 0, 3, 2] +11 1 0 3 +After: [2, 0, 3, 1] + +Before: [3, 3, 2, 0] +7 0 1 1 +After: [3, 9, 2, 0] + +Before: [1, 0, 3, 2] +7 3 2 2 +After: [1, 0, 6, 2] + +Before: [1, 0, 3, 1] +9 3 2 1 +After: [1, 3, 3, 1] + +Before: [2, 2, 1, 3] +13 0 3 2 +After: [2, 2, 0, 3] + +Before: [1, 0, 2, 2] +4 1 0 2 +After: [1, 0, 1, 2] + +Before: [3, 1, 2, 3] +3 3 3 1 +After: [3, 9, 2, 3] + +Before: [1, 0, 0, 3] +4 1 0 1 +After: [1, 1, 0, 3] + +Before: [2, 2, 0, 1] +14 3 1 1 +After: [2, 2, 0, 1] + +Before: [0, 0, 0, 3] +1 0 1 0 +After: [1, 0, 0, 3] + +Before: [0, 0, 3, 2] +10 0 0 1 +After: [0, 0, 3, 2] + +Before: [3, 0, 3, 0] +11 1 0 2 +After: [3, 0, 1, 0] + +Before: [3, 2, 0, 2] +7 0 0 2 +After: [3, 2, 9, 2] + +Before: [0, 2, 0, 3] +5 0 3 0 +After: [3, 2, 0, 3] + +Before: [2, 0, 3, 3] +3 0 2 2 +After: [2, 0, 4, 3] + +Before: [1, 0, 2, 0] +15 0 1 1 +After: [1, 1, 2, 0] + +Before: [2, 2, 2, 1] +9 3 2 0 +After: [3, 2, 2, 1] + +Before: [3, 3, 3, 0] +6 3 2 0 +After: [2, 3, 3, 0] + +Before: [3, 0, 2, 1] +15 3 1 0 +After: [1, 0, 2, 1] + +Before: [0, 2, 3, 1] +3 1 2 2 +After: [0, 2, 4, 1] + +Before: [2, 2, 3, 0] +11 1 2 2 +After: [2, 2, 1, 0] + +Before: [0, 1, 2, 1] +10 0 0 1 +After: [0, 0, 2, 1] + +Before: [1, 2, 2, 3] +14 0 1 3 +After: [1, 2, 2, 2] + +Before: [3, 0, 1, 2] +15 2 1 3 +After: [3, 0, 1, 1] + +Before: [3, 3, 1, 0] +7 0 0 2 +After: [3, 3, 9, 0] + +Before: [2, 1, 0, 3] +6 1 2 0 +After: [3, 1, 0, 3] + +Before: [0, 0, 2, 0] +6 1 3 3 +After: [0, 0, 2, 3] + +Before: [3, 3, 3, 2] +7 2 0 0 +After: [9, 3, 3, 2] + +Before: [2, 1, 3, 2] +14 2 3 1 +After: [2, 6, 3, 2] + +Before: [3, 3, 2, 2] +8 1 3 0 +After: [1, 3, 2, 2] + +Before: [0, 1, 1, 0] +0 1 0 2 +After: [0, 1, 1, 0] + +Before: [2, 1, 2, 1] +12 0 2 0 +After: [4, 1, 2, 1] + +Before: [3, 2, 3, 2] +11 1 2 0 +After: [1, 2, 3, 2] + +Before: [1, 0, 1, 1] +15 0 1 3 +After: [1, 0, 1, 1] + +Before: [1, 2, 2, 3] +13 0 3 1 +After: [1, 0, 2, 3] + +Before: [1, 0, 0, 0] +4 1 0 3 +After: [1, 0, 0, 1] + +Before: [2, 3, 2, 2] +2 1 2 3 +After: [2, 3, 2, 1] + +Before: [1, 3, 0, 3] +13 0 3 0 +After: [0, 3, 0, 3] + +Before: [3, 0, 2, 0] +12 2 2 3 +After: [3, 0, 2, 4] + +Before: [0, 1, 3, 3] +7 2 2 2 +After: [0, 1, 9, 3] + +Before: [0, 2, 3, 1] +10 0 0 2 +After: [0, 2, 0, 1] + +Before: [0, 0, 2, 3] +5 0 3 2 +After: [0, 0, 3, 3] + +Before: [1, 0, 2, 1] +9 3 2 1 +After: [1, 3, 2, 1] + +Before: [0, 1, 3, 1] +0 1 0 2 +After: [0, 1, 1, 1] + +Before: [3, 2, 1, 1] +3 2 3 2 +After: [3, 2, 3, 1] + +Before: [2, 3, 3, 0] +7 2 1 1 +After: [2, 9, 3, 0] + +Before: [1, 1, 0, 1] +3 0 3 2 +After: [1, 1, 3, 1] + +Before: [0, 0, 0, 1] +15 3 1 1 +After: [0, 1, 0, 1] + +Before: [0, 3, 2, 2] +7 2 1 3 +After: [0, 3, 2, 6] + +Before: [1, 0, 3, 3] +4 1 0 2 +After: [1, 0, 1, 3] + +Before: [2, 3, 3, 2] +2 1 0 1 +After: [2, 1, 3, 2] + +Before: [3, 2, 2, 2] +12 3 2 1 +After: [3, 4, 2, 2] + +Before: [0, 0, 2, 0] +10 0 0 2 +After: [0, 0, 0, 0] + +Before: [0, 1, 0, 0] +10 0 0 0 +After: [0, 1, 0, 0] + +Before: [1, 2, 3, 3] +7 2 2 2 +After: [1, 2, 9, 3] + +Before: [1, 2, 1, 1] +14 0 1 2 +After: [1, 2, 2, 1] + +Before: [2, 0, 0, 1] +15 3 1 0 +After: [1, 0, 0, 1] + +Before: [0, 3, 3, 2] +7 3 1 2 +After: [0, 3, 6, 2] + +Before: [1, 1, 1, 3] +5 1 3 3 +After: [1, 1, 1, 3] + +Before: [1, 0, 1, 3] +4 1 0 1 +After: [1, 1, 1, 3] + +Before: [2, 0, 2, 0] +5 3 2 0 +After: [2, 0, 2, 0] + +Before: [0, 0, 3, 0] +10 0 0 3 +After: [0, 0, 3, 0] + +Before: [0, 1, 3, 2] +14 2 3 1 +After: [0, 6, 3, 2] + +Before: [2, 3, 0, 2] +8 1 3 3 +After: [2, 3, 0, 1] + +Before: [0, 0, 1, 0] +15 2 1 2 +After: [0, 0, 1, 0] + +Before: [0, 1, 3, 0] +10 0 0 1 +After: [0, 0, 3, 0] + +Before: [1, 1, 3, 3] +13 0 3 3 +After: [1, 1, 3, 0] + +Before: [2, 3, 3, 1] +2 1 0 2 +After: [2, 3, 1, 1] + +Before: [1, 0, 3, 3] +6 1 2 3 +After: [1, 0, 3, 2] + +Before: [2, 0, 2, 2] +6 1 3 2 +After: [2, 0, 3, 2] + +Before: [2, 3, 3, 2] +7 3 2 1 +After: [2, 6, 3, 2] + +Before: [0, 2, 1, 1] +10 0 0 1 +After: [0, 0, 1, 1] + +Before: [0, 2, 0, 3] +10 0 0 0 +After: [0, 2, 0, 3] + +Before: [0, 1, 3, 1] +9 3 2 1 +After: [0, 3, 3, 1] + +Before: [2, 0, 2, 3] +12 0 2 2 +After: [2, 0, 4, 3] + +Before: [3, 3, 0, 3] +6 2 1 1 +After: [3, 1, 0, 3] + +Before: [0, 1, 3, 3] +10 0 0 0 +After: [0, 1, 3, 3] + +Before: [1, 0, 3, 3] +4 1 0 1 +After: [1, 1, 3, 3] + +Before: [2, 3, 3, 3] +2 1 0 0 +After: [1, 3, 3, 3] + +Before: [2, 1, 2, 2] +12 3 2 0 +After: [4, 1, 2, 2] + +Before: [1, 3, 0, 2] +8 1 3 0 +After: [1, 3, 0, 2] + +Before: [2, 3, 3, 3] +13 0 3 2 +After: [2, 3, 0, 3] + +Before: [3, 0, 3, 2] +14 0 3 1 +After: [3, 6, 3, 2] + +Before: [1, 0, 0, 1] +4 1 0 0 +After: [1, 0, 0, 1] + +Before: [3, 3, 0, 2] +8 1 3 3 +After: [3, 3, 0, 1] + +Before: [2, 3, 3, 1] +2 1 0 0 +After: [1, 3, 3, 1] + +Before: [1, 3, 2, 2] +8 1 3 3 +After: [1, 3, 2, 1] + +Before: [0, 0, 3, 0] +1 0 1 1 +After: [0, 1, 3, 0] + +Before: [0, 0, 2, 2] +1 0 1 1 +After: [0, 1, 2, 2] + +Before: [0, 1, 1, 3] +0 1 0 2 +After: [0, 1, 1, 3] + +Before: [2, 3, 2, 2] +14 1 3 3 +After: [2, 3, 2, 6] + +Before: [3, 1, 3, 1] +5 1 2 2 +After: [3, 1, 3, 1] + +Before: [3, 0, 3, 3] +11 1 0 0 +After: [1, 0, 3, 3] + +Before: [0, 2, 2, 0] +5 3 2 2 +After: [0, 2, 2, 0] + +Before: [0, 0, 0, 3] +10 0 0 3 +After: [0, 0, 0, 0] + +Before: [0, 3, 3, 3] +10 0 0 3 +After: [0, 3, 3, 0] + +Before: [2, 3, 1, 2] +8 1 3 1 +After: [2, 1, 1, 2] + +Before: [3, 0, 2, 3] +11 1 0 1 +After: [3, 1, 2, 3] + +Before: [1, 3, 2, 1] +7 1 1 1 +After: [1, 9, 2, 1] + +Before: [1, 3, 0, 2] +14 1 3 2 +After: [1, 3, 6, 2] + +Before: [0, 0, 1, 3] +1 0 1 2 +After: [0, 0, 1, 3] + +Before: [2, 2, 3, 2] +11 1 2 2 +After: [2, 2, 1, 2] + +Before: [3, 3, 3, 2] +8 1 3 3 +After: [3, 3, 3, 1] + +Before: [3, 1, 1, 2] +9 3 1 2 +After: [3, 1, 3, 2] + +Before: [1, 0, 2, 0] +15 0 1 3 +After: [1, 0, 2, 1] + +Before: [3, 0, 1, 2] +5 2 3 2 +After: [3, 0, 3, 2] + +Before: [1, 0, 1, 3] +15 2 1 1 +After: [1, 1, 1, 3] + +Before: [0, 1, 2, 2] +5 0 2 2 +After: [0, 1, 2, 2] + +Before: [1, 0, 0, 0] +4 1 0 0 +After: [1, 0, 0, 0] + +Before: [3, 0, 2, 1] +15 3 1 1 +After: [3, 1, 2, 1] + +Before: [2, 1, 2, 1] +9 3 2 1 +After: [2, 3, 2, 1] + +Before: [1, 2, 2, 0] +12 1 2 1 +After: [1, 4, 2, 0] + +Before: [0, 3, 2, 2] +10 0 0 3 +After: [0, 3, 2, 0] + +Before: [3, 1, 2, 1] +9 3 2 0 +After: [3, 1, 2, 1] + +Before: [3, 2, 3, 1] +9 3 2 2 +After: [3, 2, 3, 1] + +Before: [1, 0, 0, 3] +4 1 0 2 +After: [1, 0, 1, 3] + +Before: [2, 3, 3, 2] +8 1 3 0 +After: [1, 3, 3, 2] + +Before: [0, 2, 2, 1] +10 0 0 1 +After: [0, 0, 2, 1] + +Before: [0, 0, 1, 1] +15 2 1 1 +After: [0, 1, 1, 1] + +Before: [0, 2, 3, 3] +10 0 0 3 +After: [0, 2, 3, 0] + +Before: [1, 0, 0, 0] +4 1 0 2 +After: [1, 0, 1, 0] + +Before: [0, 1, 0, 1] +0 1 0 2 +After: [0, 1, 1, 1] + +Before: [1, 2, 2, 3] +12 2 2 2 +After: [1, 2, 4, 3] + +Before: [2, 1, 3, 2] +14 2 3 3 +After: [2, 1, 3, 6] + +Before: [2, 3, 2, 0] +2 1 0 0 +After: [1, 3, 2, 0] + +Before: [3, 3, 2, 1] +2 1 2 2 +After: [3, 3, 1, 1] + +Before: [3, 2, 1, 0] +3 2 3 1 +After: [3, 3, 1, 0] + +Before: [0, 0, 0, 1] +10 0 0 1 +After: [0, 0, 0, 1] + +Before: [3, 2, 3, 1] +14 3 1 3 +After: [3, 2, 3, 2] + +Before: [2, 1, 3, 2] +7 2 0 3 +After: [2, 1, 3, 6] + +Before: [3, 3, 2, 1] +2 1 2 1 +After: [3, 1, 2, 1] + +Before: [0, 3, 1, 2] +10 0 0 2 +After: [0, 3, 0, 2] + +Before: [3, 3, 3, 2] +8 1 3 1 +After: [3, 1, 3, 2] + +Before: [2, 1, 2, 1] +12 0 2 3 +After: [2, 1, 2, 4] + +Before: [0, 1, 1, 0] +3 1 3 2 +After: [0, 1, 3, 0] + +Before: [0, 3, 0, 1] +6 2 1 0 +After: [1, 3, 0, 1] + +Before: [1, 3, 1, 3] +13 0 3 1 +After: [1, 0, 1, 3] + +Before: [0, 3, 3, 1] +10 0 0 2 +After: [0, 3, 0, 1] + +Before: [0, 3, 2, 0] +7 2 1 2 +After: [0, 3, 6, 0] + +Before: [1, 0, 2, 1] +15 0 1 3 +After: [1, 0, 2, 1] + +Before: [1, 0, 0, 2] +4 1 0 3 +After: [1, 0, 0, 1] + +Before: [2, 0, 3, 3] +7 2 2 3 +After: [2, 0, 3, 9] + +Before: [0, 0, 1, 0] +3 2 3 1 +After: [0, 3, 1, 0] + +Before: [0, 0, 3, 0] +1 0 1 3 +After: [0, 0, 3, 1] + +Before: [3, 0, 3, 2] +11 1 0 3 +After: [3, 0, 3, 1] + +Before: [1, 1, 3, 1] +9 3 2 3 +After: [1, 1, 3, 3] + +Before: [3, 2, 2, 3] +7 0 0 0 +After: [9, 2, 2, 3] + +Before: [3, 2, 3, 1] +11 1 2 0 +After: [1, 2, 3, 1] + +Before: [0, 0, 2, 2] +12 3 2 3 +After: [0, 0, 2, 4] + +Before: [1, 0, 3, 3] +13 0 3 0 +After: [0, 0, 3, 3] + +Before: [2, 3, 3, 0] +2 1 0 1 +After: [2, 1, 3, 0] + +Before: [0, 0, 0, 2] +10 0 0 2 +After: [0, 0, 0, 2] + +Before: [0, 1, 3, 0] +0 1 0 0 +After: [1, 1, 3, 0] + +Before: [0, 3, 3, 2] +14 2 3 3 +After: [0, 3, 3, 6] + +Before: [0, 1, 3, 0] +0 1 0 1 +After: [0, 1, 3, 0] + +Before: [0, 1, 0, 3] +10 0 0 0 +After: [0, 1, 0, 3] + +Before: [0, 0, 1, 1] +1 0 1 0 +After: [1, 0, 1, 1] + +Before: [0, 1, 3, 3] +0 1 0 0 +After: [1, 1, 3, 3] + +Before: [0, 3, 2, 3] +3 2 3 3 +After: [0, 3, 2, 6] + +Before: [1, 3, 2, 2] +8 1 3 1 +After: [1, 1, 2, 2] + +Before: [1, 2, 2, 2] +14 0 1 2 +After: [1, 2, 2, 2] + +Before: [1, 1, 1, 3] +13 0 3 2 +After: [1, 1, 0, 3] + +Before: [3, 0, 2, 2] +11 1 0 3 +After: [3, 0, 2, 1] + +Before: [0, 1, 2, 1] +12 2 2 0 +After: [4, 1, 2, 1] + +Before: [1, 3, 2, 2] +8 1 3 2 +After: [1, 3, 1, 2] + +Before: [0, 0, 0, 1] +10 0 0 0 +After: [0, 0, 0, 1] + +Before: [0, 3, 1, 1] +10 0 0 0 +After: [0, 3, 1, 1] + +Before: [2, 0, 3, 2] +11 1 0 2 +After: [2, 0, 1, 2] + +Before: [2, 0, 0, 2] +11 1 0 0 +After: [1, 0, 0, 2] + +Before: [2, 0, 1, 1] +11 1 0 3 +After: [2, 0, 1, 1] + +Before: [0, 0, 0, 1] +1 0 1 2 +After: [0, 0, 1, 1] + +Before: [0, 0, 3, 1] +15 3 1 0 +After: [1, 0, 3, 1] + +Before: [3, 3, 1, 1] +7 1 0 1 +After: [3, 9, 1, 1] + +Before: [0, 2, 2, 1] +6 2 1 0 +After: [3, 2, 2, 1] + +Before: [0, 3, 0, 3] +3 1 3 2 +After: [0, 3, 9, 3] + +Before: [3, 0, 0, 2] +14 0 3 3 +After: [3, 0, 0, 6] + +Before: [3, 2, 2, 2] +12 3 2 0 +After: [4, 2, 2, 2] + +Before: [0, 0, 2, 1] +9 3 2 0 +After: [3, 0, 2, 1] + +Before: [1, 2, 3, 1] +14 0 1 1 +After: [1, 2, 3, 1] + +Before: [3, 1, 3, 2] +14 0 3 3 +After: [3, 1, 3, 6] + +Before: [2, 3, 2, 3] +13 0 3 3 +After: [2, 3, 2, 0] + +Before: [1, 0, 3, 0] +4 1 0 1 +After: [1, 1, 3, 0] + +Before: [0, 2, 3, 2] +11 1 2 1 +After: [0, 1, 3, 2] + +Before: [1, 0, 3, 2] +14 2 3 2 +After: [1, 0, 6, 2] + +Before: [1, 2, 3, 3] +13 0 3 1 +After: [1, 0, 3, 3] + +Before: [1, 0, 2, 3] +4 1 0 1 +After: [1, 1, 2, 3] + +Before: [1, 0, 1, 3] +15 0 1 1 +After: [1, 1, 1, 3] + +Before: [3, 0, 2, 2] +12 2 2 2 +After: [3, 0, 4, 2] + +Before: [0, 3, 3, 2] +8 1 3 2 +After: [0, 3, 1, 2] + +Before: [1, 2, 2, 3] +12 1 2 2 +After: [1, 2, 4, 3] + +Before: [1, 0, 1, 2] +4 1 0 1 +After: [1, 1, 1, 2] + +Before: [1, 2, 0, 2] +7 0 3 1 +After: [1, 2, 0, 2] + +Before: [0, 0, 0, 3] +1 0 1 1 +After: [0, 1, 0, 3] + +Before: [3, 1, 3, 1] +9 3 2 3 +After: [3, 1, 3, 3] + +Before: [3, 0, 1, 0] +15 2 1 2 +After: [3, 0, 1, 0] + +Before: [2, 0, 2, 1] +9 3 2 3 +After: [2, 0, 2, 3] + +Before: [0, 1, 1, 3] +0 1 0 3 +After: [0, 1, 1, 1] + +Before: [1, 2, 3, 0] +11 1 2 0 +After: [1, 2, 3, 0] + +Before: [1, 0, 1, 3] +13 0 3 1 +After: [1, 0, 1, 3] + +Before: [1, 2, 2, 3] +14 0 1 2 +After: [1, 2, 2, 3] + +Before: [1, 2, 2, 1] +14 3 1 1 +After: [1, 2, 2, 1] + +Before: [0, 1, 1, 2] +5 1 3 2 +After: [0, 1, 3, 2] + +Before: [3, 3, 0, 0] +7 0 1 1 +After: [3, 9, 0, 0] + +Before: [0, 0, 1, 1] +10 0 0 2 +After: [0, 0, 0, 1] + +Before: [3, 3, 2, 1] +9 3 2 2 +After: [3, 3, 3, 1] + +Before: [2, 3, 1, 3] +2 1 0 3 +After: [2, 3, 1, 1] + +Before: [0, 0, 2, 3] +10 0 0 1 +After: [0, 0, 2, 3] + +Before: [0, 1, 0, 0] +10 0 0 1 +After: [0, 0, 0, 0] + +Before: [1, 2, 1, 3] +14 0 1 2 +After: [1, 2, 2, 3] + +Before: [0, 3, 2, 1] +2 1 2 3 +After: [0, 3, 2, 1] + +Before: [1, 0, 1, 2] +4 1 0 2 +After: [1, 0, 1, 2] + +Before: [3, 2, 3, 1] +7 2 2 1 +After: [3, 9, 3, 1] + +Before: [0, 3, 1, 2] +10 0 0 1 +After: [0, 0, 1, 2] + +Before: [2, 0, 3, 1] +7 3 0 0 +After: [2, 0, 3, 1] + +Before: [1, 3, 1, 0] +6 3 2 2 +After: [1, 3, 2, 0] + +Before: [2, 0, 1, 2] +11 1 0 3 +After: [2, 0, 1, 1] + +Before: [0, 2, 2, 1] +12 2 2 2 +After: [0, 2, 4, 1] + +Before: [1, 0, 3, 2] +15 0 1 3 +After: [1, 0, 3, 1] + +Before: [2, 3, 3, 2] +7 2 2 3 +After: [2, 3, 3, 9] + +Before: [2, 1, 2, 1] +5 0 1 0 +After: [3, 1, 2, 1] + +Before: [0, 3, 3, 1] +10 0 0 0 +After: [0, 3, 3, 1] + +Before: [0, 0, 3, 3] +1 0 1 0 +After: [1, 0, 3, 3] + +Before: [0, 1, 3, 2] +0 1 0 0 +After: [1, 1, 3, 2] + +Before: [3, 0, 1, 1] +11 1 0 0 +After: [1, 0, 1, 1] + +Before: [0, 0, 2, 1] +9 3 2 1 +After: [0, 3, 2, 1] + +Before: [2, 0, 2, 3] +3 3 3 3 +After: [2, 0, 2, 9] + +Before: [3, 1, 2, 3] +3 0 3 2 +After: [3, 1, 9, 3] + +Before: [3, 1, 2, 3] +5 1 3 3 +After: [3, 1, 2, 3] + +Before: [1, 0, 2, 0] +4 1 0 2 +After: [1, 0, 1, 0] + +Before: [0, 1, 2, 2] +10 0 0 0 +After: [0, 1, 2, 2] + +Before: [1, 1, 0, 2] +9 3 1 3 +After: [1, 1, 0, 3] + +Before: [3, 0, 2, 2] +14 0 3 2 +After: [3, 0, 6, 2] + +Before: [0, 1, 3, 2] +5 1 3 2 +After: [0, 1, 3, 2] + +Before: [0, 0, 3, 3] +10 0 0 3 +After: [0, 0, 3, 0] + +Before: [2, 2, 1, 2] +3 3 2 0 +After: [4, 2, 1, 2] + +Before: [0, 3, 1, 2] +14 1 3 0 +After: [6, 3, 1, 2] + +Before: [3, 2, 2, 1] +3 3 2 3 +After: [3, 2, 2, 2] + +Before: [1, 0, 1, 1] +4 1 0 1 +After: [1, 1, 1, 1] + +Before: [1, 2, 0, 0] +14 0 1 1 +After: [1, 2, 0, 0] + +Before: [2, 2, 0, 3] +13 0 3 3 +After: [2, 2, 0, 0] + +Before: [1, 0, 3, 2] +5 0 2 3 +After: [1, 0, 3, 3] + +Before: [0, 1, 2, 1] +0 1 0 1 +After: [0, 1, 2, 1] + +Before: [1, 0, 1, 0] +4 1 0 1 +After: [1, 1, 1, 0] + +Before: [2, 1, 2, 1] +5 2 1 3 +After: [2, 1, 2, 3] + +Before: [1, 2, 1, 3] +13 0 3 0 +After: [0, 2, 1, 3] + +Before: [1, 0, 0, 3] +15 0 1 3 +After: [1, 0, 0, 1] + +Before: [1, 0, 2, 1] +15 3 1 2 +After: [1, 0, 1, 1] + +Before: [0, 0, 3, 3] +3 2 3 1 +After: [0, 9, 3, 3] + +Before: [1, 3, 2, 1] +3 3 2 2 +After: [1, 3, 2, 1] + +Before: [2, 2, 2, 3] +13 0 3 0 +After: [0, 2, 2, 3] + +Before: [0, 0, 1, 1] +15 2 1 3 +After: [0, 0, 1, 1] + +Before: [1, 1, 1, 3] +13 0 3 0 +After: [0, 1, 1, 3] + +Before: [3, 0, 2, 2] +12 3 2 2 +After: [3, 0, 4, 2] + +Before: [0, 0, 1, 0] +1 0 1 2 +After: [0, 0, 1, 0] + +Before: [1, 0, 2, 3] +13 0 3 1 +After: [1, 0, 2, 3] + +Before: [3, 0, 2, 3] +7 3 0 0 +After: [9, 0, 2, 3] + +Before: [2, 3, 2, 1] +2 1 0 0 +After: [1, 3, 2, 1] + +Before: [0, 1, 3, 2] +5 1 2 0 +After: [3, 1, 3, 2] + +Before: [0, 1, 2, 3] +0 1 0 0 +After: [1, 1, 2, 3] + +Before: [3, 3, 0, 3] +7 0 0 3 +After: [3, 3, 0, 9] + +Before: [0, 3, 2, 2] +12 2 2 2 +After: [0, 3, 4, 2] + +Before: [1, 0, 2, 0] +4 1 0 3 +After: [1, 0, 2, 1] + +Before: [2, 3, 0, 1] +2 1 0 0 +After: [1, 3, 0, 1] + +Before: [0, 1, 2, 0] +0 1 0 2 +After: [0, 1, 1, 0] + +Before: [1, 3, 2, 3] +12 2 2 0 +After: [4, 3, 2, 3] + +Before: [1, 0, 1, 0] +15 2 1 2 +After: [1, 0, 1, 0] + +Before: [3, 0, 3, 0] +7 2 0 3 +After: [3, 0, 3, 9] + +Before: [0, 0, 2, 2] +10 0 0 1 +After: [0, 0, 2, 2] + +Before: [0, 1, 1, 3] +10 0 0 1 +After: [0, 0, 1, 3] + +Before: [2, 0, 3, 2] +11 1 0 0 +After: [1, 0, 3, 2] + +Before: [1, 2, 0, 2] +3 1 2 1 +After: [1, 4, 0, 2] + +Before: [2, 2, 0, 0] +6 3 2 2 +After: [2, 2, 2, 0] + +Before: [1, 2, 2, 0] +5 3 2 1 +After: [1, 2, 2, 0] + +Before: [0, 3, 3, 1] +7 1 2 2 +After: [0, 3, 9, 1] + +Before: [2, 3, 3, 3] +2 1 0 1 +After: [2, 1, 3, 3] + +Before: [2, 0, 2, 3] +13 0 3 0 +After: [0, 0, 2, 3] + +Before: [2, 0, 1, 1] +15 3 1 0 +After: [1, 0, 1, 1] + +Before: [0, 3, 3, 2] +8 1 3 1 +After: [0, 1, 3, 2] + +Before: [0, 2, 3, 0] +10 0 0 0 +After: [0, 2, 3, 0] + +Before: [2, 1, 0, 3] +13 0 3 3 +After: [2, 1, 0, 0] + +Before: [2, 2, 0, 2] +6 0 1 2 +After: [2, 2, 3, 2] + +Before: [0, 1, 0, 0] +0 1 0 1 +After: [0, 1, 0, 0] + +Before: [0, 0, 1, 2] +1 0 1 3 +After: [0, 0, 1, 1] + +Before: [0, 0, 2, 2] +12 2 2 1 +After: [0, 4, 2, 2] + +Before: [2, 0, 1, 1] +6 1 2 1 +After: [2, 2, 1, 1] + +Before: [1, 2, 0, 0] +6 1 1 1 +After: [1, 3, 0, 0] + +Before: [0, 1, 1, 1] +0 1 0 0 +After: [1, 1, 1, 1] + +Before: [0, 1, 3, 3] +0 1 0 3 +After: [0, 1, 3, 1] + +Before: [1, 0, 0, 0] +4 1 0 1 +After: [1, 1, 0, 0] + +Before: [0, 0, 2, 1] +3 3 2 3 +After: [0, 0, 2, 2] + +Before: [1, 0, 0, 3] +4 1 0 0 +After: [1, 0, 0, 3] + +Before: [0, 0, 1, 1] +15 3 1 0 +After: [1, 0, 1, 1] + +Before: [1, 3, 0, 2] +8 1 3 2 +After: [1, 3, 1, 2] + +Before: [2, 0, 3, 1] +11 1 0 0 +After: [1, 0, 3, 1] + +Before: [1, 0, 3, 3] +13 0 3 1 +After: [1, 0, 3, 3] + +Before: [0, 3, 3, 3] +7 3 1 0 +After: [9, 3, 3, 3] + +Before: [0, 0, 2, 0] +12 2 2 3 +After: [0, 0, 2, 4] + +Before: [1, 0, 1, 3] +4 1 0 0 +After: [1, 0, 1, 3] + +Before: [3, 2, 3, 1] +9 3 2 3 +After: [3, 2, 3, 3] + +Before: [3, 2, 3, 2] +11 1 2 2 +After: [3, 2, 1, 2] + +Before: [0, 3, 2, 3] +2 1 2 0 +After: [1, 3, 2, 3] + +Before: [0, 2, 2, 3] +6 1 1 3 +After: [0, 2, 2, 3] + +Before: [3, 3, 2, 3] +2 1 2 1 +After: [3, 1, 2, 3] + +Before: [3, 0, 2, 2] +14 0 3 0 +After: [6, 0, 2, 2] + +Before: [0, 1, 1, 2] +10 0 0 3 +After: [0, 1, 1, 0] + +Before: [0, 3, 1, 2] +8 1 3 0 +After: [1, 3, 1, 2] + +Before: [0, 0, 3, 0] +1 0 1 2 +After: [0, 0, 1, 0] + +Before: [0, 1, 1, 2] +0 1 0 3 +After: [0, 1, 1, 1] + +Before: [3, 2, 2, 1] +14 3 1 0 +After: [2, 2, 2, 1] + +Before: [0, 2, 2, 0] +12 2 2 3 +After: [0, 2, 2, 4] + +Before: [0, 0, 2, 2] +10 0 0 0 +After: [0, 0, 2, 2] + +Before: [0, 0, 2, 0] +10 0 0 1 +After: [0, 0, 2, 0] + +Before: [3, 1, 2, 3] +3 3 2 2 +After: [3, 1, 6, 3] + +Before: [2, 3, 1, 2] +8 1 3 0 +After: [1, 3, 1, 2] + +Before: [1, 1, 3, 1] +5 1 2 0 +After: [3, 1, 3, 1] + +Before: [1, 0, 1, 2] +4 1 0 3 +After: [1, 0, 1, 1] + +Before: [1, 0, 3, 3] +13 0 3 3 +After: [1, 0, 3, 0] + +Before: [1, 2, 3, 3] +11 1 2 2 +After: [1, 2, 1, 3] + +Before: [3, 3, 1, 2] +8 1 3 1 +After: [3, 1, 1, 2] + +Before: [2, 2, 2, 3] +13 0 3 2 +After: [2, 2, 0, 3] + +Before: [0, 0, 1, 2] +1 0 1 0 +After: [1, 0, 1, 2] + +Before: [0, 0, 2, 0] +12 2 2 0 +After: [4, 0, 2, 0] + +Before: [0, 3, 0, 1] +10 0 0 0 +After: [0, 3, 0, 1] + +Before: [2, 3, 3, 0] +7 2 0 3 +After: [2, 3, 3, 6] + +Before: [1, 1, 2, 2] +9 3 1 2 +After: [1, 1, 3, 2] + +Before: [1, 1, 3, 2] +9 3 1 3 +After: [1, 1, 3, 3] + +Before: [3, 3, 2, 2] +2 1 2 2 +After: [3, 3, 1, 2] + +Before: [2, 3, 2, 3] +2 1 2 1 +After: [2, 1, 2, 3] + +Before: [0, 0, 2, 0] +1 0 1 1 +After: [0, 1, 2, 0] + +Before: [0, 1, 2, 0] +0 1 0 0 +After: [1, 1, 2, 0] + +Before: [1, 3, 3, 3] +13 0 3 3 +After: [1, 3, 3, 0] + +Before: [2, 3, 3, 2] +2 1 0 3 +After: [2, 3, 3, 1] + +Before: [1, 2, 3, 3] +13 0 3 0 +After: [0, 2, 3, 3] + +Before: [1, 1, 2, 2] +9 3 1 0 +After: [3, 1, 2, 2] + +Before: [1, 2, 0, 1] +14 3 1 3 +After: [1, 2, 0, 2] + +Before: [0, 0, 2, 1] +12 2 2 3 +After: [0, 0, 2, 4] + +Before: [3, 1, 2, 1] +9 3 2 3 +After: [3, 1, 2, 3] + +Before: [3, 1, 2, 1] +9 3 2 1 +After: [3, 3, 2, 1] + +Before: [2, 0, 2, 2] +12 2 2 1 +After: [2, 4, 2, 2] + +Before: [0, 1, 3, 1] +0 1 0 0 +After: [1, 1, 3, 1] + +Before: [3, 3, 1, 2] +7 1 1 0 +After: [9, 3, 1, 2] + +Before: [0, 0, 3, 1] +1 0 1 2 +After: [0, 0, 1, 1] + +Before: [1, 0, 3, 1] +15 3 1 1 +After: [1, 1, 3, 1] + +Before: [3, 1, 1, 2] +14 0 3 0 +After: [6, 1, 1, 2] + +Before: [0, 1, 1, 0] +0 1 0 0 +After: [1, 1, 1, 0] + +Before: [0, 3, 3, 2] +3 3 2 3 +After: [0, 3, 3, 4] + +Before: [2, 0, 3, 3] +11 1 0 1 +After: [2, 1, 3, 3] + +Before: [1, 1, 2, 2] +12 2 2 1 +After: [1, 4, 2, 2] + +Before: [3, 2, 1, 0] +3 2 3 2 +After: [3, 2, 3, 0] + +Before: [1, 0, 3, 2] +15 0 1 1 +After: [1, 1, 3, 2] + +Before: [1, 3, 1, 1] +6 2 2 1 +After: [1, 3, 1, 1] + +Before: [1, 1, 0, 3] +5 2 3 1 +After: [1, 3, 0, 3] + +Before: [3, 1, 2, 1] +5 1 2 2 +After: [3, 1, 3, 1] + +Before: [0, 1, 1, 2] +5 0 1 1 +After: [0, 1, 1, 2] + +Before: [0, 0, 2, 3] +1 0 1 3 +After: [0, 0, 2, 1] + +Before: [0, 0, 3, 1] +10 0 0 0 +After: [0, 0, 3, 1] + +Before: [3, 0, 3, 0] +7 2 2 2 +After: [3, 0, 9, 0] + +Before: [3, 1, 0, 2] +14 0 3 2 +After: [3, 1, 6, 2] + +Before: [3, 3, 3, 2] +8 1 3 0 +After: [1, 3, 3, 2] + +Before: [0, 3, 0, 2] +8 1 3 2 +After: [0, 3, 1, 2] + +Before: [2, 3, 2, 0] +2 1 2 0 +After: [1, 3, 2, 0] + +Before: [0, 1, 1, 2] +9 3 1 2 +After: [0, 1, 3, 2] + +Before: [1, 1, 0, 0] +6 0 2 3 +After: [1, 1, 0, 3] + +Before: [3, 2, 2, 2] +7 3 0 2 +After: [3, 2, 6, 2] + +Before: [0, 0, 0, 2] +1 0 1 0 +After: [1, 0, 0, 2] + +Before: [0, 2, 1, 3] +3 3 3 3 +After: [0, 2, 1, 9] + +Before: [1, 2, 0, 0] +14 0 1 3 +After: [1, 2, 0, 2] + +Before: [0, 0, 1, 0] +15 2 1 1 +After: [0, 1, 1, 0] + +Before: [3, 1, 1, 2] +9 3 1 3 +After: [3, 1, 1, 3] + +Before: [1, 1, 2, 2] +7 0 3 1 +After: [1, 2, 2, 2] + +Before: [0, 3, 1, 2] +8 1 3 3 +After: [0, 3, 1, 1] + +Before: [3, 0, 2, 0] +11 1 0 0 +After: [1, 0, 2, 0] + +Before: [2, 1, 0, 2] +7 1 0 3 +After: [2, 1, 0, 2] + +Before: [2, 3, 2, 1] +12 0 2 1 +After: [2, 4, 2, 1] + +Before: [1, 1, 0, 3] +13 0 3 0 +After: [0, 1, 0, 3] + +Before: [3, 0, 0, 1] +6 1 3 0 +After: [3, 0, 0, 1] + +Before: [2, 2, 2, 1] +6 0 1 3 +After: [2, 2, 2, 3] + +Before: [0, 2, 3, 1] +10 0 0 0 +After: [0, 2, 3, 1] + +Before: [0, 1, 1, 0] +0 1 0 1 +After: [0, 1, 1, 0] + +Before: [1, 0, 2, 2] +4 1 0 0 +After: [1, 0, 2, 2] + +Before: [2, 3, 0, 2] +8 1 3 2 +After: [2, 3, 1, 2] + +Before: [2, 3, 0, 1] +2 1 0 3 +After: [2, 3, 0, 1] + +Before: [0, 0, 2, 3] +1 0 1 2 +After: [0, 0, 1, 3] + +Before: [3, 3, 1, 0] +6 3 2 3 +After: [3, 3, 1, 2] + +Before: [2, 3, 3, 1] +2 1 0 1 +After: [2, 1, 3, 1] + +Before: [2, 0, 0, 1] +6 0 1 3 +After: [2, 0, 0, 3] + +Before: [0, 2, 1, 3] +10 0 0 0 +After: [0, 2, 1, 3] + +Before: [3, 3, 3, 0] +7 2 2 0 +After: [9, 3, 3, 0] + +Before: [2, 1, 1, 1] +7 3 0 3 +After: [2, 1, 1, 2] + +Before: [0, 3, 2, 2] +2 1 2 0 +After: [1, 3, 2, 2] + +Before: [2, 1, 2, 0] +3 1 2 3 +After: [2, 1, 2, 2] + +Before: [2, 3, 2, 2] +2 1 0 2 +After: [2, 3, 1, 2] + +Before: [3, 0, 1, 2] +11 1 0 3 +After: [3, 0, 1, 1] + +Before: [1, 2, 3, 2] +14 2 3 0 +After: [6, 2, 3, 2] + +Before: [0, 0, 0, 1] +1 0 1 1 +After: [0, 1, 0, 1] + +Before: [3, 0, 1, 2] +15 2 1 1 +After: [3, 1, 1, 2] + +Before: [1, 0, 3, 0] +4 1 0 3 +After: [1, 0, 3, 1] + +Before: [0, 2, 3, 0] +10 0 0 3 +After: [0, 2, 3, 0] + +Before: [0, 2, 0, 0] +6 3 2 0 +After: [2, 2, 0, 0] + +Before: [1, 1, 2, 2] +12 2 2 3 +After: [1, 1, 2, 4] + +Before: [3, 2, 1, 1] +3 2 3 0 +After: [3, 2, 1, 1] + +Before: [0, 1, 1, 2] +5 0 1 3 +After: [0, 1, 1, 1] + +Before: [3, 1, 3, 2] +9 3 1 3 +After: [3, 1, 3, 3] + +Before: [1, 0, 2, 3] +4 1 0 2 +After: [1, 0, 1, 3] + +Before: [3, 2, 1, 2] +6 2 2 2 +After: [3, 2, 3, 2] + +Before: [2, 0, 1, 3] +11 1 0 2 +After: [2, 0, 1, 3] + +Before: [1, 0, 3, 1] +4 1 0 2 +After: [1, 0, 1, 1] + +Before: [2, 0, 2, 1] +12 2 2 2 +After: [2, 0, 4, 1] + +Before: [0, 3, 2, 0] +12 2 2 3 +After: [0, 3, 2, 4] + +Before: [1, 3, 2, 2] +14 1 3 3 +After: [1, 3, 2, 6] + +Before: [0, 0, 3, 0] +10 0 0 1 +After: [0, 0, 3, 0] + +Before: [0, 2, 3, 1] +11 1 2 2 +After: [0, 2, 1, 1] + +Before: [1, 0, 3, 2] +4 1 0 1 +After: [1, 1, 3, 2] + +Before: [1, 2, 2, 3] +12 1 2 1 +After: [1, 4, 2, 3] + +Before: [0, 0, 1, 2] +15 2 1 1 +After: [0, 1, 1, 2] + +Before: [0, 1, 3, 2] +0 1 0 2 +After: [0, 1, 1, 2] + +Before: [1, 0, 3, 1] +4 1 0 3 +After: [1, 0, 3, 1] + +Before: [1, 2, 2, 1] +6 2 1 2 +After: [1, 2, 3, 1] + +Before: [0, 1, 2, 1] +10 0 0 2 +After: [0, 1, 0, 1] + +Before: [0, 1, 1, 3] +5 1 3 1 +After: [0, 3, 1, 3] + +Before: [2, 3, 1, 2] +2 1 0 2 +After: [2, 3, 1, 2] + +Before: [0, 1, 2, 2] +9 3 1 3 +After: [0, 1, 2, 3] + +Before: [1, 0, 1, 0] +15 0 1 1 +After: [1, 1, 1, 0] + +Before: [0, 1, 0, 0] +0 1 0 3 +After: [0, 1, 0, 1] + +Before: [2, 3, 3, 1] +7 0 2 1 +After: [2, 6, 3, 1] + +Before: [1, 1, 0, 1] +6 1 2 2 +After: [1, 1, 3, 1] + +Before: [0, 2, 2, 3] +7 3 1 2 +After: [0, 2, 6, 3] + +Before: [0, 3, 2, 2] +8 1 3 2 +After: [0, 3, 1, 2] + +Before: [2, 0, 2, 1] +11 1 0 0 +After: [1, 0, 2, 1] + +Before: [3, 0, 3, 3] +7 3 0 0 +After: [9, 0, 3, 3] + +Before: [0, 0, 3, 3] +1 0 1 1 +After: [0, 1, 3, 3] + +Before: [3, 2, 3, 2] +14 2 3 3 +After: [3, 2, 3, 6] + +Before: [2, 0, 2, 3] +13 0 3 1 +After: [2, 0, 2, 3] + +Before: [1, 0, 3, 2] +4 1 0 3 +After: [1, 0, 3, 1] + +Before: [0, 2, 2, 0] +10 0 0 1 +After: [0, 0, 2, 0] + +Before: [0, 1, 2, 3] +0 1 0 1 +After: [0, 1, 2, 3] + +Before: [2, 0, 3, 1] +15 3 1 2 +After: [2, 0, 1, 1] + +Before: [0, 0, 2, 1] +15 3 1 1 +After: [0, 1, 2, 1] + +Before: [0, 1, 3, 2] +14 2 3 3 +After: [0, 1, 3, 6] + +Before: [0, 3, 1, 2] +14 1 3 1 +After: [0, 6, 1, 2] + +Before: [1, 2, 3, 3] +11 1 2 0 +After: [1, 2, 3, 3] + +Before: [1, 1, 3, 2] +14 2 3 3 +After: [1, 1, 3, 6] + +Before: [3, 3, 2, 2] +7 2 0 3 +After: [3, 3, 2, 6] + +Before: [0, 3, 3, 1] +6 0 3 1 +After: [0, 3, 3, 1] + +Before: [2, 3, 2, 3] +13 0 3 2 +After: [2, 3, 0, 3] + +Before: [0, 2, 0, 1] +14 3 1 3 +After: [0, 2, 0, 2] + +Before: [2, 0, 3, 0] +6 3 2 3 +After: [2, 0, 3, 2] + +Before: [0, 0, 0, 0] +1 0 1 1 +After: [0, 1, 0, 0] + +Before: [2, 2, 3, 1] +3 1 2 3 +After: [2, 2, 3, 4] + +Before: [1, 0, 2, 1] +5 0 2 2 +After: [1, 0, 3, 1] + +Before: [0, 1, 3, 1] +10 0 0 2 +After: [0, 1, 0, 1] + +Before: [0, 0, 2, 0] +1 0 1 0 +After: [1, 0, 2, 0] + +Before: [2, 1, 1, 3] +6 2 2 2 +After: [2, 1, 3, 3] + +Before: [2, 1, 1, 0] +3 2 3 1 +After: [2, 3, 1, 0] + +Before: [2, 2, 3, 3] +3 0 2 0 +After: [4, 2, 3, 3] + +Before: [1, 0, 1, 3] +13 0 3 3 +After: [1, 0, 1, 0] + +Before: [3, 3, 3, 2] +14 0 3 0 +After: [6, 3, 3, 2] + +Before: [0, 1, 3, 3] +3 2 3 3 +After: [0, 1, 3, 9] + +Before: [0, 3, 2, 0] +12 2 2 1 +After: [0, 4, 2, 0] + +Before: [3, 3, 2, 2] +8 1 3 1 +After: [3, 1, 2, 2] + +Before: [3, 2, 0, 2] +6 2 3 0 +After: [3, 2, 0, 2] + +Before: [1, 0, 3, 3] +6 1 2 2 +After: [1, 0, 2, 3] + +Before: [3, 3, 2, 2] +8 1 3 3 +After: [3, 3, 2, 1] + +Before: [0, 1, 3, 1] +0 1 0 3 +After: [0, 1, 3, 1] + +Before: [1, 1, 3, 1] +9 3 2 0 +After: [3, 1, 3, 1] + +Before: [2, 3, 0, 1] +7 3 0 1 +After: [2, 2, 0, 1] + +Before: [3, 3, 0, 2] +8 1 3 0 +After: [1, 3, 0, 2] + +Before: [2, 2, 2, 3] +12 0 2 1 +After: [2, 4, 2, 3] + +Before: [0, 2, 1, 2] +10 0 0 0 +After: [0, 2, 1, 2] + +Before: [1, 0, 2, 3] +4 1 0 3 +After: [1, 0, 2, 1] + +Before: [3, 1, 3, 3] +7 3 2 0 +After: [9, 1, 3, 3] + +Before: [1, 0, 1, 1] +15 2 1 1 +After: [1, 1, 1, 1] + +Before: [2, 3, 2, 0] +2 1 2 3 +After: [2, 3, 2, 1] + +Before: [1, 3, 0, 2] +8 1 3 3 +After: [1, 3, 0, 1] + +Before: [1, 0, 0, 2] +6 0 2 3 +After: [1, 0, 0, 3] + +Before: [2, 1, 1, 3] +13 0 3 3 +After: [2, 1, 1, 0] + +Before: [0, 3, 3, 3] +10 0 0 0 +After: [0, 3, 3, 3] + +Before: [2, 1, 1, 3] +13 0 3 1 +After: [2, 0, 1, 3] + +Before: [1, 0, 2, 1] +4 1 0 2 +After: [1, 0, 1, 1] + +Before: [1, 1, 0, 3] +5 0 3 3 +After: [1, 1, 0, 3] + +Before: [2, 3, 1, 0] +6 3 2 1 +After: [2, 2, 1, 0] + +Before: [1, 1, 3, 2] +9 3 1 0 +After: [3, 1, 3, 2] + +Before: [0, 1, 1, 2] +5 2 3 2 +After: [0, 1, 3, 2] + +Before: [1, 3, 0, 2] +8 1 3 1 +After: [1, 1, 0, 2] + +Before: [0, 1, 0, 1] +0 1 0 3 +After: [0, 1, 0, 1] + +Before: [3, 1, 2, 2] +14 0 3 3 +After: [3, 1, 2, 6] + +Before: [0, 3, 3, 2] +8 1 3 3 +After: [0, 3, 3, 1] + +Before: [0, 0, 2, 2] +1 0 1 2 +After: [0, 0, 1, 2] + +Before: [3, 3, 2, 0] +2 1 2 2 +After: [3, 3, 1, 0] + +Before: [0, 0, 0, 3] +10 0 0 2 +After: [0, 0, 0, 3] + +Before: [0, 1, 2, 2] +0 1 0 1 +After: [0, 1, 2, 2] + +Before: [2, 2, 2, 3] +12 2 2 1 +After: [2, 4, 2, 3] + +Before: [1, 3, 3, 3] +13 0 3 0 +After: [0, 3, 3, 3] + +Before: [1, 2, 3, 3] +14 0 1 1 +After: [1, 2, 3, 3] + +Before: [1, 0, 2, 0] +3 0 3 0 +After: [3, 0, 2, 0] + +Before: [3, 2, 2, 2] +6 1 1 0 +After: [3, 2, 2, 2] + +Before: [0, 0, 0, 3] +1 0 1 2 +After: [0, 0, 1, 3] + +Before: [2, 0, 0, 1] +15 3 1 1 +After: [2, 1, 0, 1] + +Before: [1, 0, 0, 1] +4 1 0 1 +After: [1, 1, 0, 1] + +Before: [1, 0, 2, 1] +4 1 0 3 +After: [1, 0, 2, 1] + +Before: [1, 0, 3, 0] +4 1 0 0 +After: [1, 0, 3, 0] + +Before: [0, 2, 3, 1] +11 1 2 0 +After: [1, 2, 3, 1] + +Before: [1, 0, 0, 2] +4 1 0 0 +After: [1, 0, 0, 2] + +Before: [0, 3, 3, 1] +9 3 2 3 +After: [0, 3, 3, 3] + +Before: [2, 1, 2, 2] +9 3 1 3 +After: [2, 1, 2, 3] + +Before: [0, 1, 2, 3] +0 1 0 3 +After: [0, 1, 2, 1] + +Before: [3, 3, 3, 0] +7 2 1 3 +After: [3, 3, 3, 9] + +Before: [0, 3, 1, 0] +7 1 1 2 +After: [0, 3, 9, 0] + +Before: [0, 0, 1, 2] +1 0 1 1 +After: [0, 1, 1, 2] + +Before: [2, 0, 1, 3] +15 2 1 1 +After: [2, 1, 1, 3] + +Before: [0, 3, 1, 2] +8 1 3 2 +After: [0, 3, 1, 2] + +Before: [0, 1, 2, 1] +0 1 0 0 +After: [1, 1, 2, 1] + +Before: [2, 2, 3, 3] +11 1 2 1 +After: [2, 1, 3, 3] + +Before: [0, 2, 3, 2] +10 0 0 2 +After: [0, 2, 0, 2] + +Before: [2, 2, 3, 1] +3 1 2 2 +After: [2, 2, 4, 1] + +Before: [3, 0, 0, 3] +11 1 0 0 +After: [1, 0, 0, 3] + +Before: [3, 1, 2, 2] +12 3 2 0 +After: [4, 1, 2, 2] + +Before: [2, 0, 0, 3] +5 2 3 0 +After: [3, 0, 0, 3] + +Before: [1, 0, 1, 1] +15 3 1 2 +After: [1, 0, 1, 1] + +Before: [3, 3, 2, 2] +14 0 3 0 +After: [6, 3, 2, 2] + +Before: [1, 0, 1, 3] +6 0 2 0 +After: [3, 0, 1, 3] + +Before: [2, 3, 2, 3] +2 1 0 1 +After: [2, 1, 2, 3] + +Before: [0, 2, 2, 1] +12 2 2 0 +After: [4, 2, 2, 1] + +Before: [0, 1, 2, 2] +12 2 2 2 +After: [0, 1, 4, 2] + +Before: [1, 0, 1, 2] +3 3 2 1 +After: [1, 4, 1, 2] + +Before: [1, 3, 3, 0] +5 0 2 2 +After: [1, 3, 3, 0] + +Before: [3, 3, 2, 1] +2 1 2 0 +After: [1, 3, 2, 1] + +Before: [3, 3, 1, 2] +8 1 3 2 +After: [3, 3, 1, 2] + +Before: [3, 2, 3, 3] +11 1 2 3 +After: [3, 2, 3, 1] + +Before: [0, 0, 0, 2] +1 0 1 1 +After: [0, 1, 0, 2] + +Before: [2, 0, 1, 1] +15 3 1 3 +After: [2, 0, 1, 1] + +Before: [3, 3, 3, 2] +14 2 3 1 +After: [3, 6, 3, 2] + +Before: [1, 1, 3, 1] +9 3 2 1 +After: [1, 3, 3, 1] + +Before: [2, 3, 1, 1] +2 1 0 3 +After: [2, 3, 1, 1] + +Before: [3, 0, 0, 1] +15 3 1 1 +After: [3, 1, 0, 1] + +Before: [3, 3, 3, 2] +14 0 3 3 +After: [3, 3, 3, 6] + +Before: [1, 2, 2, 3] +13 0 3 3 +After: [1, 2, 2, 0] + +Before: [0, 1, 2, 0] +0 1 0 1 +After: [0, 1, 2, 0] + +Before: [0, 1, 2, 1] +5 2 1 0 +After: [3, 1, 2, 1] + +Before: [0, 0, 3, 1] +15 3 1 2 +After: [0, 0, 1, 1] + +Before: [2, 3, 0, 2] +7 1 0 2 +After: [2, 3, 6, 2] + +Before: [3, 0, 3, 2] +14 2 3 3 +After: [3, 0, 3, 6] + +Before: [1, 0, 1, 3] +13 0 3 0 +After: [0, 0, 1, 3] + +Before: [0, 1, 0, 3] +0 1 0 2 +After: [0, 1, 1, 3] + +Before: [0, 0, 2, 2] +1 0 1 0 +After: [1, 0, 2, 2] + +Before: [2, 0, 1, 3] +5 1 3 0 +After: [3, 0, 1, 3] + +Before: [2, 3, 2, 2] +8 1 3 1 +After: [2, 1, 2, 2] + +Before: [2, 3, 2, 2] +8 1 3 0 +After: [1, 3, 2, 2] + +Before: [3, 1, 2, 2] +14 0 3 2 +After: [3, 1, 6, 2] + +Before: [3, 0, 2, 2] +14 0 3 1 +After: [3, 6, 2, 2] + +Before: [3, 1, 3, 2] +9 3 1 2 +After: [3, 1, 3, 2] + +Before: [2, 0, 2, 3] +12 0 2 3 +After: [2, 0, 2, 4] + +Before: [0, 1, 0, 2] +0 1 0 0 +After: [1, 1, 0, 2] + +Before: [1, 2, 2, 3] +13 0 3 2 +After: [1, 2, 0, 3] + +Before: [2, 0, 1, 1] +11 1 0 2 +After: [2, 0, 1, 1] + +Before: [0, 0, 0, 1] +1 0 1 3 +After: [0, 0, 0, 1] + +Before: [2, 3, 0, 0] +2 1 0 0 +After: [1, 3, 0, 0] + +Before: [0, 3, 2, 0] +2 1 2 3 +After: [0, 3, 2, 1] + +Before: [2, 2, 3, 2] +14 2 3 1 +After: [2, 6, 3, 2] + +Before: [0, 3, 2, 2] +8 1 3 1 +After: [0, 1, 2, 2] + +Before: [0, 0, 2, 1] +1 0 1 0 +After: [1, 0, 2, 1] + +Before: [3, 0, 1, 0] +15 2 1 3 +After: [3, 0, 1, 1] + +Before: [1, 3, 2, 3] +13 0 3 3 +After: [1, 3, 2, 0] + +Before: [0, 1, 0, 1] +10 0 0 1 +After: [0, 0, 0, 1] + +Before: [0, 1, 0, 2] +10 0 0 1 +After: [0, 0, 0, 2] + +Before: [3, 2, 0, 1] +7 0 0 3 +After: [3, 2, 0, 9] + +Before: [1, 2, 2, 1] +14 3 1 3 +After: [1, 2, 2, 2] + +Before: [0, 0, 3, 0] +1 0 1 0 +After: [1, 0, 3, 0] + +Before: [1, 0, 1, 0] +15 2 1 0 +After: [1, 0, 1, 0] + +Before: [0, 2, 1, 1] +14 3 1 1 +After: [0, 2, 1, 1] + +Before: [0, 1, 0, 2] +0 1 0 3 +After: [0, 1, 0, 1] + +Before: [1, 1, 0, 2] +9 3 1 2 +After: [1, 1, 3, 2] + +Before: [0, 1, 0, 3] +0 1 0 0 +After: [1, 1, 0, 3] + +Before: [1, 3, 2, 1] +2 1 2 2 +After: [1, 3, 1, 1] + +Before: [3, 3, 3, 3] +7 3 0 0 +After: [9, 3, 3, 3] + +Before: [1, 2, 1, 3] +14 0 1 0 +After: [2, 2, 1, 3] + +Before: [1, 2, 0, 0] +6 3 2 0 +After: [2, 2, 0, 0] + +Before: [0, 0, 1, 3] +15 2 1 2 +After: [0, 0, 1, 3] + +Before: [0, 0, 2, 3] +1 0 1 1 +After: [0, 1, 2, 3] + +Before: [2, 1, 2, 1] +5 0 1 2 +After: [2, 1, 3, 1] + +Before: [3, 2, 2, 0] +12 1 2 2 +After: [3, 2, 4, 0] + +Before: [0, 0, 3, 0] +6 0 3 0 +After: [3, 0, 3, 0] + +Before: [1, 3, 1, 2] +8 1 3 1 +After: [1, 1, 1, 2] + +Before: [1, 2, 2, 2] +12 2 2 1 +After: [1, 4, 2, 2] + +Before: [3, 1, 2, 3] +5 1 2 1 +After: [3, 3, 2, 3] + +Before: [3, 2, 1, 2] +14 0 3 1 +After: [3, 6, 1, 2] + +Before: [0, 3, 3, 1] +9 3 2 2 +After: [0, 3, 3, 1] + +Before: [3, 0, 0, 1] +11 1 0 2 +After: [3, 0, 1, 1] + +Before: [1, 1, 2, 0] +5 2 1 3 +After: [1, 1, 2, 3] + +Before: [2, 1, 2, 2] +5 2 1 1 +After: [2, 3, 2, 2] + +Before: [1, 0, 3, 1] +15 0 1 0 +After: [1, 0, 3, 1] + +Before: [2, 1, 3, 2] +7 1 0 0 +After: [2, 1, 3, 2] + +Before: [0, 0, 3, 0] +6 1 3 1 +After: [0, 3, 3, 0] + +Before: [1, 3, 2, 2] +2 1 2 3 +After: [1, 3, 2, 1] + +Before: [2, 1, 3, 3] +3 2 3 0 +After: [9, 1, 3, 3] + +Before: [0, 0, 3, 3] +3 3 3 2 +After: [0, 0, 9, 3] + +Before: [0, 3, 2, 2] +8 1 3 0 +After: [1, 3, 2, 2] + +Before: [2, 1, 1, 2] +9 3 1 2 +After: [2, 1, 3, 2] + +Before: [1, 3, 1, 2] +8 1 3 3 +After: [1, 3, 1, 1] + +Before: [3, 2, 2, 1] +12 1 2 0 +After: [4, 2, 2, 1] + +Before: [0, 1, 3, 0] +0 1 0 2 +After: [0, 1, 1, 0] + +Before: [1, 0, 1, 2] +4 1 0 0 +After: [1, 0, 1, 2] + +Before: [0, 0, 3, 2] +1 0 1 2 +After: [0, 0, 1, 2] + +Before: [1, 2, 2, 0] +5 0 2 1 +After: [1, 3, 2, 0] + +Before: [1, 1, 2, 3] +13 0 3 3 +After: [1, 1, 2, 0] + +Before: [0, 1, 1, 1] +0 1 0 1 +After: [0, 1, 1, 1] + +Before: [1, 1, 1, 2] +7 0 3 0 +After: [2, 1, 1, 2] + +Before: [0, 0, 2, 1] +1 0 1 3 +After: [0, 0, 2, 1] + +Before: [3, 3, 3, 3] +7 2 0 0 +After: [9, 3, 3, 3] + +Before: [0, 1, 1, 2] +9 3 1 3 +After: [0, 1, 1, 3] + +Before: [3, 3, 0, 2] +8 1 3 1 +After: [3, 1, 0, 2] + +Before: [1, 1, 0, 3] +13 0 3 2 +After: [1, 1, 0, 3] + +Before: [2, 3, 0, 3] +2 1 0 3 +After: [2, 3, 0, 1] + +Before: [3, 0, 1, 2] +11 1 0 2 +After: [3, 0, 1, 2] + +Before: [0, 2, 2, 1] +14 3 1 2 +After: [0, 2, 2, 1] + +Before: [1, 2, 3, 1] +3 0 3 0 +After: [3, 2, 3, 1] + +Before: [0, 1, 3, 3] +0 1 0 1 +After: [0, 1, 3, 3] + +Before: [1, 0, 1, 3] +4 1 0 3 +After: [1, 0, 1, 1] + +Before: [2, 3, 3, 1] +7 0 2 3 +After: [2, 3, 3, 6] + +Before: [2, 2, 3, 1] +11 1 2 2 +After: [2, 2, 1, 1] + +Before: [0, 3, 3, 1] +9 3 2 0 +After: [3, 3, 3, 1] + +Before: [1, 0, 1, 2] +15 0 1 0 +After: [1, 0, 1, 2] + +Before: [0, 1, 3, 0] +7 2 2 3 +After: [0, 1, 3, 9] + +Before: [2, 3, 2, 1] +2 1 0 1 +After: [2, 1, 2, 1] + +Before: [1, 1, 2, 0] +3 1 2 0 +After: [2, 1, 2, 0] + +Before: [2, 3, 0, 2] +2 1 0 0 +After: [1, 3, 0, 2] + +Before: [3, 1, 3, 1] +9 3 2 2 +After: [3, 1, 3, 1] + +Before: [0, 1, 3, 1] +0 1 0 1 +After: [0, 1, 3, 1] + +Before: [0, 1, 2, 1] +0 1 0 3 +After: [0, 1, 2, 1] + +Before: [0, 3, 2, 3] +5 0 3 2 +After: [0, 3, 3, 3] + +Before: [1, 2, 1, 3] +6 1 1 2 +After: [1, 2, 3, 3] + +Before: [1, 0, 1, 3] +13 0 3 2 +After: [1, 0, 0, 3] + +Before: [0, 0, 1, 1] +1 0 1 3 +After: [0, 0, 1, 1] + +Before: [2, 2, 1, 1] +14 3 1 1 +After: [2, 2, 1, 1] + +Before: [0, 2, 1, 2] +10 0 0 2 +After: [0, 2, 0, 2] + +Before: [1, 1, 2, 2] +5 2 1 3 +After: [1, 1, 2, 3] + +Before: [3, 0, 1, 2] +14 0 3 1 +After: [3, 6, 1, 2] + +Before: [1, 3, 0, 3] +7 3 1 0 +After: [9, 3, 0, 3] + +Before: [1, 0, 2, 3] +4 1 0 0 +After: [1, 0, 2, 3] + +Before: [0, 1, 0, 2] +9 3 1 3 +After: [0, 1, 0, 3] + +Before: [2, 3, 1, 1] +2 1 0 2 +After: [2, 3, 1, 1] + +Before: [0, 0, 0, 0] +1 0 1 3 +After: [0, 0, 0, 1] + +Before: [0, 1, 1, 3] +5 0 1 2 +After: [0, 1, 1, 3] + +Before: [2, 3, 2, 3] +2 1 0 3 +After: [2, 3, 2, 1] + +Before: [2, 3, 2, 1] +2 1 0 2 +After: [2, 3, 1, 1] + +Before: [1, 0, 1, 1] +4 1 0 0 +After: [1, 0, 1, 1] + +Before: [0, 1, 1, 0] +6 1 2 2 +After: [0, 1, 3, 0] + +Before: [0, 0, 2, 2] +1 0 1 3 +After: [0, 0, 2, 1] + +Before: [2, 3, 2, 3] +7 1 0 2 +After: [2, 3, 6, 3] + +Before: [2, 2, 2, 0] +12 1 2 3 +After: [2, 2, 2, 4] + +Before: [1, 3, 1, 3] +13 0 3 0 +After: [0, 3, 1, 3] + +Before: [0, 0, 1, 1] +1 0 1 1 +After: [0, 1, 1, 1] + +Before: [3, 2, 2, 1] +9 3 2 0 +After: [3, 2, 2, 1] + +Before: [0, 2, 0, 1] +10 0 0 0 +After: [0, 2, 0, 1] + +Before: [0, 3, 2, 2] +8 1 3 3 +After: [0, 3, 2, 1] + +Before: [2, 1, 0, 0] +6 3 2 2 +After: [2, 1, 2, 0] + +Before: [0, 0, 1, 3] +5 0 3 3 +After: [0, 0, 1, 3] + +Before: [1, 0, 1, 2] +15 0 1 2 +After: [1, 0, 1, 2] + +Before: [0, 1, 0, 1] +0 1 0 0 +After: [1, 1, 0, 1] + +Before: [3, 2, 3, 1] +9 3 2 1 +After: [3, 3, 3, 1] + +Before: [2, 0, 1, 2] +15 2 1 3 +After: [2, 0, 1, 1] + +Before: [2, 3, 1, 2] +8 1 3 2 +After: [2, 3, 1, 2] + +Before: [1, 0, 1, 1] +4 1 0 3 +After: [1, 0, 1, 1] + +Before: [3, 1, 3, 2] +5 1 2 3 +After: [3, 1, 3, 3] + +Before: [0, 1, 3, 2] +0 1 0 3 +After: [0, 1, 3, 1] + +Before: [2, 3, 0, 0] +6 2 1 2 +After: [2, 3, 1, 0] + +Before: [2, 1, 2, 3] +12 2 2 3 +After: [2, 1, 2, 4] + +Before: [0, 0, 3, 1] +1 0 1 0 +After: [1, 0, 3, 1] + +Before: [0, 3, 2, 0] +6 0 1 2 +After: [0, 3, 1, 0] + +Before: [0, 0, 0, 3] +5 2 3 1 +After: [0, 3, 0, 3] + +Before: [3, 0, 3, 3] +3 2 3 0 +After: [9, 0, 3, 3] + +Before: [0, 0, 3, 3] +1 0 1 2 +After: [0, 0, 1, 3] + +Before: [0, 2, 3, 3] +10 0 0 2 +After: [0, 2, 0, 3] + +Before: [2, 3, 0, 2] +8 1 3 1 +After: [2, 1, 0, 2] + +Before: [1, 3, 1, 2] +14 1 3 0 +After: [6, 3, 1, 2] + +Before: [1, 0, 1, 0] +3 2 3 3 +After: [1, 0, 1, 3] + +Before: [3, 1, 0, 2] +9 3 1 1 +After: [3, 3, 0, 2] + +Before: [1, 3, 2, 1] +2 1 2 1 +After: [1, 1, 2, 1] + +Before: [2, 3, 2, 2] +8 1 3 2 +After: [2, 3, 1, 2] + +Before: [1, 2, 3, 3] +14 0 1 0 +After: [2, 2, 3, 3] + +Before: [0, 3, 0, 2] +8 1 3 0 +After: [1, 3, 0, 2] + +Before: [1, 2, 2, 2] +12 1 2 0 +After: [4, 2, 2, 2] + +Before: [3, 3, 1, 2] +7 0 0 3 +After: [3, 3, 1, 9] + +Before: [1, 3, 3, 2] +8 1 3 1 +After: [1, 1, 3, 2] + +Before: [0, 0, 0, 0] +1 0 1 2 +After: [0, 0, 1, 0] + +Before: [2, 3, 3, 2] +8 1 3 3 +After: [2, 3, 3, 1] + +Before: [1, 3, 2, 2] +8 1 3 0 +After: [1, 3, 2, 2] + +Before: [2, 0, 1, 0] +3 0 2 2 +After: [2, 0, 4, 0] + +Before: [1, 2, 3, 2] +14 0 1 3 +After: [1, 2, 3, 2] + +Before: [2, 3, 3, 0] +2 1 0 0 +After: [1, 3, 3, 0] + +Before: [3, 0, 0, 1] +11 1 0 0 +After: [1, 0, 0, 1] + +Before: [2, 3, 2, 3] +2 1 2 0 +After: [1, 3, 2, 3] + +Before: [2, 3, 0, 2] +7 1 0 0 +After: [6, 3, 0, 2] + +Before: [0, 0, 2, 1] +10 0 0 1 +After: [0, 0, 2, 1] + +Before: [1, 0, 3, 2] +4 1 0 0 +After: [1, 0, 3, 2] + +Before: [0, 0, 1, 2] +1 0 1 2 +After: [0, 0, 1, 2] + +Before: [2, 3, 2, 2] +12 3 2 1 +After: [2, 4, 2, 2] + +Before: [1, 1, 1, 3] +5 2 3 2 +After: [1, 1, 3, 3] + +Before: [0, 3, 2, 3] +2 1 2 2 +After: [0, 3, 1, 3] + +Before: [1, 0, 2, 3] +13 0 3 3 +After: [1, 0, 2, 0] + +Before: [2, 0, 0, 3] +13 0 3 1 +After: [2, 0, 0, 3] + +Before: [2, 3, 0, 2] +8 1 3 0 +After: [1, 3, 0, 2] + +Before: [0, 1, 2, 0] +0 1 0 3 +After: [0, 1, 2, 1] + +Before: [3, 2, 0, 2] +6 2 3 1 +After: [3, 3, 0, 2] + +Before: [2, 3, 1, 3] +2 1 0 1 +After: [2, 1, 1, 3] + +Before: [1, 0, 3, 3] +4 1 0 3 +After: [1, 0, 3, 1] + +Before: [1, 3, 3, 2] +8 1 3 3 +After: [1, 3, 3, 1] + +Before: [1, 1, 2, 1] +9 3 2 1 +After: [1, 3, 2, 1] + +Before: [1, 1, 0, 1] +3 1 3 0 +After: [3, 1, 0, 1] + +Before: [2, 0, 3, 0] +6 1 2 1 +After: [2, 2, 3, 0] + +Before: [1, 0, 3, 1] +4 1 0 0 +After: [1, 0, 3, 1] + +Before: [0, 0, 3, 2] +1 0 1 1 +After: [0, 1, 3, 2] + +Before: [1, 3, 2, 0] +2 1 2 2 +After: [1, 3, 1, 0] + +Before: [0, 3, 0, 3] +5 2 3 2 +After: [0, 3, 3, 3] + +Before: [0, 0, 1, 0] +6 1 3 3 +After: [0, 0, 1, 3] + +Before: [0, 1, 0, 2] +9 3 1 2 +After: [0, 1, 3, 2] + +Before: [2, 0, 0, 1] +11 1 0 2 +After: [2, 0, 1, 1] + +Before: [1, 3, 2, 3] +13 0 3 2 +After: [1, 3, 0, 3] + +Before: [2, 0, 1, 0] +11 1 0 2 +After: [2, 0, 1, 0] + + + +9 3 3 0 +9 1 0 1 +9 0 1 2 +3 1 2 2 +3 2 3 2 +12 3 2 3 +0 3 1 2 +9 1 1 0 +9 2 2 1 +9 2 1 3 +7 0 3 0 +3 0 1 0 +3 0 1 0 +12 0 2 2 +0 2 0 1 +9 0 0 0 +9 2 1 2 +9 3 0 2 +3 2 1 2 +12 2 1 1 +0 1 3 2 +3 1 0 3 +14 3 1 3 +9 3 2 1 +12 3 3 0 +3 0 1 0 +12 0 2 2 +0 2 1 0 +9 3 2 2 +9 0 2 3 +9 1 3 1 +4 3 2 1 +3 1 1 1 +12 0 1 0 +3 0 0 2 +14 2 0 2 +9 1 1 1 +3 1 2 3 +3 3 3 3 +12 3 0 0 +0 0 0 3 +3 0 0 1 +14 1 2 1 +3 3 0 0 +14 0 2 0 +3 1 0 2 +14 2 3 2 +5 0 2 2 +3 2 3 2 +12 2 3 3 +0 3 0 1 +9 3 3 2 +9 1 0 3 +5 0 2 2 +3 2 3 2 +12 1 2 1 +0 1 1 2 +9 3 2 3 +9 2 2 1 +9 1 3 0 +12 0 0 3 +3 3 3 3 +3 3 1 3 +12 2 3 2 +0 2 0 1 +9 2 1 3 +3 3 0 2 +14 2 0 2 +4 2 3 0 +3 0 1 0 +12 0 1 1 +0 1 3 2 +9 3 3 0 +3 2 0 3 +14 3 3 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 3 1 +9 1 3 3 +9 1 2 0 +12 3 3 3 +3 3 1 3 +12 2 3 2 +0 2 1 3 +3 3 0 2 +14 2 2 2 +9 3 1 0 +2 2 0 2 +3 2 2 2 +12 3 2 3 +0 3 3 1 +3 3 0 2 +14 2 2 2 +9 1 3 3 +9 1 1 0 +0 0 2 3 +3 3 2 3 +3 3 3 3 +12 1 3 1 +0 1 2 0 +9 2 3 1 +9 0 3 2 +9 2 0 3 +4 2 3 1 +3 1 2 1 +12 0 1 0 +0 0 3 3 +3 3 0 0 +14 0 3 0 +3 1 0 2 +14 2 3 2 +9 2 1 1 +5 1 2 2 +3 2 2 2 +12 3 2 3 +0 3 0 1 +9 0 1 2 +9 2 0 3 +4 2 3 3 +3 3 3 3 +12 1 3 1 +9 2 1 2 +9 2 2 3 +9 1 2 0 +0 0 2 0 +3 0 2 0 +3 0 3 0 +12 0 1 1 +0 1 2 2 +3 1 0 0 +14 0 0 0 +9 2 1 1 +6 1 3 1 +3 1 2 1 +12 1 2 2 +0 2 0 3 +3 0 0 1 +14 1 3 1 +9 3 3 0 +9 0 0 2 +11 2 0 0 +3 0 1 0 +12 0 3 3 +0 3 0 1 +9 2 0 0 +9 2 2 3 +4 2 3 3 +3 3 2 3 +12 1 3 1 +0 1 3 2 +9 2 2 1 +9 2 3 3 +1 0 3 3 +3 3 2 3 +12 3 2 2 +0 2 1 0 +9 3 0 1 +9 1 3 3 +9 3 0 2 +15 1 2 2 +3 2 1 2 +3 2 1 2 +12 0 2 0 +0 0 0 1 +9 2 1 0 +9 2 3 2 +7 3 0 2 +3 2 3 2 +12 1 2 1 +0 1 0 3 +9 0 2 1 +9 3 1 2 +9 3 2 0 +15 0 2 1 +3 1 1 1 +12 1 3 3 +0 3 3 0 \ No newline at end of file diff --git a/AoC2018.Runner/Properties/launchSettings.json b/AoC2018.Runner/Properties/launchSettings.json index 839f0bc..1e17ccd 100644 --- a/AoC2018.Runner/Properties/launchSettings.json +++ b/AoC2018.Runner/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "AoC2018.Runner": { "commandName": "Project", - "commandLineArgs": "15 2" + "commandLineArgs": "16 1" } } } \ No newline at end of file diff --git a/AoC2018.Solutions/Day15/Part02.cs b/AoC2018.Solutions/Day15/Part02.cs index 236dcb9..4f02906 100644 --- a/AoC2018.Solutions/Day15/Part02.cs +++ b/AoC2018.Solutions/Day15/Part02.cs @@ -1,6 +1,4 @@ -using System; - -namespace AoC2018.Solutions.Day15 +namespace AoC2018.Solutions.Day15 { public class Part02 : ISolution { @@ -54,7 +52,6 @@ public string Solve(string input) return (rounds * currentState.TotalRemainingHitPoints()).ToString(); } } - } } } diff --git a/AoC2018.Solutions/Day16/Instruction.cs b/AoC2018.Solutions/Day16/Instruction.cs new file mode 100644 index 0000000..41c5865 --- /dev/null +++ b/AoC2018.Solutions/Day16/Instruction.cs @@ -0,0 +1,17 @@ +namespace AoC2018.Solutions.Day16 +{ + using System; + using System.Collections.Generic; + using System.Text.RegularExpressions; + + public class Instruction + { + public int OpCode { get; set; } + + public int A { get; set; } + + public int B { get; set; } + + public int C { get; set; } + } +} diff --git a/AoC2018.Solutions/Day16/Operation.cs b/AoC2018.Solutions/Day16/Operation.cs new file mode 100644 index 0000000..6acd3b3 --- /dev/null +++ b/AoC2018.Solutions/Day16/Operation.cs @@ -0,0 +1,39 @@ +namespace AoC2018.Solutions.Day16 +{ + using System; + + public class Operation + { + public static Operation[] All = new[] + { + new Operation("addr", (registers, instruction) => registers[instruction.C] = registers[instruction.A] + registers[instruction.B]), + new Operation("addi", (registers, instruction) => registers[instruction.C] = registers[instruction.A] + instruction.B), + new Operation("mulr", (registers, instruction) => registers[instruction.C] = registers[instruction.A] * registers[instruction.B]), + new Operation("muli", (registers, instruction) => registers[instruction.C] = registers[instruction.A] * instruction.B), + new Operation("banr", (registers, instruction) => registers[instruction.C] = registers[instruction.A] & registers[instruction.B]), + new Operation("bani", (registers, instruction) => registers[instruction.C] = registers[instruction.A] & instruction.B), + new Operation("borr", (registers, instruction) => registers[instruction.C] = registers[instruction.A] | registers[instruction.B]), + new Operation("bori", (registers, instruction) => registers[instruction.C] = registers[instruction.A] | instruction.B), + new Operation("setr", (registers, instruction) => registers[instruction.C] = registers[instruction.A]), + new Operation("seti", (registers, instruction) => registers[instruction.C] = instruction.A), + new Operation("gtir", (registers, instruction) => registers[instruction.C] = instruction.A > registers[instruction.B] ? 1 : 0), + new Operation("gtri", (registers, instruction) => registers[instruction.C] = registers[instruction.A] > instruction.B ? 1 : 0), + new Operation("gtrr", (registers, instruction) => registers[instruction.C] = registers[instruction.A] > registers[instruction.B] ? 1 : 0), + new Operation("eqir", (registers, instruction) => registers[instruction.C] = instruction.A == registers[instruction.B] ? 1 : 0), + new Operation("eqri", (registers, instruction) => registers[instruction.C] = registers[instruction.A] == instruction.B ? 1 : 0), + new Operation("eqrr", (registers, instruction) => registers[instruction.C] = registers[instruction.A] == registers[instruction.B] ? 1 : 0), + }; + + public Operation(string name, Action instruction) + { + this.Name = name; + this.Execute = instruction; + } + + public int? OpCode { get; set; } + + public string Name { get; set; } + + public Action Execute { get; } + } +} diff --git a/AoC2018.Solutions/Day16/Parser.cs b/AoC2018.Solutions/Day16/Parser.cs new file mode 100644 index 0000000..c908d8c --- /dev/null +++ b/AoC2018.Solutions/Day16/Parser.cs @@ -0,0 +1,67 @@ +namespace AoC2018.Solutions.Day16 +{ + using System; + using System.Collections.Generic; + using System.Linq; + using System.Text.RegularExpressions; + + public static class Parser + { + public static (Sample[] Samples, Instruction[] instructions) Parse(string input) + { + // Split into samples and instructions + int breakPoint = input.IndexOf(string.Concat(Environment.NewLine, Environment.NewLine, Environment.NewLine, Environment.NewLine)); + string samplesInput = input.Substring(0, breakPoint == -1 ? input.Length : breakPoint); + string instructionsInput = breakPoint == -1 ? string.Empty : input.Substring(breakPoint + 4); + + // Use a regex to build up the samples + var sampleRegex = new Regex(@"Before: \[(\d+), (\d+), (\d+), (\d+)]\r\n(\d+) (\d+) (\d+) (\d+)\r\nAfter: \[(\d+), (\d+), (\d+), (\d+)\]"); + MatchCollection sampleMatches = sampleRegex.Matches(samplesInput); + + var samples = new List(sampleMatches.Count); + foreach (Match match in sampleMatches) + { + samples.Add(BuildSampleFromMatch(match)); + } + + // Program is easier... + IEnumerable instructions = instructionsInput.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries) + .Select(BuildInstructionFromInputLine); + + return (samples.ToArray(), instructions.ToArray()); + } + + private static Instruction BuildInstructionFromInputLine(string input) + { + string[] components = input.Split(' '); + + return new Instruction + { + OpCode = int.Parse(components[0]), + A = int.Parse(components[1]), + B = int.Parse(components[2]), + C = int.Parse(components[3]), + }; + } + + private static Sample BuildSampleFromMatch(Match input) + { + int[] preOp = new[] { int.Parse(input.Groups[1].Value), int.Parse(input.Groups[2].Value), int.Parse(input.Groups[3].Value), int.Parse(input.Groups[4].Value) }; + var instruction = new Instruction + { + OpCode = int.Parse(input.Groups[5].Value), + A = int.Parse(input.Groups[6].Value), + B = int.Parse(input.Groups[7].Value), + C = int.Parse(input.Groups[8].Value), + }; + int[] postOp = new[] { int.Parse(input.Groups[9].Value), int.Parse(input.Groups[10].Value), int.Parse(input.Groups[11].Value), int.Parse(input.Groups[12].Value) }; + + return new Sample + { + PreOp = preOp, + Instruction = instruction, + PostOp = postOp, + }; + } + } +} diff --git a/AoC2018.Solutions/Day16/Part01.cs b/AoC2018.Solutions/Day16/Part01.cs new file mode 100644 index 0000000..40959be --- /dev/null +++ b/AoC2018.Solutions/Day16/Part01.cs @@ -0,0 +1,19 @@ +namespace AoC2018.Solutions.Day16 +{ + using System.Collections.Generic; + using System.Linq; + + public class Part01 : ISolution + { + public string Solve(string input) + { + (Sample[] Samples, Instruction[] instructions) data = Parser.Parse(input); + + IEnumerable<(Sample x, int)> testResults = data.Samples.Select(x => (x, x.GetMatchingOperationsCount())); + + int result = testResults.Count(x => x.Item2 >= 3); + + return result.ToString(); + } + } +} diff --git a/AoC2018.Solutions/Day16/Part02.cs b/AoC2018.Solutions/Day16/Part02.cs new file mode 100644 index 0000000..0393636 --- /dev/null +++ b/AoC2018.Solutions/Day16/Part02.cs @@ -0,0 +1,41 @@ +namespace AoC2018.Solutions.Day16 +{ + using System.Collections.Generic; + using System.Linq; + + public class Part02 : ISolution + { + public string Solve(string input) + { + (Sample[] Samples, Instruction[] Instructions) data = Parser.Parse(input); + + IEnumerable<(Sample Sample, Operation[] CandidateOperations)> testResults = data.Samples.Select(x => (x, x.GetMatchingOperations())); + + // We need to find the opcode for each operation... + Operation[] operations = Operation.All; + + while (operations.Any(x => !x.OpCode.HasValue)) + { + // Find any sample that has only one unallocated opcode + IEnumerable<(Sample Sample, Operation[] CandidateOperations)> samplesWithOnlyOneUnallocatedOperation = testResults.Where(x => x.CandidateOperations.Count(op => !op.OpCode.HasValue) == 1); + foreach ((Sample Sample, Operation[] CandidateOperations) current in samplesWithOnlyOneUnallocatedOperation) + { + Operation unallocatedOperation = current.CandidateOperations.First(x => !x.OpCode.HasValue); + unallocatedOperation.OpCode = current.Sample.Instruction.OpCode; + } + } + + // Now we have allocated all the operations we can run the program + // For ease of use we'll stick the operations in a dictionary... + var operationsDictionary = operations.ToDictionary(x => x.OpCode, x => x); + int[] register = new[] { 0, 0, 0, 0 }; + + foreach (Instruction instruction in data.Instructions) + { + operationsDictionary[instruction.OpCode].Execute(register, instruction); + } + + return register[0].ToString(); + } + } +} diff --git a/AoC2018.Solutions/Day16/Sample.cs b/AoC2018.Solutions/Day16/Sample.cs new file mode 100644 index 0000000..1188892 --- /dev/null +++ b/AoC2018.Solutions/Day16/Sample.cs @@ -0,0 +1,15 @@ +namespace AoC2018.Solutions.Day16 +{ + using System; + using System.Collections.Generic; + using System.Text.RegularExpressions; + + public class Sample + { + public int[] PreOp { get; set; } + + public Instruction Instruction { get; set; } + + public int[] PostOp { get; set; } + } +} diff --git a/AoC2018.Solutions/Day16/SampleExtensions.cs b/AoC2018.Solutions/Day16/SampleExtensions.cs new file mode 100644 index 0000000..33e88e4 --- /dev/null +++ b/AoC2018.Solutions/Day16/SampleExtensions.cs @@ -0,0 +1,28 @@ +namespace AoC2018.Solutions.Day16 +{ + using System.Linq; + + public static class SampleExtensions + { + public static int GetMatchingOperationsCount(this Sample sample) + { + return sample.GetMatchingOperations().Length; + } + + public static Operation[] GetMatchingOperations(this Sample sample) + { + return Operation.All.Where(op => + { + // We don't want to mess with the sample, so we need to create a clean copy of the input + // for each test + int[] registers = (int[])sample.PreOp.Clone(); + op.Execute(registers, sample.Instruction); + + return registers[0] == sample.PostOp[0] + && registers[1] == sample.PostOp[1] + && registers[2] == sample.PostOp[2] + && registers[3] == sample.PostOp[3]; + }).ToArray(); + } + } +} diff --git a/AoC2018.Tests/AoCTestCases.cs b/AoC2018.Tests/AoCTestCases.cs index ef97375..5bca52c 100644 --- a/AoC2018.Tests/AoCTestCases.cs +++ b/AoC2018.Tests/AoCTestCases.cs @@ -53,6 +53,7 @@ public class AoCTestCases [TestCase(15, 1, "#######\r\n#E.G#.#\r\n#.#G..#\r\n#G.#.G#\r\n#G..#.#\r\n#...E.#\r\n#######", "27755")] [TestCase(15, 1, "#######\r\n#.E...#\r\n#.#..G#\r\n#.###.#\r\n#E#G#G#\r\n#...#G#\r\n#######", "28944")] [TestCase(15, 1, "#########\r\n#G......#\r\n#.E.#...#\r\n#..##..G#\r\n#...##..#\r\n#...#...#\r\n#.G...G.#\r\n#.....G.#\r\n#########", "18740")] + [TestCase(16, 1, "Before: [3, 2, 1, 1]\r\n9 2 1 2\r\nAfter: [3, 2, 2, 1]", "1")] public void Tests(int day, int part, string input, string expectedResult) { ISolution solution = SolutionFactory.GetSolution(day, part);