├── .dir-locals.el ├── .gitignore ├── LICENSE ├── README.md ├── Setup.hs ├── adventofcode2016.cabal ├── input ├── 1.txt ├── 10.txt ├── 11.txt ├── 12.txt ├── 13.txt ├── 14.txt ├── 15.txt ├── 16.txt ├── 17.txt ├── 18.txt ├── 19.txt ├── 2.txt ├── 20.txt ├── 21.txt ├── 22.txt ├── 23.txt ├── 24.txt ├── 25.txt ├── 3.txt ├── 4.txt ├── 5.txt ├── 6.txt ├── 7.txt ├── 8.txt └── 9.txt ├── lib ├── AdventOfCode.hs └── Search.hs ├── src ├── Day1.hs ├── Day10.hs ├── Day11.hs ├── Day12.hs ├── Day13.hs ├── Day14.hs ├── Day15.hs ├── Day16.hs ├── Day17.hs ├── Day18.hs ├── Day19.hs ├── Day2.hs ├── Day20.hs ├── Day21.hs ├── Day22.hs ├── Day23.hs ├── Day24.hs ├── Day25.hs ├── Day3.hs ├── Day4.hs ├── Day5.hs ├── Day6.hs ├── Day7.hs ├── Day8.hs └── Day9.hs └── stack.yaml /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | 4 | ((haskell-mode 5 | (hindent-reformat-buffer-on-save . t) 6 | (haskell-stylish-on-save . nil))) 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.stack-work/ 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright Author name here (c) 2016 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | 11 | * Redistributions in binary form must reproduce the above 12 | copyright notice, this list of conditions and the following 13 | disclaimer in the documentation and/or other materials provided 14 | with the distribution. 15 | 16 | * Neither the name of Author name here nor the names of other 17 | contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Haskell solutions for 2016 [Advent of Code](https://adventofcode.com/) 2 | 3 | These little solutions are optimised for tidiness rather than speed of 4 | writing. In some cases I've code-golfed them for performance or 5 | elegance, in the interest of learning new tools and techniques. 6 | 7 | ## Usage 8 | 9 | With [stack](https://www.haskellstack.org/) installed: 10 | ``` 11 | stack setup 12 | stack build 13 | stack exec adventofcode2016 [DAYNUM] 14 | ``` 15 | where `DAYNUM` is the number of one of the days of Advent! 16 | -------------------------------------------------------------------------------- /Setup.hs: -------------------------------------------------------------------------------- 1 | import Distribution.Simple 2 | main = defaultMain 3 | -------------------------------------------------------------------------------- /adventofcode2016.cabal: -------------------------------------------------------------------------------- 1 | name: adventofcode2016 2 | version: 0.1.0.0 3 | synopsis: 2016 Advent of Code solutions 4 | description: Please see README.md 5 | homepage: https://github.com/purcell/adventofcode2016#readme 6 | license: BSD3 7 | license-file: LICENSE 8 | author: Steve Purcell 9 | maintainer: steved@sanityinc.com 10 | copyright: 2016 Steve Purcell 11 | category: Other 12 | build-type: Simple 13 | extra-source-files: README.md 14 | cabal-version: >=1.10 15 | 16 | library 17 | hs-source-dirs: lib 18 | exposed-modules: AdventOfCode, Search 19 | build-depends: base >= 4.7 && < 5 20 | , parsec >= 3 21 | , containers >= 0.5 22 | default-language: Haskell2010 23 | 24 | executable Day1 25 | hs-source-dirs: src 26 | main-is: Day1.hs 27 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 28 | build-depends: base 29 | , adventofcode2016 30 | , containers 31 | default-language: Haskell2010 32 | 33 | executable Day2 34 | hs-source-dirs: src 35 | main-is: Day2.hs 36 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 37 | build-depends: base 38 | , adventofcode2016 39 | , containers 40 | default-language: Haskell2010 41 | 42 | executable Day3 43 | hs-source-dirs: src 44 | main-is: Day3.hs 45 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 46 | build-depends: base 47 | , adventofcode2016 48 | default-language: Haskell2010 49 | 50 | executable Day4 51 | hs-source-dirs: src 52 | main-is: Day4.hs 53 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 54 | build-depends: base 55 | , adventofcode2016 56 | default-language: Haskell2010 57 | 58 | executable Day5 59 | hs-source-dirs: src 60 | main-is: Day5.hs 61 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 62 | build-depends: base 63 | , adventofcode2016 64 | , containers 65 | , cryptonite 66 | , bytestring 67 | default-language: Haskell2010 68 | 69 | executable Day6 70 | hs-source-dirs: src 71 | main-is: Day6.hs 72 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 73 | build-depends: base 74 | , adventofcode2016 75 | default-language: Haskell2010 76 | 77 | executable Day7 78 | hs-source-dirs: src 79 | main-is: Day7.hs 80 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 81 | build-depends: base 82 | , adventofcode2016 83 | default-language: Haskell2010 84 | 85 | executable Day8 86 | hs-source-dirs: src 87 | main-is: Day8.hs 88 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 89 | build-depends: base 90 | , adventofcode2016 91 | , containers 92 | default-language: Haskell2010 93 | 94 | executable Day9 95 | hs-source-dirs: src 96 | main-is: Day9.hs 97 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 98 | build-depends: base 99 | , adventofcode2016 100 | default-language: Haskell2010 101 | 102 | executable Day10 103 | hs-source-dirs: src 104 | main-is: Day10.hs 105 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 106 | build-depends: base 107 | , adventofcode2016 108 | , containers 109 | , mtl 110 | default-language: Haskell2010 111 | 112 | executable Day11 113 | hs-source-dirs: src 114 | main-is: Day11.hs 115 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 116 | build-depends: base 117 | , adventofcode2016 118 | , containers 119 | default-language: Haskell2010 120 | 121 | executable Day12 122 | hs-source-dirs: src 123 | main-is: Day12.hs 124 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 125 | build-depends: base 126 | , adventofcode2016 127 | , containers 128 | , mtl 129 | default-language: Haskell2010 130 | 131 | executable Day13 132 | hs-source-dirs: src 133 | main-is: Day13.hs 134 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 135 | build-depends: base 136 | , adventofcode2016 137 | , containers 138 | default-language: Haskell2010 139 | 140 | executable Day14 141 | hs-source-dirs: src 142 | main-is: Day14.hs 143 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 144 | build-depends: base 145 | , adventofcode2016 146 | , cryptonite 147 | , bytestring 148 | default-language: Haskell2010 149 | 150 | executable Day15 151 | hs-source-dirs: src 152 | main-is: Day15.hs 153 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 154 | build-depends: base 155 | , adventofcode2016 156 | default-language: Haskell2010 157 | 158 | executable Day16 159 | hs-source-dirs: src 160 | main-is: Day16.hs 161 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 162 | build-depends: base 163 | , adventofcode2016 164 | default-language: Haskell2010 165 | 166 | executable Day17 167 | hs-source-dirs: src 168 | main-is: Day17.hs 169 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 170 | build-depends: base 171 | , adventofcode2016 172 | , containers 173 | , cryptonite 174 | , bytestring 175 | default-language: Haskell2010 176 | 177 | executable Day18 178 | hs-source-dirs: src 179 | main-is: Day18.hs 180 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 181 | build-depends: base 182 | , adventofcode2016 183 | default-language: Haskell2010 184 | 185 | executable Day19 186 | hs-source-dirs: src 187 | main-is: Day19.hs 188 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 189 | build-depends: base 190 | , adventofcode2016 191 | , containers 192 | default-language: Haskell2010 193 | 194 | executable Day20 195 | hs-source-dirs: src 196 | main-is: Day20.hs 197 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 198 | build-depends: base 199 | , adventofcode2016 200 | default-language: Haskell2010 201 | 202 | executable Day21 203 | hs-source-dirs: src 204 | main-is: Day21.hs 205 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 206 | build-depends: base 207 | , adventofcode2016 208 | , containers 209 | default-language: Haskell2010 210 | 211 | executable Day22 212 | hs-source-dirs: src 213 | main-is: Day22.hs 214 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 215 | build-depends: base 216 | , adventofcode2016 217 | , containers 218 | default-language: Haskell2010 219 | 220 | executable Day23 221 | hs-source-dirs: src 222 | main-is: Day23.hs 223 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 224 | build-depends: base 225 | , adventofcode2016 226 | , containers 227 | , mtl 228 | default-language: Haskell2010 229 | 230 | executable Day24 231 | hs-source-dirs: src 232 | main-is: Day24.hs 233 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 234 | build-depends: base 235 | , adventofcode2016 236 | , containers 237 | , mtl 238 | default-language: Haskell2010 239 | 240 | executable Day25 241 | hs-source-dirs: src 242 | main-is: Day25.hs 243 | ghc-options: -threaded -rtsopts -with-rtsopts=-N -Wall -O 244 | build-depends: base 245 | , adventofcode2016 246 | , containers 247 | , mtl 248 | default-language: Haskell2010 249 | 250 | source-repository head 251 | type: git 252 | location: https://github.com/purcell/adventofcode2016 253 | -------------------------------------------------------------------------------- /input/1.txt: -------------------------------------------------------------------------------- 1 | L3, R1, L4, L1, L2, R4, L3, L3, R2, R3, L5, R1, R3, L4, L1, L2, R2, R1, L4, L4, R2, L5, R3, R2, R1, L1, L2, R2, R2, L1, L1, R2, R1, L3, L5, R4, L3, R3, R3, L5, L190, L4, R4, R51, L4, R5, R5, R2, L1, L3, R1, R4, L3, R1, R3, L5, L4, R2, R5, R2, L1, L5, L1, L1, R78, L3, R2, L3, R5, L2, R2, R4, L1, L4, R1, R185, R3, L4, L1, L1, L3, R4, L4, L1, R5, L5, L1, R5, L1, R2, L5, L2, R4, R3, L2, R3, R1, L3, L5, L4, R3, L2, L4, L5, L4, R1, L1, R5, L2, R4, R2, R3, L1, L1, L4, L3, R4, L3, L5, R2, L5, L1, L1, R2, R3, L5, L3, L2, L1, L4, R4, R4, L2, R3, R1, L2, R1, L2, L2, R3, R3, L1, R4, L5, L3, R4, R4, R1, L2, L5, L3, R1, R4, L2, R5, R4, R2, L5, L3, R4, R1, L1, R5, L3, R1, R5, L2, R1, L5, L2, R2, L2, L3, R3, R3, R1 2 | -------------------------------------------------------------------------------- /input/10.txt: -------------------------------------------------------------------------------- 1 | bot 76 gives low to bot 191 and high to bot 21 2 | bot 193 gives low to bot 118 and high to bot 145 3 | bot 173 gives low to bot 91 and high to bot 36 4 | value 23 goes to bot 68 5 | bot 129 gives low to bot 124 and high to bot 155 6 | bot 58 gives low to output 2 and high to bot 51 7 | bot 97 gives low to bot 205 and high to bot 156 8 | bot 95 gives low to bot 21 and high to bot 204 9 | bot 56 gives low to bot 202 and high to bot 97 10 | bot 181 gives low to bot 144 and high to bot 101 11 | bot 20 gives low to bot 42 and high to bot 23 12 | bot 122 gives low to bot 190 and high to bot 50 13 | bot 202 gives low to bot 103 and high to bot 205 14 | bot 169 gives low to bot 125 and high to bot 208 15 | bot 91 gives low to bot 58 and high to bot 17 16 | bot 10 gives low to bot 127 and high to bot 1 17 | bot 119 gives low to bot 50 and high to bot 149 18 | bot 194 gives low to bot 38 and high to bot 77 19 | bot 82 gives low to bot 49 and high to bot 22 20 | bot 180 gives low to bot 199 and high to bot 71 21 | bot 191 gives low to bot 146 and high to bot 13 22 | bot 111 gives low to bot 186 and high to bot 89 23 | bot 75 gives low to bot 195 and high to bot 117 24 | bot 17 gives low to bot 51 and high to bot 184 25 | value 5 goes to bot 209 26 | bot 139 gives low to bot 81 and high to bot 57 27 | bot 36 gives low to bot 17 and high to bot 46 28 | bot 158 gives low to bot 30 and high to bot 6 29 | bot 40 gives low to bot 160 and high to bot 82 30 | value 11 goes to bot 175 31 | value 3 goes to bot 170 32 | bot 208 gives low to bot 14 and high to bot 104 33 | bot 113 gives low to output 15 and high to bot 27 34 | bot 96 gives low to bot 170 and high to bot 110 35 | bot 9 gives low to bot 102 and high to bot 132 36 | value 67 goes to bot 129 37 | bot 35 gives low to bot 24 and high to bot 187 38 | bot 172 gives low to bot 117 and high to bot 64 39 | bot 157 gives low to bot 65 and high to bot 136 40 | bot 179 gives low to bot 178 and high to bot 197 41 | bot 144 gives low to bot 172 and high to bot 2 42 | bot 51 gives low to output 8 and high to bot 31 43 | bot 177 gives low to bot 194 and high to bot 61 44 | bot 106 gives low to bot 134 and high to bot 52 45 | bot 148 gives low to bot 86 and high to bot 199 46 | bot 64 gives low to bot 48 and high to bot 146 47 | bot 121 gives low to bot 165 and high to bot 116 48 | bot 146 gives low to bot 9 and high to bot 69 49 | bot 199 gives low to bot 141 and high to bot 152 50 | bot 166 gives low to bot 62 and high to bot 201 51 | bot 102 gives low to bot 151 and high to bot 179 52 | bot 15 gives low to bot 80 and high to bot 3 53 | bot 105 gives low to bot 197 and high to bot 86 54 | bot 2 gives low to bot 64 and high to bot 191 55 | bot 3 gives low to bot 169 and high to bot 208 56 | bot 39 gives low to bot 43 and high to bot 98 57 | bot 196 gives low to bot 66 and high to bot 32 58 | value 47 goes to bot 142 59 | bot 110 gives low to bot 29 and high to bot 40 60 | bot 151 gives low to bot 74 and high to bot 178 61 | bot 164 gives low to bot 4 and high to bot 93 62 | bot 61 gives low to bot 77 and high to bot 144 63 | bot 29 gives low to bot 183 and high to bot 160 64 | bot 79 gives low to bot 204 and high to bot 37 65 | bot 188 gives low to output 0 and high to bot 72 66 | bot 131 gives low to bot 54 and high to bot 38 67 | bot 59 gives low to output 4 and high to bot 34 68 | bot 8 gives low to bot 101 and high to bot 7 69 | bot 189 gives low to bot 46 and high to bot 53 70 | bot 77 gives low to bot 75 and high to bot 172 71 | bot 206 gives low to bot 56 and high to bot 107 72 | bot 114 gives low to bot 188 and high to bot 125 73 | bot 207 gives low to bot 87 and high to bot 10 74 | bot 30 gives low to bot 106 and high to bot 11 75 | bot 167 gives low to bot 45 and high to bot 183 76 | bot 168 gives low to output 12 and high to bot 58 77 | bot 142 gives low to bot 68 and high to bot 111 78 | bot 138 gives low to bot 180 and high to bot 198 79 | bot 171 gives low to bot 150 and high to bot 35 80 | bot 5 gives low to bot 39 and high to bot 100 81 | bot 197 gives low to bot 120 and high to bot 173 82 | bot 46 gives low to bot 184 and high to bot 128 83 | bot 137 gives low to bot 0 and high to bot 114 84 | bot 7 gives low to bot 76 and high to bot 95 85 | bot 104 gives low to bot 159 and high to bot 203 86 | bot 103 gives low to bot 5 and high to bot 108 87 | bot 66 gives low to bot 158 and high to bot 161 88 | bot 156 gives low to bot 166 and high to bot 201 89 | bot 178 gives low to bot 130 and high to bot 120 90 | bot 1 gives low to bot 206 and high to bot 107 91 | bot 65 gives low to bot 111 and high to bot 143 92 | bot 150 gives low to bot 25 and high to bot 24 93 | value 7 goes to bot 135 94 | bot 48 gives low to bot 182 and high to bot 9 95 | bot 112 gives low to bot 22 and high to bot 202 96 | bot 32 gives low to bot 161 and high to bot 42 97 | bot 12 gives low to bot 61 and high to bot 181 98 | bot 155 gives low to bot 196 and high to bot 73 99 | value 73 goes to bot 140 100 | bot 99 gives low to bot 109 and high to bot 151 101 | bot 163 gives low to bot 131 and high to bot 194 102 | bot 98 gives low to bot 174 and high to bot 26 103 | value 53 goes to bot 4 104 | bot 204 gives low to bot 18 and high to bot 126 105 | bot 19 gives low to output 6 and high to bot 113 106 | bot 190 gives low to bot 7 and high to bot 154 107 | bot 88 gives low to bot 26 and high to bot 122 108 | bot 153 gives low to bot 113 and high to bot 33 109 | bot 49 gives low to bot 193 and high to bot 55 110 | value 37 goes to bot 150 111 | bot 53 gives low to bot 128 and high to bot 15 112 | bot 80 gives low to bot 114 and high to bot 169 113 | bot 192 gives low to bot 115 and high to bot 138 114 | bot 132 gives low to bot 179 and high to bot 105 115 | bot 57 gives low to bot 41 and high to bot 206 116 | bot 118 gives low to bot 20 and high to bot 162 117 | bot 37 gives low to bot 126 and high to bot 78 118 | bot 201 gives low to bot 16 and high to bot 119 119 | bot 145 gives low to bot 162 and high to bot 39 120 | bot 62 gives low to bot 88 and high to bot 16 121 | bot 133 gives low to bot 59 and high to bot 200 122 | bot 52 gives low to bot 19 and high to bot 153 123 | bot 28 gives low to bot 200 and high to bot 182 124 | bot 149 gives low to bot 79 and high to bot 37 125 | bot 117 gives low to bot 28 and high to bot 48 126 | bot 4 gives low to bot 171 and high to bot 93 127 | bot 182 gives low to bot 99 and high to bot 102 128 | value 2 goes to bot 92 129 | bot 170 gives low to bot 167 and high to bot 29 130 | bot 187 gives low to bot 47 and high to bot 63 131 | bot 72 gives low to output 20 and high to bot 176 132 | bot 209 gives low to bot 94 and high to bot 30 133 | bot 26 gives low to bot 8 and high to bot 190 134 | bot 162 gives low to bot 23 and high to bot 43 135 | bot 16 gives low to bot 122 and high to bot 119 136 | bot 200 gives low to bot 34 and high to bot 99 137 | bot 68 gives low to bot 175 and high to bot 186 138 | bot 85 gives low to bot 82 and high to bot 112 139 | value 61 goes to bot 45 140 | bot 38 gives low to bot 123 and high to bot 75 141 | bot 108 gives low to bot 100 and high to bot 62 142 | bot 34 gives low to output 17 and high to bot 109 143 | bot 90 gives low to bot 44 and high to bot 193 144 | bot 94 gives low to bot 135 and high to bot 106 145 | value 19 goes to bot 124 146 | bot 184 gives low to bot 31 and high to bot 137 147 | bot 134 gives low to output 3 and high to bot 19 148 | bot 63 gives low to bot 207 and high to bot 10 149 | bot 24 gives low to bot 157 and high to bot 47 150 | bot 185 gives low to bot 147 and high to bot 81 151 | bot 18 gives low to bot 84 and high to bot 192 152 | bot 130 gives low to output 14 and high to bot 168 153 | bot 78 gives low to bot 138 and high to bot 198 154 | bot 69 gives low to bot 132 and high to bot 60 155 | bot 161 gives low to bot 6 and high to bot 163 156 | bot 176 gives low to output 5 and high to bot 159 157 | bot 55 gives low to bot 145 and high to bot 5 158 | bot 160 gives low to bot 90 and high to bot 49 159 | value 71 goes to bot 167 160 | bot 165 gives low to bot 53 and high to bot 116 161 | bot 128 gives low to bot 137 and high to bot 80 162 | bot 67 gives low to bot 140 and high to bot 66 163 | bot 86 gives low to bot 173 and high to bot 141 164 | bot 93 gives low to bot 35 and high to bot 187 165 | bot 175 gives low to bot 96 and high to bot 70 166 | bot 174 gives low to bot 181 and high to bot 8 167 | bot 14 gives low to bot 176 and high to bot 104 168 | bot 13 gives low to bot 69 and high to bot 84 169 | bot 54 gives low to bot 153 and high to bot 123 170 | bot 135 gives low to output 10 and high to bot 134 171 | bot 101 gives low to bot 2 and high to bot 76 172 | bot 147 gives low to bot 40 and high to bot 85 173 | bot 205 gives low to bot 108 and high to bot 166 174 | bot 141 gives low to bot 36 and high to bot 189 175 | bot 84 gives low to bot 60 and high to bot 115 176 | bot 115 gives low to bot 148 and high to bot 180 177 | value 31 goes to bot 171 178 | value 13 goes to bot 67 179 | bot 195 gives low to bot 133 and high to bot 28 180 | bot 124 gives low to bot 67 and high to bot 196 181 | bot 109 gives low to output 7 and high to bot 74 182 | bot 25 gives low to bot 92 and high to bot 157 183 | bot 116 gives low to bot 15 and high to bot 3 184 | bot 140 gives low to bot 209 and high to bot 158 185 | bot 154 gives low to bot 95 and high to bot 79 186 | bot 92 gives low to bot 142 and high to bot 65 187 | bot 81 gives low to bot 85 and high to bot 41 188 | bot 33 gives low to bot 27 and high to bot 133 189 | bot 186 gives low to bot 70 and high to bot 185 190 | bot 73 gives low to bot 32 and high to bot 20 191 | bot 41 gives low to bot 112 and high to bot 56 192 | bot 89 gives low to bot 185 and high to bot 139 193 | bot 23 gives low to bot 177 and high to bot 12 194 | bot 125 gives low to bot 72 and high to bot 14 195 | bot 50 gives low to bot 154 and high to bot 149 196 | bot 21 gives low to bot 13 and high to bot 18 197 | bot 159 gives low to output 9 and high to bot 203 198 | bot 47 gives low to bot 136 and high to bot 63 199 | bot 143 gives low to bot 89 and high to bot 87 200 | bot 44 gives low to bot 73 and high to bot 118 201 | value 43 goes to bot 94 202 | bot 107 gives low to bot 97 and high to bot 156 203 | bot 70 gives low to bot 110 and high to bot 147 204 | bot 45 gives low to bot 129 and high to bot 83 205 | bot 43 gives low to bot 12 and high to bot 174 206 | value 41 goes to bot 164 207 | bot 74 gives low to output 18 and high to bot 130 208 | bot 136 gives low to bot 143 and high to bot 207 209 | bot 42 gives low to bot 163 and high to bot 177 210 | value 17 goes to bot 164 211 | bot 0 gives low to output 19 and high to bot 188 212 | bot 87 gives low to bot 139 and high to bot 127 213 | value 59 goes to bot 96 214 | bot 120 gives low to bot 168 and high to bot 91 215 | bot 198 gives low to bot 71 and high to bot 121 216 | bot 203 gives low to output 16 and high to output 1 217 | value 29 goes to bot 25 218 | bot 22 gives low to bot 55 and high to bot 103 219 | bot 11 gives low to bot 52 and high to bot 54 220 | bot 6 gives low to bot 11 and high to bot 131 221 | bot 31 gives low to output 13 and high to bot 0 222 | bot 126 gives low to bot 192 and high to bot 78 223 | bot 27 gives low to output 11 and high to bot 59 224 | bot 127 gives low to bot 57 and high to bot 1 225 | bot 60 gives low to bot 105 and high to bot 148 226 | bot 152 gives low to bot 189 and high to bot 165 227 | bot 100 gives low to bot 98 and high to bot 88 228 | bot 83 gives low to bot 155 and high to bot 44 229 | bot 123 gives low to bot 33 and high to bot 195 230 | bot 183 gives low to bot 83 and high to bot 90 231 | bot 71 gives low to bot 152 and high to bot 121 232 | -------------------------------------------------------------------------------- /input/11.txt: -------------------------------------------------------------------------------- 1 | The first floor contains a polonium generator, a thulium generator, a thulium-compatible microchip, a promethium generator, a ruthenium generator, a ruthenium-compatible microchip, a cobalt generator, and a cobalt-compatible microchip. 2 | The second floor contains a polonium-compatible microchip and a promethium-compatible microchip. 3 | The third floor contains nothing relevant. 4 | The fourth floor contains nothing relevant. 5 | -------------------------------------------------------------------------------- /input/12.txt: -------------------------------------------------------------------------------- 1 | cpy 1 a 2 | cpy 1 b 3 | cpy 26 d 4 | jnz c 2 5 | jnz 1 5 6 | cpy 7 c 7 | inc d 8 | dec c 9 | jnz c -2 10 | cpy a c 11 | inc a 12 | dec b 13 | jnz b -2 14 | cpy c b 15 | dec d 16 | jnz d -6 17 | cpy 14 c 18 | cpy 14 d 19 | inc a 20 | dec d 21 | jnz d -2 22 | dec c 23 | jnz c -5 24 | -------------------------------------------------------------------------------- /input/13.txt: -------------------------------------------------------------------------------- 1 | 1350 2 | 3 | -------------------------------------------------------------------------------- /input/14.txt: -------------------------------------------------------------------------------- 1 | yjdafjpo 2 | -------------------------------------------------------------------------------- /input/15.txt: -------------------------------------------------------------------------------- 1 | Disc #1 has 17 positions; at time=0, it is at position 15. 2 | Disc #2 has 3 positions; at time=0, it is at position 2. 3 | Disc #3 has 19 positions; at time=0, it is at position 4. 4 | Disc #4 has 13 positions; at time=0, it is at position 2. 5 | Disc #5 has 7 positions; at time=0, it is at position 2. 6 | Disc #6 has 5 positions; at time=0, it is at position 0. 7 | -------------------------------------------------------------------------------- /input/16.txt: -------------------------------------------------------------------------------- 1 | 11101000110010100 2 | -------------------------------------------------------------------------------- /input/17.txt: -------------------------------------------------------------------------------- 1 | qljzarfv 2 | -------------------------------------------------------------------------------- /input/18.txt: -------------------------------------------------------------------------------- 1 | .^^..^...^..^^.^^^.^^^.^^^^^^.^.^^^^.^^.^^^^^^.^...^......^...^^^..^^^.....^^^^^^^^^....^^...^^^^..^ 2 | -------------------------------------------------------------------------------- /input/19.txt: -------------------------------------------------------------------------------- 1 | 3018458 2 | -------------------------------------------------------------------------------- /input/2.txt: -------------------------------------------------------------------------------- 1 | LLULLLRLDLLLRLUURDDLRDLDURULRLUULUDDUDDLLLURRLDRRLDRRRLDUDLRDLRRDLLDUDUDUDRLUDUUDLLLRDURUDUULUDLRDUUUDUUDURLDUULLRDLULDUURUDRDDLDRLURLRURRDUURLRLUURURUUULLRLLULRUURLULURDLLRRUDLUDULDRDRLRULUURRDRULLRUUUDLRLDLUURRRURDLUDDRRUDRLUDRDLLLLLRULLDUDRLRRDDULDLRUURRRRRLDLDLRDURDRUUURDLRDDDDULURRRRDUURLULLLDLRULRDULRUDLRRLRDLLRLLLUDDLRDRURDDLLLLDUDRDLRURRDLRDDDLDULDRLRULUUDRRRUUULLLURRDDUULURULDURRLLULLDRURUUULRLRDRRUDRDRRDURRUUUULDRDDDUDLDDURLLRR 2 | LDLRRRUURDLDDRLRRDLLULRULLLUDUUDUDLRULLDRUDRULLDULURDRDDLRURDDULLLLDLRDRDRDDURLURLURLUDRDDRDULULUDDRURRDLLDUURDRDDLRLLURRDLRDDULDLULURDRDLUDRRUUDULLULURRDUDRUUUDRULDLDURLRRUDURLDLRRUURRRURDLUDRLDUDRRUDUURURUDDUUDRDULRDLUDRRRLDRURLLRDDDLUDRDUDURDDDRRDDRRRLLRRDDLDDLRUURRURDLLDRLRRDLLUDRRRURURLRDRLLRLRLRULLRURLDLRRULLRRRDULUUULDRDLLURDDLDLRDRLUUDLLUDDLDRRLDLRUDRUDLLUURLLULURUDUDRLULLUDRURDDLDLDDUDLRDDRRURLRLLUDDUDRUURRURRULDRLDDRLLRRLDDURRDLDULLLURULLLRUURLRRRRUUULRLLLURRLRLRUDRDUUUDUUUDDLULLDLLLLDLDRULDRUUULDDDLURLDLRLULRUDDDDURDDLU 3 | RURLURRDLDULLULDDDLRUULLUURLRUDRUDRRUDDLDDDDRRDLRURLRURLDDDUDDUURRDRULDRRRULRDRDDLRUDULRLURDUUDRRLDLRDRURDLDRRRRDRURUUDDDLLRDRDUDUDUDLLULURULRRLRURUULUULDDDDURULRULLRUDUURLURDUDLUDLUDRLLDUUDUULRLRLUUDRDULDULRURDRRRULRUDLRURDDULUDULLRLRURURUULLULDRURLLRRUUDDUUURRDLURUURULRDRRDDUDULRDDLUDLURURUURDRULLRDDLLRDDLDRDUDRRDLUURRLRLUURRULUDURLDDRLLURRDDDLDDRURULLDDRLUDDLRLURDUDULLRDULLLDLLUDDRUDRUDDUUDRDRULRL 4 | RLRDRDULULUDLUDRDRLUDLDLLUDURULDDDUDLRURLLRLRLDLDRLDURDLRRURLULLULURLLDRRDRLUDRLRDLLULRULURRURURUULRDUDLLRDLRRRRRLUURDRRRDLRUDLLDLLDLRUUUDLLLDDDLRDULLRUUDDRLDDURRRDLRLRLDDDDLRDRULLUURUUDRRLLRLLRDDLLRURRRRDRULRRLLRLLLRLDRRLDDDURRURLDURUURRLRLRLDRURULLRLRUDLDUURDLLRLDLURUUUDLLRDRDDDDDDRLDRRRLRRRRURUDLDDRDLLURUDLRRLDDDLUDUDUULRDULULUDDULUUDLLLLRLDDUUULRLRDULURDURRRURRULURRRDRDLDDURDLURUDURRRDDRLRLUDLUDDLUULLDURLURDDUDDLRUUUDRLLDRURL 5 | ULUDLLUDDULRUURDRURDUDUDLUURDDDRRLUDURURDRURRLDRDURLRLLRRDDRRDRRRUULURUDURUDULRRRRDDLDURRLRRDUDDDRLLLULDRLRLURRDUURDURRRURRDLUDUDDRLDLURRRDDRLLRDRDDRDURRRRLURRLUDDURRULRUDUDULDRUDDRULLUUULDURRRLDRULLURULLRUDLDUDDLDULDLUUDRULULDLLDRULLRUULDUDUUDRLRRLDLUULUDLLDDRLRRDDLLURURDULRRDDRURDRLRLULDLDURULLUUUDURURDLDUDDDDUUULUDLUURRULLDLRLURDLURLRLDDURRLDDRRRDUUULLUULDLLDLLDDRLRRUDLULDRLULDULULRRLRULUUURURUUURDUUDDURLLUDDRLRDDLUURRUULRDLDDRLULUULRDRURLUURDRDUURUDLRR 6 | -------------------------------------------------------------------------------- /input/20.txt: -------------------------------------------------------------------------------- 1 | 1873924193-1879728099 2 | 2042754084-2076891856 3 | 4112318198-4113899685 4 | 1039794493-1057170966 5 | 3791841434-3797494664 6 | 1518668516-1518748952 7 | 1946127596-1953926346 8 | 4058215215-4086224696 9 | 3429681642-3455096313 10 | 2599576643-2604275147 11 | 1800210010-1801990849 12 | 1761160149-1766904471 13 | 2774395403-2774748831 14 | 1520470679-1542287000 15 | 2343327790-2346083217 16 | 1628052281-1630209458 17 | 100577752-127518854 18 | 671383949-696948197 19 | 2144689921-2169898850 20 | 3606633683-3608925912 21 | 2109791040-2110314929 22 | 492539485-512327909 23 | 1364276172-1365041569 24 | 3467175303-3467618102 25 | 460580113-466381680 26 | 813074193-837921910 27 | 5537006-14606952 28 | 946065544-951330790 29 | 989372718-991282302 30 | 200009261-205932238 31 | 3798271597-3801031905 32 | 2216207343-2242110933 33 | 848423835-848853657 34 | 1748754108-1786349744 35 | 2399831275-2450914999 36 | 1663535391-1664405521 37 | 892515306-898828394 38 | 2880137661-2888009771 39 | 3365333945-3374605152 40 | 987036370-998814590 41 | 3892148601-3897753835 42 | 2284996682-2304337355 43 | 308020918-314394785 44 | 538685495-544373302 45 | 1823596335-1824819464 46 | 971809355-983694756 47 | 284716926-285879421 48 | 3637637036-3652853727 49 | 1916553349-1918781150 50 | 696948199-701183905 51 | 2108894965-2110155929 52 | 368081079-369068299 53 | 1528668961-1565706834 54 | 3711148791-3721773623 55 | 3379988898-3419009907 56 | 75796957-84367940 57 | 1622153638-1627375599 58 | 1660472686-1675015684 59 | 1153621810-1160895822 60 | 2031612525-2032051797 61 | 1150487328-1153453006 62 | 300933544-307215112 63 | 3189667528-3205813479 64 | 2693102773-2697432888 65 | 2923748650-2931308011 66 | 2512953216-2519005204 67 | 1651098254-1660472685 68 | 3988605837-4016033187 69 | 270425249-275430325 70 | 649608587-651366398 71 | 2880152810-2894023332 72 | 3367065179-3368964916 73 | 1137467603-1160465160 74 | 3378838178-3379988897 75 | 1912841207-1913884949 76 | 3734505169-3755988948 77 | 1518708042-1518847704 78 | 1930577208-1944584155 79 | 2869986404-2909986632 80 | 424121138-428248387 81 | 1827165738-1840620936 82 | 324495276-330189246 83 | 2521490885-2526000948 84 | 1513153698-1513536552 85 | 3156724300-3177963150 86 | 2737600184-2746832287 87 | 2597645418-2602897419 88 | 1972314551-1997656153 89 | 1468081450-1492108957 90 | 3217469337-3227811437 91 | 2456382583-2459166080 92 | 4038379151-4038960518 93 | 3984707942-3986223942 94 | 1514736329-1515006318 95 | 1410942019-1420373476 96 | 3943044250-3945907963 97 | 1675015686-1680347958 98 | 1182759348-1204636005 99 | 1547041264-1574284229 100 | 3998227842-4000267869 101 | 2719765570-2731840505 102 | 2003729668-2031612524 103 | 1124274530-1124952970 104 | 2710016978-2729083584 105 | 2697048351-2697545869 106 | 3249954687-3258412725 107 | 1177795536-1179734693 108 | 1063172514-1063568483 109 | 3919426754-3928084951 110 | 2649727243-2651783771 111 | 420545813-425492876 112 | 2187511660-2189532955 113 | 1332771672-1337238856 114 | 2559522941-2561165264 115 | 3611794421-3612100974 116 | 990434095-991061744 117 | 3311767249-3323759965 118 | 2082306404-2087247912 119 | 977081397-983520148 120 | 2700457093-2722036558 121 | 889804703-901273822 122 | 3281975407-3288376938 123 | 1900859-2087697 124 | 3359024113-3364297429 125 | 1488620946-1499185913 126 | 3095850063-3110957137 127 | 2924020651-2934105636 128 | 3480872005-3500207692 129 | 3265576322-3273927552 130 | 3886295152-3887811607 131 | 479600661-482552524 132 | 2077800379-2083424063 133 | 479438989-482498799 134 | 2205762-2390846 135 | 967070257-969400280 136 | 1780626494-1795356535 137 | 336050227-362501040 138 | 2066894356-2070157688 139 | 2711664519-2715211035 140 | 2739426388-2743490521 141 | 50566643-67435318 142 | 138963898-142290410 143 | 3017544167-3021132102 144 | 1133322944-1136596047 145 | 2992711187-3011792444 146 | 1356144684-1358533149 147 | 3298716765-3308644329 148 | 3812682402-3820212811 149 | 3364246396-3378838176 150 | 3605560680-3611803358 151 | 4161229768-4199248942 152 | 250277160-269792207 153 | 4022334281-4042792788 154 | 1479138689-1496448606 155 | 4067103958-4097402008 156 | 324353383-330107603 157 | 3460719560-3465121559 158 | 3357509623-3363501925 159 | 1676179664-1681316839 160 | 334302095-368081077 161 | 4041856791-4049650625 162 | 1095104172-1110817036 163 | 4263462943-4271423497 164 | 35238773-42649255 165 | 1995738612-2003729666 166 | 1145121134-1165576620 167 | 3121753822-3122940047 168 | 781223110-789178753 169 | 284412404-308020917 170 | 477369326-481964268 171 | 3611852163-3612014702 172 | 559316688-567907435 173 | 2705313585-2714787801 174 | 3161761475-3200072999 175 | 3671560806-3676498689 176 | 4112794252-4113970604 177 | 3458327475-3459250050 178 | 655022836-671383948 179 | 269792208-273225169 180 | 420746448-424787078 181 | 1620238298-1621937312 182 | 3618192415-3628252830 183 | 3887811608-3909810672 184 | 3807511962-3807557825 185 | 2947393390-2972353230 186 | 647054999-650847928 187 | 2035631680-2072674057 188 | 1293223106-1312776798 189 | 3616108547-3618041359 190 | 2524866696-2552983326 191 | 14606953-15778021 192 | 1200129106-1204922922 193 | 1577044819-1580263124 194 | 4223248135-4236928477 195 | 785470440-799681933 196 | 1888528109-1893336449 197 | 1122685939-1130099493 198 | 176561814-176701662 199 | 2519417187-2544323712 200 | 1122274583-1124137383 201 | 2957029658-2981009221 202 | 650915504-653475697 203 | 210247196-220200437 204 | 3797007953-3799783891 205 | 488327867-501225193 206 | 130651124-139866418 207 | 864076535-878798307 208 | 2760435654-2774208779 209 | 3103916066-3116559183 210 | 333917748-334285405 211 | 3430587881-3441615730 212 | 148086799-159397502 213 | 3798409655-3803475476 214 | 526468312-538164764 215 | 849018009-849596864 216 | 1442223118-1445044517 217 | 4263319428-4270436586 218 | 4112399576-4113547944 219 | 1978346741-1979488526 220 | 2283224279-2300553570 221 | 1152488821-1156120463 222 | 1390496843-1417003046 223 | 333587527-333646376 224 | 1585558620-1620238296 225 | 1803018238-1806854806 226 | 2925788498-2926548045 227 | 2712474658-2720901711 228 | 1196989900-1202719311 229 | 3952755624-3956970495 230 | 4103476761-4116483698 231 | 4057768470-4058215214 232 | 2710635380-2712069704 233 | 2101903120-2104154726 234 | 1442132763-1443362285 235 | 420330272-435610317 236 | 1431487556-1438515826 237 | 974145635-978447714 238 | 2021691721-2021705237 239 | 3569348094-3574217716 240 | 3016610743-3017615483 241 | 3772028933-3779583364 242 | 1394699060-1428446963 243 | 1515382747-1517187741 244 | 1049613498-1051047136 245 | 95646179-95720807 246 | 539901377-559316686 247 | 987536084-989075921 248 | 2009566992-2023431090 249 | 3459250051-3467175301 250 | 751560448-758586987 251 | 1073411728-1105472904 252 | 1131007779-1149933404 253 | 3674686507-3683472345 254 | 990594635-991997118 255 | 3468204111-3517888339 256 | 4141956472-4146201368 257 | 4060795160-4061262187 258 | 3057468879-3067720704 259 | 3165290543-3166404174 260 | 292172493-311377330 261 | 180601389-183326808 262 | 2951935860-2964576062 263 | 3673461712-3677351195 264 | 1036920441-1060628630 265 | 774260375-779314232 266 | 3734215825-3767700406 267 | 2033080178-2042754083 268 | 3954694001-3983601982 269 | 1737269170-1739584124 270 | 2513146725-2514600051 271 | 1135918433-1160858115 272 | 820957565-836393612 273 | 284896641-290792716 274 | 1412008407-1412622240 275 | 1550150096-1561746360 276 | 824382476-832032406 277 | 208456629-208524145 278 | 917736511-921005775 279 | 1823540463-1824143249 280 | 1274319639-1299239254 281 | 3855584417-3886295150 282 | 3531103253-3549118849 283 | 3267509957-3280095405 284 | 3540252288-3544997898 285 | 701952217-712878128 286 | 3446951203-3458327473 287 | 1551465958-1557177842 288 | 2745906803-2747647252 289 | 3282589918-3311767247 290 | 3765332261-3776919677 291 | 2165412917-2173968511 292 | 109358635-124305239 293 | 3212676972-3214315203 294 | 3326533847-3326810005 295 | 3920666694-3926929222 296 | 650309182-651544046 297 | 708098735-714454173 298 | 572511501-574452217 299 | 449508527-454545623 300 | 1942601982-1949448687 301 | 2064046021-2067447600 302 | 333151198-333393337 303 | 1574284231-1585558619 304 | 698322352-703120196 305 | 148229752-172697920 306 | 3267988563-3273485517 307 | 2032217907-2033036948 308 | 3862068873-3870249341 309 | 919713318-922163670 310 | 155662841-162963144 311 | 1394140453-1430957514 312 | 2873677871-2896542230 313 | 37916329-39253788 314 | 681670311-687826081 315 | 1719299314-1735498986 316 | 461628210-471865324 317 | 2517128070-2524600375 318 | 3080279788-3095850061 319 | 2097814073-2101401036 320 | 3442936490-3446270960 321 | 2860573369-2869986403 322 | 1450009722-1454375183 323 | 2677633624-2700457091 324 | 1116524230-1120647931 325 | 2198429635-2200634071 326 | 333679323-334302094 327 | 172697922-180250781 328 | 3568670472-3600780676 329 | 2567650852-2571689819 330 | 3991524157-4018198632 331 | 1320088804-1336761048 332 | 1441441574-1447722009 333 | 4070063946-4077134102 334 | 1518303291-1518757627 335 | 789712274-793961738 336 | 537271530-539849150 337 | 2749214451-2751716398 338 | 1252243784-1253382137 339 | 3549118851-3568670471 340 | 2608002055-2649178024 341 | 849424472-849667326 342 | 1662868529-1665937308 343 | 3347147435-3361850347 344 | 1977046180-1978396522 345 | 1510301697-1514872861 346 | 2809612788-2812017542 347 | 699757461-733301324 348 | 4145771441-4156192606 349 | 3853363014-3855584416 350 | 3237664679-3239097359 351 | 2265041728-2281659545 352 | 2146272587-2151730776 353 | 2375706172-2397802671 354 | 1219402849-1230826128 355 | 2125488963-2136467252 356 | 183326810-242569486 357 | 2147340-14658906 358 | 242569487-250277158 359 | 3014720726-3015174849 360 | 1689217997-1697645738 361 | 26620759-31443699 362 | 1696477009-1704667294 363 | 3628252831-3659254482 364 | 988172886-990269879 365 | 4134312523-4146938756 366 | 4110871648-4112682586 367 | 1977409651-1982693985 368 | 1053361409-1060474644 369 | 2101489104-2102003463 370 | 1966318308-1995738611 371 | 510056428-510157967 372 | 854676429-872751220 373 | 856029593-876424461 374 | 1471353586-1474887569 375 | 2450915001-2456382582 376 | 1407555501-1408047605 377 | 527722980-547224258 378 | 3280095407-3282589917 379 | 2909986634-2916837990 380 | 1232996245-1253914471 381 | 31086557-35734834 382 | 1694910589-1711998895 383 | 762305366-775159488 384 | 1225774520-1228140780 385 | 257330043-270391498 386 | 3915486327-3923103539 387 | 1926249337-1966318306 388 | 1178971023-1183248004 389 | 116510673-132805111 390 | 1915704972-1922908375 391 | 969412073-979230383 392 | 3986223944-3991524156 393 | 405494083-449508526 394 | 1670274140-1672828275 395 | 4255322589-4265083226 396 | 2615943647-2628573870 397 | 253900156-264130685 398 | 812381326-838878231 399 | 3676068147-3678805855 400 | 4018198634-4020002159 401 | 927634473-956957738 402 | 1728404615-1731917611 403 | 4027974514-4050074007 404 | 1698299296-1698622868 405 | 2149508758-2160191833 406 | 1160737915-1174189471 407 | 3381967104-3399337635 408 | 4057735038-4057925711 409 | 3659254484-3672311596 410 | 4064241135-4070650968 411 | 973353987-978907985 412 | 1174189473-1179817409 413 | 698277114-706179803 414 | 2873214132-2883076783 415 | 1857579377-1865963654 416 | 4218815063-4232049540 417 | 464623007-466732505 418 | 145258734-149921134 419 | 1776765373-1785155753 420 | 2328728331-2345665378 421 | 255225324-269092529 422 | 2079410577-2083947272 423 | 3797389909-3799120406 424 | 2956534572-2957931629 425 | 3744749430-3770715654 426 | 560693405-572304095 427 | 2372761028-2393875166 428 | 706179804-740943515 429 | 1875539946-1877484014 430 | 633634731-644741930 431 | 3683472347-3694077033 432 | 3701974775-3724779161 433 | 2848467395-2852263066 434 | 3730366567-3730989122 435 | 2117254263-2130476988 436 | 3698750668-3698975786 437 | 2746832288-2751564814 438 | 253658494-259116334 439 | 2364532781-2372761027 440 | 456714135-461505875 441 | 3672275679-3674478931 442 | 2522406078-2531544560 443 | 792035582-793138494 444 | 69154638-75829014 445 | 2926548046-2947393388 446 | 4220770598-4239648140 447 | 1231191898-1231698394 448 | 2032945297-2033080176 449 | 1447304643-1450009720 450 | 849303213-849636806 451 | 2580161324-2586439081 452 | 869920911-871138045 453 | 3327278827-3328956868 454 | 2987830862-3004476243 455 | 1578256762-1596421560 456 | 3725920649-3734505168 457 | 177635071-179461239 458 | 2984672502-2992711186 459 | 55507652-68823687 460 | 2455788859-2455936061 461 | 2701657503-2734666015 462 | 3602006162-3608766950 463 | 4116793339-4145771440 464 | 3461179167-3461527047 465 | 2087698-2122623 466 | 2291815799-2296911924 467 | 2596260797-2599637238 468 | 741177583-762305365 469 | 1918475929-1919207177 470 | 4170813079-4175037031 471 | 2122624-2315281 472 | 1253914472-1274319637 473 | 2487150877-2509030416 474 | 3379861818-3416060190 475 | 333646378-334048524 476 | 2326969860-2360851304 477 | 337863211-360992608 478 | 3074050973-3092995408 479 | 3110957138-3120916334 480 | 33876232-35227157 481 | 1797203899-1797849973 482 | 730720453-733433538 483 | 857489932-864404088 484 | 1829927048-1847707809 485 | 2772398259-2781857468 486 | 1244316186-1259999059 487 | 3462793245-3462944813 488 | 2182652-2214508 489 | 1060628631-1062482015 490 | 2925598220-2926530972 491 | 900674266-922436488 492 | 1178662480-1184341164 493 | 2459166082-2504309844 494 | 1910189689-1913976941 495 | 4220927757-4234807086 496 | 3969999207-3974656835 497 | 3775545128-3782028606 498 | 2734332905-2737600182 499 | 1729489128-1733660501 500 | 4156192608-4161893257 501 | 162824624-169481809 502 | 3146103157-3203151235 503 | 4041586778-4048136958 504 | 4203009505-4224632535 505 | 1110882582-1113030824 506 | 3913795915-3942297002 507 | 2271387462-2272232473 508 | 517350158-526962459 509 | 779314234-785470439 510 | 1916548840-1918281992 511 | 1888889-1904062 512 | 2664310740-2677633623 513 | 1893488044-1910189687 514 | 2242110935-2265041727 515 | 3498906702-3502025359 516 | 4258143098-4268731878 517 | 2397802673-2398500769 518 | 572676036-572701832 519 | 1446041312-1447304642 520 | 3826077985-3829627277 521 | 4020002160-4047217761 522 | 1380452883-1429557315 523 | 4047082396-4050677020 524 | 3921624009-3929261229 525 | 2619033943-2632247390 526 | 2455802505-2455982302 527 | 4224632536-4255322587 528 | 897555132-906210835 529 | 881604485-889804702 530 | 3516964473-3523121967 531 | 2304512438-2307555454 532 | 3820151660-3853363012 533 | 3820170090-3827290700 534 | 3249983509-3250443047 535 | 988351392-990103337 536 | 2740868594-2743074820 537 | 2405403685-2447661661 538 | 823437467-829851419 539 | 937422032-942832643 540 | 971602506-976542623 541 | 785880816-801146210 542 | 4277743826-4294967295 543 | 1220312589-1225494571 544 | 3067720705-3089970954 545 | 2791983488-2809612786 546 | 2591514716-2602768599 547 | 3354140278-3357144795 548 | 2995080913-3008383912 549 | 3107886744-3116206353 550 | 2390847-5537005 551 | 3203151236-3210148830 552 | 2525591016-2552221661 553 | 3356499587-3362877956 554 | 3942297003-3943746936 555 | 2369635408-2396711414 556 | 644741932-645492895 557 | 1465863404-1482131479 558 | 3943121023-3944346698 559 | 2561165265-2591514714 560 | 19449263-35238772 561 | 1082566831-1083675917 562 | 2197161910-2198528564 563 | 2826493138-2860573367 564 | 2504309845-2512953214 565 | 1627066830-1642274044 566 | 2883117929-2903014292 567 | 583190345-633634730 568 | 2973540042-2982443255 569 | 3699440664-3713677655 570 | 3746896292-3760652269 571 | 3171099262-3180938498 572 | 572697766-572756080 573 | 3988852854-3988997069 574 | 4265083227-4277743824 575 | 383972777-401061270 576 | 945475099-953801412 577 | 3528634603-3542351915 578 | 2300856021-2308581946 579 | 3122557350-3124419305 580 | 660165472-664987050 581 | 32790502-34209087 582 | 2851805721-2855373838 583 | 992214332-997255508 584 | 2732719831-2735572206 585 | 3868474597-3881441121 586 | 333379670-333580739 587 | 3381334635-3388608632 588 | 3563089705-3573594471 589 | 3210148832-3237664678 590 | 1187695934-1194142092 591 | 1438515828-1446601852 592 | 991039829-1027395932 593 | 848648599-849082618 594 | 3736687746-3774570916 595 | 8407552-13762041 596 | 2232234823-2235394467 597 | 1755371838-1765328838 598 | 1110605895-1112786421 599 | 1829011713-1846414725 600 | 1125629499-1131007777 601 | 1620448623-1622231718 602 | 1819546669-1857579375 603 | 2574044802-2579190543 604 | 44327412-53557883 605 | 743188265-775219027 606 | 2088304828-2108894963 607 | 2115234805-2135895690 608 | 3661589550-3667328781 609 | 948393409-961955386 610 | 3296787727-3307575232 611 | 591649479-623936900 612 | 3127688079-3134369195 613 | 3121554064-3122386341 614 | 4265181650-4265802278 615 | 95671345-95744284 616 | 3632933123-3652082814 617 | 2602768600-2608002053 618 | 855428909-878230687 619 | 518821859-527722979 620 | 3164805808-3166272976 621 | 1503827162-1509814674 622 | 1083143813-1083702538 623 | 1454375184-1479743870 624 | 3323759966-3345377938 625 | 3252601419-3261416869 626 | 659490354-659624437 627 | 2690988793-2694240575 628 | 2925030178-2926498213 629 | 3724779163-3731382232 630 | 2817808230-2826493137 631 | 3611600625-3612000729 632 | 1922908377-1926249336 633 | 3054727190-3057468877 634 | 2318069658-2349685562 635 | 1224408645-1230905383 636 | 3426646140-3446265909 637 | 3698560892-3703351760 638 | 3893285255-3897654014 639 | 3334017866-3341652536 640 | 3467542284-3468204110 641 | 3552641883-3560193935 642 | 1577860113-1616147289 643 | 792385239-798544023 644 | 3524508765-3535502551 645 | 2079154753-2079647911 646 | 3662660030-3676294372 647 | 1974333295-1989116976 648 | 2349685563-2364532779 649 | 1179711637-1180870951 650 | 657058762-689503958 651 | 2751716400-2791983487 652 | 2281659547-2300856020 653 | 3745499151-3746841127 654 | 3568050533-3573507136 655 | 3124419306-3133154818 656 | 707480362-726334537 657 | 2792898927-2805591285 658 | 2110314930-2140259502 659 | 3790557838-3790821659 660 | 3034617264-3054755435 661 | 2119833193-2126798390 662 | 956957739-965040695 663 | 3105127325-3113783343 664 | 2203526166-2216207342 665 | 3893109545-3895690030 666 | 1953185341-1954544580 667 | 1149483814-1151080437 668 | 2397990602-2399831274 669 | 2529540174-2531766027 670 | 3040682810-3045957235 671 | 1080702276-1112990581 672 | 2454727672-2455707974 673 | 3120916336-3122292317 674 | 1540361624-1570029586 675 | 2048523135-2052071542 676 | 1038796864-1046952356 677 | 3954274530-3958300763 678 | 2472916352-2505189818 679 | 1108664119-1110283066 680 | 3909810674-3932704041 681 | 2986410650-3000522702 682 | 2126923951-2133118178 683 | 2619513661-2648860446 684 | 745808816-752461748 685 | 2032570613-2033017246 686 | 1225966324-1231538269 687 | 1177964744-1181712502 688 | 1761008098-1766235040 689 | 3298803758-3306723635 690 | 2021641434-2024692738 691 | 1595091669-1612372139 692 | 1941821906-1960762898 693 | 2186311939-2194297020 694 | 47802669-62393198 695 | 1123500672-1124070782 696 | 2910564254-2926504746 697 | 3124929968-3130520163 698 | 3226077340-3228054324 699 | 1636675883-1644581701 700 | 1346992603-1348129673 701 | 4080421115-4101064153 702 | 1798120143-1801945969 703 | 180334939-181524921 704 | 68823688-83563926 705 | 3020761343-3021817567 706 | 1279065904-1316503183 707 | 2153948447-2169932701 708 | 3115629813-3118656717 709 | 2825214732-2828305578 710 | 2984310864-2990997583 711 | 178717970-179503517 712 | 2058539536-2067010739 713 | 3016814756-3017670406 714 | 2730476137-2736514991 715 | 39687255-44327410 716 | 3428187444-3429514630 717 | 165353608-170252815 718 | 1928294039-1947673816 719 | 2481282831-2501238225 720 | 998819145-1005462099 721 | 1752276551-1784480513 722 | 146652512-151673725 723 | 1362119775-1365250964 724 | 4160738180-4163750066 725 | 2314088362-2338653170 726 | 1298996094-1311546715 727 | 4132326237-4144090012 728 | 1254561821-1268295556 729 | 3803475478-3820151659 730 | 2093541493-2097966199 731 | 95572083-95700288 732 | 2084930491-2104963206 733 | 1333016590-1349983110 734 | 24509125-41294028 735 | 2813496284-2815951003 736 | 3170619802-3176056931 737 | 1123756904-1124832163 738 | 687462919-689373049 739 | 4160933120-4167201363 740 | 898320180-905022052 741 | 1005799857-1023924764 742 | 977044645-979628011 743 | 74989273-84281783 744 | 4212107733-4215081511 745 | 1323282537-1349961316 746 | 198929657-199463525 747 | 60359856-83903508 748 | 1535382902-1566104279 749 | 1062354273-1063440138 750 | 180250782-180836870 751 | 810842896-830439133 752 | 1815521836-1821199497 753 | 2410396425-2413223137 754 | 3005164082-3012157652 755 | 614154154-639131835 756 | 2368126375-2376371375 757 | 848742116-853217530 758 | 2812452191-2816536085 759 | 453271322-456714133 760 | 3782382849-3794182243 761 | 1231863689-1232996243 762 | 1698500883-1699628705 763 | 2837831808-2854116172 764 | 325784764-332571920 765 | 2681945893-2692689494 766 | 2242318868-2276515328 767 | 615372556-633018840 768 | 174537037-175706165 769 | 4265180056-4265548452 770 | 1946782676-1948030232 771 | 3090555846-3091254399 772 | 4075367556-4081807898 773 | 966697131-967647806 774 | 975982130-978678992 775 | 381622091-383401034 776 | 3694077034-3718390721 777 | 3066767367-3091060238 778 | 921048198-924193336 779 | 2247293647-2269423767 780 | 1518267616-1518511723 781 | 1338166110-1354456999 782 | 1457454398-1510301695 783 | 1118885758-1124129968 784 | 3782028608-3782877419 785 | 3794182244-3799566334 786 | 338019282-348095336 787 | 2882633741-2901934705 788 | 4141186961-4142165287 789 | 645486416-645944383 790 | 352101084-364591159 791 | 3600780678-3606937835 792 | 2683090964-2684370557 793 | 3541047853-3541994869 794 | 3333084429-3334030102 795 | 3126194199-3129935758 796 | 371339342-373806460 797 | 1230932008-1232187292 798 | 208470214-209193118 799 | 1354457001-1371635555 800 | 2173968513-2181884574 801 | 1918021371-1919110200 802 | 2812017543-2817808228 803 | 2724336622-2730653841 804 | 2649178025-2660374286 805 | 0-1888888 806 | 4267087346-4275541579 807 | 1247902155-1260953714 808 | 142290412-148229751 809 | 2532554358-2540855042 810 | 1795356537-1803018237 811 | 2249829541-2251006359 812 | 3239097361-3267410980 813 | 1806854808-1819546668 814 | 3368852506-3373277857 815 | 2454288937-2454315837 816 | 381773593-384357154 817 | 2406382908-2442196465 818 | 430251075-444680559 819 | 3603771632-3607267790 820 | 3032227327-3040030225 821 | 1515154393-1518755420 822 | 1135736946-1144990739 823 | 38376160-41665021 824 | 15778022-19449261 825 | 1429557316-1434743652 826 | 77180981-88138768 827 | 1371635556-1380452881 828 | 841305901-841404555 829 | 2722036559-2726308166 830 | 3172206472-3185876600 831 | 1299239255-1320088802 832 | 1725854117-1744385026 833 | 996320481-1012998985 834 | 1181698174-1215279334 835 | 3811104408-3827985303 836 | 3333480667-3334132994 837 | 333516020-333617177 838 | 3033812452-3036695198 839 | 88138770-130651123 840 | 2307295212-2314088360 841 | 3893795432-3898571061 842 | 4028277165-4057735036 843 | 3122390571-3125913885 844 | 1114116644-1125629498 845 | 3249674305-3250304612 846 | 853217531-881604483 847 | 3386154033-3411882529 848 | 201141111-231074692 849 | 1049202442-1050466108 850 | 3445599644-3446951202 851 | 1179668312-1183015015 852 | 3255408881-3258664273 853 | 1976455908-1981569398 854 | 1952856244-1954468652 855 | 2666556582-2696725230 856 | 2031809521-2032325253 857 | 2934698477-2934714455 858 | 567907436-583190343 859 | 1140499208-1145440329 860 | 482552525-517350156 861 | 645492896-655022834 862 | 2306386691-2307678393 863 | 95538211-95699883 864 | 1865963655-1896438172 865 | 3014938823-3017205093 866 | 664741090-683754272 867 | 1539845876-1547041263 868 | 2569184033-2569739585 869 | 2596632054-2606025914 870 | 2568570852-2589262191 871 | 3914231660-3927512695 872 | 461505876-477369324 873 | 1514872862-1520470677 874 | 1298955403-1302935547 875 | 2340961777-2357367276 876 | 1421012173-1422211362 877 | 1911306751-1915704971 878 | 1622231719-1651098252 879 | 1111783809-1114116642 880 | 801146212-841305900 881 | 1184341165-1219402847 882 | 208515089-208552663 883 | 113739263-118476142 884 | 1716816645-1725854116 885 | 717297025-730844938 886 | 2260605394-2268237426 887 | 2469379666-2484990280 888 | 1891682888-1896393627 889 | 2268097794-2279310973 890 | 1872987167-1876038388 891 | 3922364684-3927485573 892 | 870013786-874312926 893 | 487920315-496959388 894 | 2300879142-2309452712 895 | 3339096993-3347147433 896 | 2376318475-2387155565 897 | 853636490-865748846 898 | 1489714174-1498479204 899 | 2378938290-2394510167 900 | 671771167-680588355 901 | 3307872338-3309633505 902 | 2333653700-2351930363 903 | 1256216667-1271177293 904 | 275430327-303429552 905 | 841404557-850304042 906 | 2223088279-2236937230 907 | 649410540-651327653 908 | 2655227264-2664310738 909 | 3896607653-3902120279 910 | 2981077775-2984310862 911 | 2220986676-2230179027 912 | 3653104767-3654804499 913 | 4169345300-4203009503 914 | 754983804-774841798 915 | 659376850-659571678 916 | 3009855031-3010464245 917 | 4220535116-4240517613 918 | 3503171717-3503206049 919 | 3122936808-3128912932 920 | 55099720-72174340 921 | 1970582126-1980928849 922 | 3999140749-4011567231 923 | 2540135228-2548563437 924 | 486840577-493667077 925 | 3421523242-3436385357 926 | 304620939-307244601 927 | 3584674908-3594238408 928 | 3857534623-3859943891 929 | 1681316840-1713630743 930 | 1083260069-1083705127 931 | 3124888764-3146103155 932 | 1189498321-1216312827 933 | 1552856847-1563782649 934 | 3008845968-3009980589 935 | 2079074374-2082559497 936 | 4110762479-4111056886 937 | 990957769-992049690 938 | 3782547468-3791579659 939 | 3012157654-3020860593 940 | 3665026148-3676239424 941 | 992049691-1026588637 942 | 3524660322-3531103252 943 | 1878298966-1882615092 944 | 3923196013-3942202205 945 | 2578473159-2584766311 946 | 90607936-122424387 947 | 3540610321-3541605330 948 | 3979731432-3982143719 949 | 828074268-833118498 950 | 1488736510-1488749429 951 | 1300869665-1307542773 952 | 1877663796-1888931788 953 | 4167201364-4190293895 954 | 3265098769-3267509956 955 | 4064016721-4074827871 956 | 2100409724-2101804552 957 | 4214567163-4233290691 958 | 189717203-231296345 959 | 3164583326-3164801067 960 | 1744385028-1770167107 961 | 4121108358-4145079404 962 | 753388973-777355343 963 | 3164636578-3164954504 964 | 4116483700-4133896167 965 | 33752855-34032233 966 | 4111742153-4113213993 967 | 1043487579-1054622271 968 | 3021132103-3046193303 969 | 3164839823-3180738585 970 | 4103181605-4105869442 971 | 754905815-761743025 972 | 1952665910-1953433270 973 | 2314883517-2324534151 974 | 2993732550-3009897818 975 | 3420873563-3423164569 976 | 2810181095-2811456553 977 | 2010165801-2023812035 978 | 1885135264-1889950507 979 | 4144857306-4153676723 980 | 869398480-871470963 981 | 1105472905-1110869617 982 | 314394787-318243942 983 | 3503101007-3503172522 984 | 4159475284-4194909281 985 | 2191923377-2203526164 986 | 896676315-921551112 987 | 304481071-305508611 988 | 984250575-987645320 989 | 4101064155-4103439647 990 | 3419009909-3446424945 991 | 547023756-549064661 992 | 4282390963-4283810466 993 | 977739722-984250573 994 | 3152153827-3180871559 995 | 2183409610-2198198790 996 | 1912187897-1912964610 997 | 4288558455-4293415604 998 | 650443681-652917734 999 | 2810679676-2811896595 1000 | 4284399257-4290240034 1001 | 3945907965-3977860104 1002 | 896507573-927634471 1003 | 2594571102-2596729241 1004 | 650340896-651904869 1005 | 3663512068-3674686506 1006 | 1702145201-1716816643 1007 | 4102028316-4103476760 1008 | 2140259504-2143344425 1009 | 3889682782-3898950708 1010 | 3242636904-3246887557 1011 | 11174641-18449276 1012 | 290513163-292256515 1013 | 1062125199-1073411726 1014 | 2412362250-2415099013 1015 | 422226966-428387779 1016 | 3306156-16019348 1017 | 3305613991-3308042567 1018 | 3523121969-3528068884 1019 | 3523265294-3525005629 1020 | 1149933405-1152331697 1021 | 2087247913-2100886247 1022 | 2691075518-2693026017 1023 | 3356323513-3364246395 1024 | 373151936-405494081 1025 | 369068300-381423906 1026 | 1025569374-1036920439 1027 | 3252901420-3270033863 1028 | 2719048254-2735630821 1029 | 1766292061-1780626493 1030 | 848394147-848657039 1031 | 420719565-431765901 1032 | 1514895780-1515289801 1033 | 2519005205-2557015796 1034 | 740943517-747508062 1035 | 2972353231-2983357025 1036 | 967792496-971809354 1037 | 824340711-829628532 1038 | 965040697-966871284 1039 | 1486637472-1496349918 1040 | 2543366907-2559522939 1041 | 3320919376-3333042521 1042 | 1150347115-1155284378 1043 | 2181884575-2200064456 1044 | 990865894-991355669 1045 | 2692987724-2694585947 1046 | 3288275136-3307945139 1047 | 3616593385-3618107349 1048 | 3565775907-3597807291 1049 | 3444367535-3446735109 1050 | 561517921-574215242 1051 | 1337238857-1349083727 1052 | 991010485-991631272 1053 | 315759690-333151197 1054 | 462446579-465758715 1055 | 1684699734-1706672921 1056 | 1230826129-1231575999 1057 | 3617829061-3618192413 1058 | 3601718684-3616108546 1059 | 3408662775-3410669980 1060 | 1780045799-1783004862 1061 | 217154892-241204500 1062 | 4135176740-4147913097 1063 | 460349581-465632949 1064 | 3194132621-3200446332 1065 | 620532470-637639642 1066 | 3984428673-3986115872 1067 | 782503719-796872832 1068 | 3983601983-3985969366 1069 | 3014748925-3034829048 1070 | 3403049585-3409700128 1071 | 4139874731-4143631115 1072 | 2140849733-2153948446 1073 | 2934672189-2934698845 1074 | 572351719-575778209 1075 | 2076891858-2081262092 1076 | -------------------------------------------------------------------------------- /input/21.txt: -------------------------------------------------------------------------------- 1 | rotate right 1 step 2 | swap position 2 with position 4 3 | rotate based on position of letter g 4 | rotate left 4 steps 5 | swap position 6 with position 0 6 | swap letter h with letter a 7 | swap letter d with letter c 8 | reverse positions 2 through 4 9 | swap position 2 with position 4 10 | swap letter d with letter e 11 | reverse positions 1 through 5 12 | swap letter b with letter a 13 | rotate right 0 steps 14 | swap position 7 with position 3 15 | move position 2 to position 1 16 | reverse positions 2 through 5 17 | reverse positions 4 through 7 18 | reverse positions 2 through 7 19 | swap letter e with letter c 20 | swap position 1 with position 7 21 | swap position 5 with position 7 22 | move position 3 to position 6 23 | swap position 7 with position 2 24 | move position 0 to position 7 25 | swap position 3 with position 7 26 | reverse positions 3 through 6 27 | move position 0 to position 5 28 | swap letter h with letter c 29 | reverse positions 2 through 3 30 | swap position 2 with position 3 31 | move position 4 to position 0 32 | rotate based on position of letter g 33 | rotate based on position of letter g 34 | reverse positions 0 through 2 35 | swap letter e with letter d 36 | reverse positions 2 through 5 37 | swap position 6 with position 0 38 | swap letter a with letter g 39 | swap position 2 with position 5 40 | reverse positions 2 through 3 41 | swap letter b with letter d 42 | reverse positions 3 through 7 43 | swap position 2 with position 5 44 | swap letter d with letter b 45 | reverse positions 0 through 3 46 | swap letter e with letter g 47 | rotate based on position of letter h 48 | move position 4 to position 3 49 | reverse positions 0 through 6 50 | swap position 4 with position 1 51 | swap position 6 with position 4 52 | move position 7 to position 5 53 | swap position 6 with position 4 54 | reverse positions 5 through 6 55 | move position 0 to position 6 56 | swap position 5 with position 0 57 | reverse positions 2 through 5 58 | rotate right 0 steps 59 | swap position 7 with position 0 60 | swap position 0 with position 2 61 | swap position 2 with position 5 62 | swap letter h with letter c 63 | rotate left 1 step 64 | reverse positions 6 through 7 65 | swap letter g with letter a 66 | reverse positions 3 through 7 67 | move position 2 to position 4 68 | reverse positions 0 through 6 69 | rotate based on position of letter g 70 | swap position 0 with position 6 71 | move position 2 to position 0 72 | rotate left 3 steps 73 | reverse positions 2 through 5 74 | rotate based on position of letter a 75 | reverse positions 1 through 4 76 | move position 2 to position 3 77 | rotate right 2 steps 78 | rotate based on position of letter f 79 | rotate based on position of letter f 80 | swap letter g with letter a 81 | rotate right 0 steps 82 | swap letter f with letter h 83 | swap letter f with letter b 84 | swap letter d with letter e 85 | swap position 0 with position 7 86 | move position 3 to position 0 87 | swap position 3 with position 0 88 | rotate right 4 steps 89 | rotate based on position of letter a 90 | reverse positions 0 through 7 91 | rotate left 6 steps 92 | swap letter d with letter h 93 | reverse positions 0 through 4 94 | rotate based on position of letter f 95 | move position 5 to position 3 96 | move position 1 to position 3 97 | move position 6 to position 0 98 | swap letter f with letter c 99 | rotate based on position of letter h 100 | reverse positions 6 through 7 101 | -------------------------------------------------------------------------------- /input/23.txt: -------------------------------------------------------------------------------- 1 | cpy a b 2 | dec b 3 | cpy a d 4 | cpy 0 a 5 | cpy b c 6 | inc a 7 | dec c 8 | jnz c -2 9 | dec d 10 | jnz d -5 11 | dec b 12 | cpy b c 13 | cpy c d 14 | dec d 15 | inc c 16 | jnz d -2 17 | tgl c 18 | cpy -16 c 19 | jnz 1 c 20 | cpy 98 c 21 | jnz 91 d 22 | inc a 23 | inc d 24 | jnz d -2 25 | inc c 26 | jnz c -5 27 | -------------------------------------------------------------------------------- /input/24.txt: -------------------------------------------------------------------------------- 1 | ######################################################################################################################################################################################### 2 | #.#.....#.........#.....#.......#.#...........#...#.....................#...................#.....#.......#.#...#...................#...#...........#...#...#...#...#...#...#.....#...#.# 3 | #.###.#.#.###.#.#.#.#.#.#########.#.#.###.#.#.#.###.#.#.#.#####.#.###.###.#.###.#.#.#.###.#.#.#.#.#.#.#.#.#.#.#.#.###.###.#.#.#.#.#.#.###.###.#.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.#.#.#.#.# 4 | #.#...#.#...#...#...#.........#...#...#...#.............#.......#.....#.....#...#.#.......#.......#.........#.#.#...#...#...#.....#...#...#.#.#.#..3#.....#.........#.#...#.....#.#...#.# 5 | #.#.#.#.#.#.#.#.#.#.#.###.###.#.#####.#.#.#####.#.###.#####.#.###.#.###.#.###.#####.###.###.#.###.#.#.#.###.#####.###.###.###.#.###.#.#####.#.###.#.#.###.###.#.###.#.###.#.###.###.#.#.# 6 | #.....#.....#...#.....#...#.#.#.#...#...#...#.#...#...#.......#...#.....#...#.....#.......#.#...#.....#...#.#...#.....#.....#.#.#...#.#.......#.......#...#...#.#.#.#.#.#...#.......#.#.# 7 | #.###.#.###.#.###.#.#.#.#.#.#####.#.#.#.#####.#.#.#.#.#.#.#.###.#.#.###.#.#.#.###.###.###.#.###.#.#.#.###.#.#.###.#.#####.#.#.#.#.#.#.#.#####.#.#.#.###.#.#.#.###.#.#.#.###.#.#######.#.# 8 | #...#.#.#5#.#.........#.....#.....#.#.#.#...........#.#.....#.#...#.........#.....#...#.#...#.#.#.#...#.....#...#.#.....#...#...#.#.#...#.#.....#...#...#.....#.......#...#...#.....#...# 9 | #.#.#.###.#.#########.###.#.###.#.#.#.###.#.#######.#.#.#.#.#.#.#######.###.#.#.#.#.###.#.###.#.#.#.###.#.#####.###.###.###.#.#.#.#.#.#.#.###.#####.#######.#.#.#.###.#.#.###.#.###.###.# 10 | #...#.#.......#.#.......#.#...#...#.....#.#.#.....#.#...#...#...#.....#.....#.#...#.#.........#.....#...........#.......#.....#...#.#.....#.......#.#...#...#.#.......#.#.#.#.#.........# 11 | ###.#.#.###.#.#.#.#.#.#.#.#.#.#.#######.#.#.#.#.###.#.#.###.#.#.#.#.#.#.#####.#####.#.#.#.###.#.#####.#.#.#.###.#.#.#.###.#.#.#.#.#.#.#.#.#.#.###.###.#.#.#.#.#.#.#.#.#####.###.#######.# 12 | #.#...#.#...#.#.....#...#...#...#.....#.........#.............#.......#.............#.........#.......#...#...#...#.......#.....#.......#...#.....#.....#.........#.#.#...#.#...#.....#6# 13 | #.#.#.#.###.#.#.###.#.#.#.#.#.###.#.#.#.#.#####.#.#.###.#.###.#.#.#######.#.#####.#.#######.#####.#######.#.###.#.#####.#.#.#.#.#.#####.#.#.#.#.#.#######.###.#.###.#.#.#.#.#.#.#.#.#.#.# 14 | #...#.#...#.#...........#...#.......#...#...#.......#...#.#.....#.#.................#...#...#.#.....#.....#.#.......#...#.....#...#.#...#.......#.#.#...#.......#...#.#.#.........#.....# 15 | #####.###.#.###.#####.###.#.#.#.#####.#.###.#.#.#####.#.#.#.#.#.###.#####.###.#.#####.###.#.#.#.#.#.###.###.#######.#.#.#.#.#.#.#.#.###.###.###.###.#.#.#.#.#####.#.#.###.#.#####.###.### 16 | #...#.#.........#.#...#.#...........#.#...#...#.#...#...#...#.......#...#...#...............................#.....#...#...#.....#...#.#.#.#...#.#.......#.....#.....#.#.#...#...#...#...# 17 | ###.#.#.#########.#.###.#.#.###.#######.#.###.#.#.###.#.#.###.#####.###.#.#.#####.#.#.#.#.###.###.#.#.#.#.#.#.#######.#.#.#.###.###.#.#.#.#.#.###.###.###.###.#####.#.#.#.#.###.#.#.#.#.# 18 | #.#...#.#.#.#.......#...#.....#.#...#...#.....#.............#.#...#.#...#.#.......#.......#...................#.....#.#.....#.#...#.#...#.#...#...#...#...#.....#.#...#.........#...#...# 19 | #.#.#.###.#.#########.#.#.#.#.#.#.#.#.###.#.###.#.#.#.#.#######.#.#####.#####.#.#.###.###.#.#.#.###.#####.###.#.#.#.#.#.#.###.#####.#####.#.#.#####.#######.###.#.#.#.#.#.#####.###.#.#.# 20 | #...#.#.....#.#.#4#.#...#...#.........#.#.#...#...#.#.#.....#...#.#.....#.....#.......#...#.#.#.......#...#.#...#.....#.#.....#.........#.#...#.........#...#.#...#...............#.#...# 21 | #####.#.#.###.#.#.#.#.#.###.#.#.###.###.#.#.#.#.#.#.###.###.#.#.#.#.#######.###.###.#.###.#.#####.#.###.#.#.###.#####.#.#######.#.#######.###.#.#.###.#.#.###.#.#########.#.###.#.#.###.# 22 | #...#.....#.....#.......#.#...#.#.#.#.....#...#.#.#...........#.#.............#.#.......#.#.#...........#.............#.....#.#.......#...#.....#.#...#.#...#.#.........#.#...#.#...#...# 23 | #.#.#.###.#########.#.#.#.#.#.###.###.###.#######.#.#.###.#.#.#.#.###.#.#.#.#.###.#####.###.#####.#.###.#.#.###.#.#.#.#####.#.#.#.#.###.#.#.#.###.#.###.#.#.#.#.###.###.#.#.#######.#.### 24 | #...#.....#.#.......#...#.#...#.......#.......#...#.#...#...#.#.#...........#...#.......#...#.......#.#.....#.....#...#.......#...#.........#.....#.#.#.#.#...#.#.........#...........#.# 25 | #.#.###.#.#.#.#.#.#.#.#.#.#.#.#.###.#.#.#.#.#.#.#.###.###.###.#.#.#.#####.###.#.#.#########.#.#.###.#.#.#.###.###.#.#.###.#.#.#.#.###.#.#.#.#.#.#.#.#.#.#.#.###.#.###.#.#.#.#####.#.#.#.# 26 | #.#.....#.#...#.#.#.#.#...#.......#.#...#.#.#.#...#...#.......#.......#...#...#.#...#.....#.#...#...#...#.........#...#.#.#.....#.#.....#.....#.............#...#.......#...........#...# 27 | #.#.#.#.#.#.###.###.###.###.#.###.#.#.#.#.#.#.#.#.#.#######.#####.#.#.#####.#.#.###.#.#.#####.#.#####.#.#.#.#.#.#.###.#.###.#.###.#.#.###.###.#.#.#.#.#.###.#.#.#.###.###.#.#.#####.##### 28 | #...#.........#.....#.#.....#.....#.#...#.#...#...........#.#.......#.........#...............#.#...#...#.#...#.....#.#.#.....#...#.......#...#.....#...#...#.....#...#...#...#7#.......# 29 | #.#.#.###.#######.###.#.#####.#.###.#.###.#.#######.#.#.#.#.###.###.#.#.#####.#.#.#.###.#.#.###.#.#.#####.#.#.###.#.#.#.#.#.###.#.#.#.###.#.#.###.#####.#.###.#.###.#.###.#.#.#.#######.# 30 | #...#.#.............#.#...#0..#.#...........#.#.............#...#...#...#.......#.....#...#.......#...#.....#.....#.#.#.#...#.#.#.#...#...#...#.....#.#.#...........#.....#.....#.#.....# 31 | ###.#.###.#.#.#.#.#.#.###.#.#.#.###.###.#####.#.#####.###.#.#.#.#.#####.#.#.#.#####.#####.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.#.#.#.#.#.#####.#.###.#####.#.#.###.#######.#.#.#.#####.#.#.#.# 32 | #.#.....#...#.......#.....#.....#...#.....#...........#...#.....#.#.....#.......#.....#.....#.............#.#...#.....#.#.........#...#...#.#.............#...#...#...#.#...#.#.......#.# 33 | #.#.#.#.#.###.###.###.#.#.#.#######.#.#.#.#####.#.###.#.###.#.#.#.#.###.#.###.#.#.###.#.#.#.#########.#.#.#.###.#.#.###.#.#######.#.###.#.#.#.#.#.#.###.#.#.#.###.#.#.#.#####.#.#.###.### 34 | #.....#...#.......#.....#...#.#.....#...#.........#...#.....#.#...#.......#...............#.#.......#.......#.#...........#.....#.......#.#.#.#.#...#.......#.....#.....#...#.......#...# 35 | #.###.###.#.#######.#.#.#.#.#.#.#.#.###.#.#######.#.###.#.#####.###.#.###.###.#####.#.###.###.#.#.#.#####.#.#.#.#########.#.#.#.#####.#.#.#.###.#.###.#.###.#.###.###.#.#.#.#.#.#.#.#.#.# 36 | #.#.#.......#.#.#...#.....#.....#.#...#.....#...#.....#.#.#...........#...#...#...#.....#...#.......#.#.....#.........#...#.#...........#.#.#...#...#......1#.....#...#.#...#...#...#...# 37 | #.#.#.#.#####.#.#.###.#####.#####.#.#.###.###.#.#####.###.#.#.#.#.#####.###.###.#.#.###.###.#######.#.###.#.#.###.#.#.#.###.#.###########.#.#.###.#######.#######.#.###.###.#.#.#.###.#.# 38 | #...#.........#.....#...#.....#.....#...#.....#.......#.#...#...#.#.......#.....#...#.........#.....#...#.#.#...............#.............#.......#.........#.........#...........#.....# 39 | #.#.#.###.#.#.#.###.###.#.#####.#####.#.###.#.###.#.#.#.###.#.#####.#.###.#.#.#.#.#.#.#.###.###.###.###.#.#.#.#.#.#.#####.###.#.#.#######.#.#.#.###.#.###.#.#.#.###.#####.###.###.#.#.### 40 | #.........#.....#.......#....2#.........#.....#.....#.#.......#.#.#.......#.#...#...........#.#.#...#...#.#...#.....#.....#.#.#.#.#.......#...#.#.#.#.........#.#.........#.#...#...#.#.# 41 | ######################################################################################################################################################################################### 42 | -------------------------------------------------------------------------------- /input/25.txt: -------------------------------------------------------------------------------- 1 | cpy a d 2 | cpy 14 c 3 | cpy 182 b 4 | inc d 5 | dec b 6 | jnz b -2 7 | dec c 8 | jnz c -5 9 | cpy d a 10 | jnz 0 0 11 | cpy a b 12 | cpy 0 a 13 | cpy 2 c 14 | jnz b 2 15 | jnz 1 6 16 | dec b 17 | dec c 18 | jnz c -4 19 | inc a 20 | jnz 1 -7 21 | cpy 2 b 22 | jnz c 2 23 | jnz 1 4 24 | dec b 25 | dec c 26 | jnz 1 -4 27 | jnz 0 0 28 | out b 29 | jnz a -19 30 | jnz 1 -21 31 | -------------------------------------------------------------------------------- /input/3.txt: -------------------------------------------------------------------------------- 1 | 810 679 10 2 | 783 255 616 3 | 545 626 626 4 | 84 910 149 5 | 607 425 901 6 | 556 616 883 7 | 938 900 621 8 | 638 749 188 9 | 981 415 634 10 | 680 557 571 11 | 523 604 270 12 | 910 954 484 13 | 464 392 514 14 | 458 52 687 15 | 696 438 832 16 | 213 583 966 17 | 572 571 922 18 | 451 42 686 19 | 177 390 688 20 | 151 136 705 21 | 92 413 191 22 | 789 676 377 23 | 486 262 600 24 | 450 708 472 25 | 556 9 481 26 | 157 85 94 27 | 574 93 549 28 | 539 165 487 29 | 815 742 73 30 | 353 773 428 31 | 526 152 680 32 | 433 711 557 33 | 168 632 306 34 | 848 992 757 35 | 885 786 890 36 | 469 475 146 37 | 899 833 137 38 | 864 202 688 39 | 101 902 620 40 | 529 937 826 41 | 41 381 521 42 | 562 883 804 43 | 468 197 272 44 | 451 8 420 45 | 561 193 630 46 | 597 951 383 47 | 171 845 251 48 | 541 810 157 49 | 268 46 712 50 | 332 2 397 51 | 100 47 436 52 | 194 665 205 53 | 325 277 21 54 | 170 652 205 55 | 765 165 506 56 | 15 257 144 57 | 762 124 401 58 | 662 543 531 59 | 29 425 308 60 | 667 785 299 61 | 935 758 405 62 | 504 998 367 63 | 771 947 630 64 | 490 933 978 65 | 441 498 896 66 | 862 896 607 67 | 655 935 194 68 | 286 240 324 69 | 368 723 311 70 | 419 762 600 71 | 316 903 529 72 | 197 215 215 73 | 551 461 77 74 | 855 318 7 75 | 894 690 86 76 | 451 648 416 77 | 608 132 385 78 | 420 761 112 79 | 560 711 195 80 | 371 750 506 81 | 188 307 584 82 | 26 377 622 83 | 304 701 292 84 | 286 630 642 85 | 883 880 379 86 | 774 564 597 87 | 300 692 701 88 | 529 595 27 89 | 740 76 445 90 | 567 648 422 91 | 340 163 901 92 | 374 775 902 93 | 308 827 882 94 | 529 371 374 95 | 996 587 162 96 | 534 360 516 97 | 924 160 276 98 | 724 896 687 99 | 929 971 578 100 | 798 252 761 101 | 512 991 812 102 | 465 758 49 103 | 724 446 571 104 | 482 196 544 105 | 553 247 86 106 | 624 552 778 107 | 73 143 127 108 | 556 471 749 109 | 224 927 383 110 | 133 636 847 111 | 174 985 569 112 | 572 819 881 113 | 282 818 383 114 | 535 429 780 115 | 953 540 815 116 | 577 302 494 117 | 530 654 370 118 | 670 739 168 119 | 700 695 806 120 | 196 48 928 121 | 255 805 749 122 | 65 96 969 123 | 292 860 929 124 | 556 269 297 125 | 43 832 407 126 | 542 723 438 127 | 919 139 407 128 | 709 194 955 129 | 847 237 933 130 | 321 41 216 131 | 778 749 374 132 | 782 745 529 133 | 716 572 251 134 | 90 49 976 135 | 639 557 740 136 | 148 125 784 137 | 143 819 382 138 | 71 729 563 139 | 309 500 806 140 | 25 412 594 141 | 296 600 237 142 | 681 187 142 143 | 758 913 288 144 | 163 972 266 145 | 197 352 190 146 | 383 190 562 147 | 206 214 393 148 | 566 307 294 149 | 2 284 335 150 | 564 472 394 151 | 635 928 589 152 | 169 744 574 153 | 710 386 589 154 | 970 386 827 155 | 943 424 134 156 | 846 269 712 157 | 266 765 615 158 | 344 824 685 159 | 250 222 554 160 | 377 586 859 161 | 398 526 275 162 | 317 996 937 163 | 503 364 389 164 | 212 782 533 165 | 584 539 589 166 | 731 200 584 167 | 773 389 578 168 | 43 482 104 169 | 432 140 339 170 | 193 758 673 171 | 612 882 582 172 | 314 920 130 173 | 522 40 26 174 | 695 939 149 175 | 955 121 552 176 | 728 850 661 177 | 524 766 433 178 | 817 221 992 179 | 753 580 543 180 | 72 392 873 181 | 445 897 3 182 | 144 508 567 183 | 354 990 566 184 | 477 392 687 185 | 602 846 520 186 | 321 577 677 187 | 716 518 55 188 | 367 77 545 189 | 361 473 504 190 | 98 893 887 191 | 854 920 887 192 | 860 174 30 193 | 389 857 797 194 | 686 968 907 195 | 613 275 595 196 | 855 440 906 197 | 749 494 735 198 | 527 895 550 199 | 767 971 488 200 | 118 814 148 201 | 854 193 480 202 | 847 425 378 203 | 697 159 357 204 | 282 476 48 205 | 96 314 176 206 | 949 597 903 207 | 956 478 885 208 | 714 754 278 209 | 757 547 210 210 | 53 223 170 211 | 355 725 928 212 | 930 780 762 213 | 924 581 266 214 | 570 132 283 215 | 625 674 529 216 | 159 719 325 217 | 316 670 929 218 | 55 655 542 219 | 344 19 791 220 | 437 805 312 221 | 327 867 647 222 | 521 405 496 223 | 383 58 117 224 | 638 36 175 225 | 924 59 112 226 | 401 66 353 227 | 740 785 823 228 | 713 725 622 229 | 821 702 246 230 | 378 24 958 231 | 690 718 924 232 | 486 788 537 233 | 377 214 670 234 | 514 720 427 235 | 451 927 877 236 | 808 868 872 237 | 554 94 2 238 | 534 516 715 239 | 735 318 125 240 | 880 496 755 241 | 724 115 567 242 | 23 105 89 243 | 725 55 561 244 | 599 44 581 245 | 378 661 173 246 | 628 640 632 247 | 747 817 448 248 | 557 248 338 249 | 743 833 776 250 | 309 895 759 251 | 18 696 851 252 | 328 775 356 253 | 220 37 499 254 | 865 390 651 255 | 736 397 205 256 | 645 949 170 257 | 638 860 143 258 | 23 262 98 259 | 822 46 842 260 | 663 687 860 261 | 941 700 745 262 | 762 304 509 263 | 154 275 369 264 | 728 155 324 265 | 99 113 485 266 | 245 82 62 267 | 294 76 484 268 | 215 664 398 269 | 146 336 461 270 | 102 591 503 271 | 535 814 749 272 | 250 410 892 273 | 672 467 212 274 | 304 108 285 275 | 300 246 11 276 | 4 304 284 277 | 115 132 112 278 | 460 334 739 279 | 453 281 792 280 | 505 591 6 281 | 482 413 975 282 | 26 763 980 283 | 226 377 727 284 | 406 59 39 285 | 570 325 691 286 | 333 438 966 287 | 267 792 229 288 | 130 384 854 289 | 375 165 187 290 | 37 498 403 291 | 357 509 242 292 | 710 796 296 293 | 708 187 265 294 | 46 762 279 295 | 84 589 760 296 | 578 38 226 297 | 624 558 570 298 | 338 517 276 299 | 547 498 648 300 | 626 265 677 301 | 144 662 193 302 | 581 820 407 303 | 477 567 232 304 | 582 890 926 305 | 167 458 502 306 | 635 841 607 307 | 505 346 239 308 | 522 970 506 309 | 608 830 686 310 | 100 89 353 311 | 95 159 652 312 | 24 163 786 313 | 328 313 534 314 | 793 52 249 315 | 750 274 683 316 | 885 463 247 317 | 534 326 391 318 | 938 726 199 319 | 893 620 120 320 | 899 410 508 321 | 226 896 459 322 | 677 694 780 323 | 880 15 831 324 | 909 683 903 325 | 55 7 541 326 | 294 221 109 327 | 286 216 507 328 | 239 652 380 329 | 948 760 431 330 | 772 258 275 331 | 562 226 631 332 | 503 264 765 333 | 690 42 369 334 | 761 541 373 335 | 232 596 75 336 | 925 60 402 337 | 550 181 16 338 | 600 579 701 339 | 92 419 696 340 | 26 117 290 341 | 4 487 157 342 | 21 474 308 343 | 99 827 835 344 | 279 216 451 345 | 267 739 749 346 | 309 456 262 347 | 320 91 282 348 | 52 431 304 349 | 773 784 932 350 | 474 483 932 351 | 703 975 257 352 | 851 227 584 353 | 17 224 365 354 | 845 96 536 355 | 258 150 905 356 | 797 119 876 357 | 862 196 220 358 | 954 964 355 359 | 534 979 302 360 | 905 509 628 361 | 153 185 273 362 | 169 538 509 363 | 43 477 356 364 | 702 357 940 365 | 340 403 284 366 | 638 86 744 367 | 329 426 903 368 | 222 720 682 369 | 127 624 253 370 | 28 849 485 371 | 555 158 599 372 | 553 690 443 373 | 598 926 185 374 | 611 934 868 375 | 986 8 983 376 | 166 396 946 377 | 500 822 662 378 | 507 715 828 379 | 294 790 587 380 | 661 779 235 381 | 549 594 657 382 | 771 918 800 383 | 923 896 983 384 | 866 203 437 385 | 723 465 852 386 | 589 717 731 387 | 332 331 710 388 | 984 484 794 389 | 750 479 886 390 | 857 5 286 391 | 400 841 63 392 | 665 513 508 393 | 841 739 513 394 | 331 586 669 395 | 420 561 690 396 | 346 104 22 397 | 847 758 149 398 | 570 211 816 399 | 524 868 962 400 | 483 229 317 401 | 408 555 325 402 | 682 650 285 403 | 646 987 974 404 | 467 368 779 405 | 442 640 968 406 | 644 131 184 407 | 903 916 162 408 | 565 890 91 409 | 474 763 351 410 | 569 178 709 411 | 520 618 666 412 | 437 75 213 413 | 509 471 758 414 | 298 486 904 415 | 364 416 429 416 | 513 971 271 417 | 169 863 202 418 | 15 206 565 419 | 163 69 713 420 | 167 186 542 421 | 908 550 89 422 | 936 764 451 423 | 118 467 464 424 | 89 385 375 425 | 179 165 545 426 | 143 514 187 427 | 313 47 636 428 | 477 830 550 429 | 769 808 577 430 | 74 756 630 431 | 698 799 654 432 | 721 387 36 433 | 993 763 945 434 | 707 746 7 435 | 955 113 948 436 | 723 532 526 437 | 174 795 204 438 | 671 968 575 439 | 523 256 109 440 | 570 186 296 441 | 350 351 215 442 | 141 251 22 443 | 532 217 695 444 | 460 37 719 445 | 695 69 516 446 | 36 597 350 447 | 670 552 556 448 | 287 143 35 449 | 400 801 45 450 | 133 921 71 451 | 637 169 646 452 | 108 721 890 453 | 655 681 311 454 | 885 393 603 455 | 375 388 113 456 | 976 522 534 457 | 15 516 627 458 | 685 602 535 459 | 669 390 781 460 | 845 950 348 461 | 388 30 379 462 | 825 955 46 463 | 360 579 898 464 | 363 573 660 465 | 33 30 864 466 | 905 723 916 467 | 968 648 655 468 | 178 181 363 469 | 754 262 268 470 | 883 837 45 471 | 216 687 222 472 | 520 973 909 473 | 808 968 943 474 | 335 3 202 475 | 211 605 517 476 | 32 298 358 477 | 184 488 173 478 | 741 23 328 479 | 400 482 144 480 | 626 491 451 481 | 920 546 219 482 | 363 734 861 483 | 739 417 685 484 | 954 470 541 485 | 598 679 950 486 | 550 372 450 487 | 980 459 213 488 | 353 374 293 489 | 720 220 256 490 | 173 29 571 491 | 289 769 833 492 | 372 793 345 493 | 578 298 332 494 | 763 225 167 495 | 258 519 307 496 | 504 7 649 497 | 186 319 883 498 | 358 322 918 499 | 293 60 330 500 | 373 562 550 501 | 310 532 573 502 | 741 129 533 503 | 701 614 869 504 | 54 736 587 505 | 451 131 817 506 | 499 784 651 507 | 931 681 193 508 | 674 311 500 509 | 900 312 197 510 | 553 94 331 511 | 9 715 572 512 | 590 97 275 513 | 579 713 299 514 | 20 345 741 515 | 817 738 534 516 | 819 963 497 517 | 168 303 997 518 | 462 599 698 519 | 400 772 485 520 | 755 922 928 521 | 591 847 180 522 | 500 135 977 523 | 946 940 751 524 | 658 368 790 525 | 720 714 141 526 | 850 261 594 527 | 615 116 476 528 | 660 156 488 529 | 485 895 378 530 | 797 992 614 531 | 847 652 838 532 | 842 516 364 533 | 745 444 329 534 | 175 362 84 535 | 684 223 578 536 | 43 291 394 537 | 702 222 862 538 | 208 247 494 539 | 601 236 234 540 | 780 53 675 541 | 754 135 126 542 | 26 776 52 543 | 735 716 136 544 | 591 829 171 545 | 606 373 824 546 | 51 926 766 547 | 273 161 558 548 | 215 557 149 549 | 393 703 653 550 | 318 208 207 551 | 891 54 570 552 | 790 153 689 553 | 521 693 423 554 | 559 986 542 555 | 58 611 404 556 | 178 509 602 557 | 684 120 975 558 | 791 407 811 559 | 94 321 66 560 | 14 317 266 561 | 108 14 271 562 | 580 454 391 563 | 781 82 849 564 | 419 406 775 565 | 396 298 237 566 | 448 375 330 567 | 747 301 322 568 | 103 835 120 569 | 138 897 630 570 | 127 102 546 571 | 518 552 412 572 | 398 442 43 573 | 586 972 380 574 | 30 535 91 575 | 42 384 962 576 | 61 414 942 577 | 610 147 65 578 | 945 155 418 579 | 667 54 375 580 | 473 251 187 581 | 440 222 124 582 | 886 158 163 583 | 862 493 149 584 | 805 451 536 585 | 59 108 458 586 | 663 613 719 587 | 264 525 574 588 | 755 176 168 589 | 390 6 783 590 | 50 561 233 591 | 401 568 582 592 | 121 979 769 593 | 94 77 830 594 | 195 938 201 595 | 124 626 161 596 | 668 633 35 597 | 662 29 164 598 | 394 658 768 599 | 203 918 850 600 | 466 425 399 601 | 353 804 714 602 | 323 851 640 603 | 152 939 642 604 | 29 309 484 605 | 579 529 822 606 | 608 262 731 607 | 38 756 450 608 | 433 828 740 609 | 431 895 693 610 | 392 477 399 611 | 25 925 513 612 | 368 969 491 613 | 671 736 911 614 | 307 198 660 615 | 662 859 311 616 | 853 596 526 617 | 917 24 461 618 | 677 574 960 619 | 697 220 90 620 | 203 458 102 621 | 499 284 29 622 | 400 79 582 623 | 484 195 597 624 | 575 276 912 625 | 493 269 347 626 | 23 593 223 627 | 476 802 358 628 | 33 944 255 629 | 715 117 460 630 | 739 885 586 631 | 748 954 527 632 | 734 773 643 633 | 542 202 117 634 | 15 976 460 635 | 309 830 331 636 | 319 208 557 637 | 458 822 461 638 | 545 784 690 639 | 878 372 858 640 | 57 295 470 641 | 268 537 822 642 | 271 301 699 643 | 806 909 878 644 | 744 182 571 645 | 106 895 468 646 | 121 778 28 647 | 641 202 593 648 | 710 724 592 649 | 125 784 603 650 | 654 771 83 651 | 721 87 543 652 | 585 724 89 653 | 381 739 524 654 | 623 28 494 655 | 869 729 292 656 | 228 736 298 657 | 803 10 95 658 | 700 224 786 659 | 738 512 9 660 | 708 407 775 661 | 558 645 863 662 | 45 209 466 663 | 540 809 587 664 | 372 512 717 665 | 416 203 974 666 | 272 496 928 667 | 816 141 903 668 | 675 894 84 669 | 567 900 957 670 | 827 122 189 671 | 882 860 56 672 | 98 792 196 673 | 861 461 209 674 | 685 339 87 675 | 585 464 235 676 | 640 156 703 677 | 817 596 321 678 | 893 462 996 679 | 679 536 208 680 | 199 455 365 681 | 873 260 492 682 | 528 179 563 683 | 689 563 849 684 | 887 417 507 685 | 64 270 198 686 | 595 214 166 687 | 566 232 242 688 | 921 102 212 689 | 187 202 335 690 | 992 169 475 691 | 736 754 200 692 | 655 374 127 693 | 84 492 193 694 | 21 709 972 695 | 199 208 236 696 | 216 683 926 697 | 479 669 604 698 | 437 872 293 699 | 789 256 515 700 | 341 948 637 701 | 142 933 536 702 | 207 82 218 703 | 702 249 779 704 | 253 369 874 705 | 508 255 254 706 | 91 536 541 707 | 212 813 28 708 | 144 406 563 709 | 180 513 277 710 | 421 842 639 711 | 570 520 522 712 | 224 830 592 713 | 153 582 606 714 | 81 415 239 715 | 160 553 735 716 | 525 348 778 717 | 454 352 626 718 | 609 460 169 719 | 559 57 334 720 | 784 428 242 721 | 706 867 289 722 | 637 914 281 723 | 620 407 83 724 | 152 446 90 725 | 260 331 799 726 | 301 677 725 727 | 708 254 328 728 | 418 147 798 729 | 732 344 963 730 | 627 626 302 731 | 670 241 76 732 | 220 383 376 733 | 733 124 50 734 | 795 673 466 735 | 136 637 423 736 | 823 258 700 737 | 204 936 878 738 | 730 976 981 739 | 272 310 894 740 | 333 201 863 741 | 90 122 621 742 | 90 811 209 743 | 275 904 283 744 | 193 125 189 745 | 127 961 283 746 | 347 529 829 747 | 352 738 734 748 | 878 726 411 749 | 942 54 34 750 | 429 750 426 751 | 367 938 424 752 | 501 447 757 753 | 566 773 648 754 | 382 140 899 755 | 462 353 90 756 | 230 493 945 757 | 425 290 415 758 | 894 360 21 759 | 897 529 431 760 | 914 124 338 761 | 78 766 876 762 | 858 664 764 763 | 598 664 317 764 | 630 548 772 765 | 30 483 604 766 | 642 331 545 767 | 518 702 474 768 | 546 750 887 769 | 252 663 547 770 | 813 917 671 771 | 852 367 894 772 | 97 192 265 773 | 661 587 858 774 | 726 674 748 775 | 578 178 878 776 | 327 535 608 777 | 426 419 871 778 | 559 837 229 779 | 851 721 708 780 | 860 978 770 781 | 308 604 626 782 | 198 168 408 783 | 138 628 799 784 | 669 525 918 785 | 804 762 652 786 | 389 429 554 787 | 618 566 360 788 | 814 648 887 789 | 677 697 659 790 | 600 660 162 791 | 256 749 195 792 | 840 734 216 793 | 445 192 960 794 | 341 226 975 795 | 699 140 114 796 | 763 833 533 797 | 234 835 38 798 | 798 10 569 799 | 190 745 418 800 | 183 563 486 801 | 295 224 197 802 | 437 724 885 803 | 197 706 328 804 | 268 709 702 805 | 351 679 694 806 | 642 555 769 807 | 333 521 883 808 | 182 532 772 809 | 517 543 711 810 | 657 154 169 811 | 134 888 300 812 | 217 121 209 813 | 346 796 100 814 | 755 681 817 815 | 277 733 980 816 | 677 162 481 817 | 527 191 433 818 | 293 999 653 819 | 429 850 503 820 | 562 205 402 821 | 217 323 414 822 | 565 402 43 823 | 730 223 537 824 | 4 701 567 825 | 737 570 523 826 | 644 510 459 827 | 390 252 367 828 | 344 715 179 829 | 62 236 586 830 | 527 310 137 831 | 526 96 548 832 | 585 357 407 833 | 768 532 384 834 | 591 421 43 835 | 928 129 533 836 | 228 469 848 837 | 886 349 596 838 | 392 231 867 839 | 507 664 870 840 | 546 881 121 841 | 28 306 275 842 | 688 284 261 843 | 683 495 31 844 | 733 191 899 845 | 83 785 730 846 | 738 668 220 847 | 795 69 237 848 | 148 175 238 849 | 872 139 100 850 | 673 671 744 851 | 222 421 346 852 | 824 971 589 853 | 283 135 474 854 | 626 48 487 855 | 426 172 548 856 | 796 463 616 857 | 547 349 568 858 | 717 798 428 859 | 248 977 192 860 | 337 683 128 861 | 480 487 231 862 | 817 559 882 863 | 413 935 879 864 | 694 724 447 865 | 221 458 449 866 | 649 523 725 867 | 689 131 311 868 | 726 707 273 869 | 712 689 127 870 | 65 338 183 871 | 612 523 679 872 | 631 834 297 873 | 701 320 433 874 | 265 518 602 875 | 691 519 160 876 | 463 4 575 877 | 777 590 394 878 | 790 975 201 879 | 22 449 242 880 | 578 308 911 881 | 371 157 191 882 | 489 263 789 883 | 962 696 390 884 | 494 760 494 885 | 760 656 350 886 | 57 322 551 887 | 639 105 616 888 | 676 402 236 889 | 269 464 893 890 | 265 573 312 891 | 472 822 682 892 | 410 385 584 893 | 882 56 493 894 | 596 330 827 895 | 184 494 873 896 | 61 580 793 897 | 157 260 128 898 | 440 239 390 899 | 701 174 230 900 | 946 357 394 901 | 273 423 258 902 | 529 438 733 903 | 552 75 892 904 | 946 755 996 905 | 64 836 112 906 | 971 192 928 907 | 188 378 692 908 | 179 299 676 909 | 91 177 202 910 | 748 644 634 911 | 551 355 345 912 | 265 504 410 913 | 644 58 450 914 | 103 716 556 915 | 691 679 128 916 | 166 255 174 917 | 415 682 368 918 | 474 862 434 919 | 348 462 133 920 | 704 626 374 921 | 979 835 426 922 | 239 897 288 923 | 381 953 234 924 | 181 65 504 925 | 61 803 297 926 | 761 22 946 927 | 771 822 908 928 | 900 914 563 929 | 656 948 114 930 | 349 202 594 931 | 322 294 811 932 | 535 484 837 933 | 532 438 869 934 | 700 94 814 935 | 691 557 159 936 | 201 512 738 937 | 598 652 742 938 | 269 642 772 939 | 698 23 49 940 | 376 375 689 941 | 375 476 819 942 | 426 421 559 943 | 683 775 420 944 | 876 374 995 945 | 281 556 587 946 | 990 137 273 947 | 782 928 299 948 | 895 829 65 949 | 228 687 764 950 | 62 496 905 951 | 210 277 352 952 | 732 461 535 953 | 418 364 561 954 | 958 373 189 955 | 640 617 27 956 | 185 680 698 957 | 697 507 688 958 | 324 836 143 959 | 434 868 658 960 | 342 516 628 961 | 351 760 280 962 | 796 663 876 963 | 977 133 813 964 | 169 326 101 965 | 139 575 796 966 | 236 597 851 967 | 191 704 375 968 | 568 733 436 969 | 615 68 728 970 | 478 768 617 971 | 531 594 596 972 | 898 898 64 973 | 596 181 707 974 | 371 381 259 975 | 609 406 528 976 | 810 271 308 977 | 211 975 596 978 | 963 896 551 979 | 94 362 418 980 | 812 351 848 981 | 732 495 708 982 | 866 246 209 983 | 973 682 792 984 | 898 535 672 985 | 667 237 783 986 | 325 642 229 987 | 419 654 754 988 | 328 374 7 989 | 359 468 93 990 | 91 453 93 991 | 923 741 53 992 | 721 938 589 993 | 235 716 605 994 | 466 387 199 995 | 554 430 681 996 | 166 181 864 997 | 699 998 953 998 | 999 962 718 999 | 330 124 822 1000 | 443 536 930 1001 | 293 631 674 1002 | 197 574 315 1003 | 407 183 293 1004 | 432 417 537 1005 | 31 571 657 1006 | 901 555 463 1007 | 686 456 465 1008 | 217 259 3 1009 | 742 535 427 1010 | 881 347 555 1011 | 769 659 299 1012 | 134 577 20 1013 | 252 566 877 1014 | 181 10 885 1015 | 191 829 994 1016 | 744 649 867 1017 | 910 354 781 1018 | 68 767 930 1019 | 88 716 850 1020 | 22 290 121 1021 | 226 212 666 1022 | 266 327 812 1023 | 356 112 148 1024 | 252 397 741 1025 | 325 674 834 1026 | 389 442 946 1027 | 898 83 618 1028 | 51 807 862 1029 | 844 772 461 1030 | 831 546 467 1031 | 644 476 539 1032 | 758 758 722 1033 | 346 512 463 1034 | 157 427 697 1035 | 439 672 243 1036 | 192 869 150 1037 | 890 977 753 1038 | 962 767 607 1039 | 818 926 500 1040 | 960 927 219 1041 | 377 9 389 1042 | 661 191 869 1043 | 695 149 368 1044 | 358 342 778 1045 | 474 396 202 1046 | 546 585 853 1047 | 74 281 734 1048 | 830 295 611 1049 | 19 813 388 1050 | 847 963 378 1051 | 78 140 278 1052 | 531 580 246 1053 | 550 546 415 1054 | 739 419 197 1055 | 803 266 247 1056 | 285 672 123 1057 | 669 51 665 1058 | 525 662 5 1059 | 998 619 667 1060 | 737 368 910 1061 | 533 550 245 1062 | 899 667 932 1063 | 80 302 566 1064 | 508 1 576 1065 | 454 303 15 1066 | 752 463 159 1067 | 119 380 906 1068 | 702 279 942 1069 | 234 198 326 1070 | 262 207 305 1071 | 214 388 64 1072 | 975 779 523 1073 | 975 243 519 1074 | 694 895 79 1075 | 750 477 112 1076 | 746 470 108 1077 | 201 299 119 1078 | 748 890 652 1079 | 808 897 387 1080 | 908 617 466 1081 | 739 750 302 1082 | 887 765 558 1083 | 464 97 662 1084 | 11 745 109 1085 | 454 537 27 1086 | 446 363 118 1087 | 265 33 670 1088 | 862 497 147 1089 | 681 488 582 1090 | 370 131 389 1091 | 645 652 560 1092 | 496 548 779 1093 | 910 434 642 1094 | 793 105 303 1095 | 232 468 916 1096 | 932 5 657 1097 | 782 634 626 1098 | 429 642 326 1099 | 946 618 408 1100 | 760 711 553 1101 | 561 391 385 1102 | 614 834 961 1103 | 585 853 375 1104 | 188 562 635 1105 | 775 758 496 1106 | 300 128 476 1107 | 747 817 333 1108 | 288 608 259 1109 | 410 883 700 1110 | 142 691 562 1111 | 222 270 870 1112 | 654 341 896 1113 | 548 133 474 1114 | 49 712 796 1115 | 486 607 561 1116 | 483 920 970 1117 | 510 553 658 1118 | 876 682 369 1119 | 654 744 670 1120 | 508 888 671 1121 | 648 111 694 1122 | 213 954 529 1123 | 548 879 258 1124 | 342 15 155 1125 | 265 880 313 1126 | 613 36 583 1127 | 285 774 605 1128 | 696 776 742 1129 | 772 230 561 1130 | 239 304 710 1131 | 602 387 940 1132 | 871 107 512 1133 | 182 321 376 1134 | 927 392 527 1135 | 677 124 195 1136 | 312 270 938 1137 | 755 308 986 1138 | 400 779 601 1139 | 876 843 690 1140 | 964 719 119 1141 | 925 665 237 1142 | 730 719 310 1143 | 352 86 123 1144 | 583 801 629 1145 | 697 340 198 1146 | 150 635 446 1147 | 905 183 133 1148 | 648 654 298 1149 | 445 743 383 1150 | 483 628 344 1151 | 460 822 64 1152 | 264 872 384 1153 | 496 291 691 1154 | 130 742 608 1155 | 491 590 986 1156 | 737 317 602 1157 | 442 179 684 1158 | 617 256 642 1159 | 711 688 915 1160 | 679 804 29 1161 | 127 869 890 1162 | 621 677 347 1163 | 306 486 533 1164 | 645 198 481 1165 | 706 855 997 1166 | 686 743 117 1167 | 152 947 939 1168 | 271 251 352 1169 | 324 621 83 1170 | 562 745 349 1171 | 901 797 273 1172 | 7 84 696 1173 | 895 857 751 1174 | 692 663 805 1175 | 692 489 122 1176 | 876 848 930 1177 | 667 851 155 1178 | 226 218 502 1179 | 447 876 635 1180 | 395 40 430 1181 | 652 999 312 1182 | 362 992 135 1183 | 714 360 668 1184 | 603 393 858 1185 | 176 36 470 1186 | 956 803 884 1187 | 678 829 391 1188 | 340 128 810 1189 | 643 777 545 1190 | 71 314 335 1191 | 705 667 881 1192 | 119 708 664 1193 | 480 524 560 1194 | 432 183 165 1195 | 983 946 881 1196 | 788 472 442 1197 | 386 767 510 1198 | 864 823 566 1199 | 764 684 955 1200 | 155 309 725 1201 | 459 300 826 1202 | 627 85 796 1203 | 497 376 448 1204 | 827 969 784 1205 | 408 875 120 1206 | 764 883 698 1207 | 81 590 675 1208 | 128 549 653 1209 | 127 606 712 1210 | 668 989 706 1211 | 776 440 615 1212 | 121 840 169 1213 | 641 648 803 1214 | 224 671 825 1215 | 733 419 107 1216 | 86 208 359 1217 | 383 809 426 1218 | 322 741 122 1219 | 772 75 577 1220 | 844 100 782 1221 | 128 139 344 1222 | 702 420 230 1223 | 311 488 724 1224 | 633 209 661 1225 | 33 564 249 1226 | 459 120 886 1227 | 493 473 761 1228 | 252 719 939 1229 | 506 628 748 1230 | 673 843 501 1231 | 124 54 798 1232 | 421 761 726 1233 | 521 732 70 1234 | 395 438 839 1235 | 600 434 851 1236 | 464 374 29 1237 | 598 900 349 1238 | 817 637 266 1239 | 558 625 311 1240 | 503 806 254 1241 | 527 415 447 1242 | 131 972 675 1243 | 816 36 481 1244 | 870 880 637 1245 | 215 908 266 1246 | 973 18 622 1247 | 973 940 514 1248 | 463 923 875 1249 | 472 982 282 1250 | 868 808 269 1251 | 544 272 456 1252 | 961 836 90 1253 | 130 888 215 1254 | 974 276 275 1255 | 309 233 253 1256 | 973 46 438 1257 | 842 277 438 1258 | 366 80 179 1259 | 419 901 846 1260 | 82 907 966 1261 | 596 354 513 1262 | 381 362 490 1263 | 846 11 884 1264 | 22 718 970 1265 | 396 766 862 1266 | 397 62 598 1267 | 222 158 646 1268 | 814 712 225 1269 | 732 629 623 1270 | 809 626 692 1271 | 979 632 811 1272 | 503 139 372 1273 | 462 517 811 1274 | 256 899 609 1275 | 216 570 483 1276 | 902 733 385 1277 | 89 928 4 1278 | 887 695 386 1279 | 35 568 155 1280 | 781 58 203 1281 | 775 604 291 1282 | 367 692 689 1283 | 101 158 677 1284 | 336 580 368 1285 | 981 337 174 1286 | 900 880 593 1287 | 275 613 463 1288 | 311 907 363 1289 | 368 83 832 1290 | 64 974 980 1291 | 157 562 421 1292 | 12 820 590 1293 | 160 464 322 1294 | 245 444 382 1295 | 9 312 134 1296 | 257 306 288 1297 | 237 449 297 1298 | 142 600 661 1299 | 320 363 821 1300 | 721 84 89 1301 | 589 509 116 1302 | 413 594 181 1303 | 890 477 712 1304 | 742 65 245 1305 | 229 432 917 1306 | 536 189 821 1307 | 732 401 407 1308 | 515 210 512 1309 | 733 778 2 1310 | 852 451 210 1311 | 130 360 208 1312 | 230 408 748 1313 | 667 499 94 1314 | 467 112 789 1315 | 649 764 715 1316 | 253 908 53 1317 | 775 878 673 1318 | 265 5 24 1319 | 717 434 72 1320 | 687 428 72 1321 | 268 436 903 1322 | 678 450 742 1323 | 636 40 792 1324 | 555 104 649 1325 | 538 608 340 1326 | 370 525 847 1327 | 555 830 585 1328 | 763 92 375 1329 | 754 898 314 1330 | 153 560 139 1331 | 224 663 666 1332 | 138 344 595 1333 | 278 448 532 1334 | 413 492 470 1335 | 432 98 335 1336 | 148 795 903 1337 | 729 903 101 1338 | 818 186 960 1339 | 853 631 290 1340 | 761 170 666 1341 | 171 582 732 1342 | 189 731 633 1343 | 779 20 287 1344 | 883 726 449 1345 | 701 139 747 1346 | 571 29 567 1347 | 918 166 232 1348 | 98 356 853 1349 | 815 512 449 1350 | 911 504 671 1351 | 728 414 257 1352 | 515 517 657 1353 | 590 854 517 1354 | 388 526 831 1355 | 646 217 989 1356 | 845 355 289 1357 | 573 306 156 1358 | 563 11 456 1359 | 107 320 601 1360 | 37 287 714 1361 | 167 290 958 1362 | 198 37 287 1363 | 896 491 695 1364 | 712 282 239 1365 | 223 252 604 1366 | 524 955 584 1367 | 883 890 665 1368 | 818 817 242 1369 | 518 236 632 1370 | 410 222 191 1371 | 310 135 666 1372 | 983 634 348 1373 | 671 476 306 1374 | 986 665 111 1375 | 109 220 399 1376 | 717 738 695 1377 | 764 825 534 1378 | 616 315 977 1379 | 628 142 873 1380 | 19 287 155 1381 | 967 255 868 1382 | 191 80 844 1383 | 986 220 988 1384 | 419 521 444 1385 | 454 916 489 1386 | 71 859 500 1387 | 897 459 731 1388 | 823 791 216 1389 | 351 677 556 1390 | 840 208 612 1391 | 983 156 22 1392 | 988 318 633 1393 | 472 628 495 1394 | 341 608 343 1395 | 771 779 528 1396 | 818 149 422 1397 | 598 52 436 1398 | 678 130 285 1399 | 455 502 177 1400 | 461 245 81 1401 | 466 382 258 1402 | 181 661 64 1403 | 808 499 22 1404 | 892 243 76 1405 | 341 643 531 1406 | 717 328 856 1407 | 811 779 683 1408 | 666 220 797 1409 | 613 453 417 1410 | 978 632 462 1411 | 457 620 387 1412 | 558 681 351 1413 | 105 337 432 1414 | 880 55 818 1415 | 438 63 136 1416 | 709 100 700 1417 | 229 792 280 1418 | 427 985 53 1419 | 442 385 325 1420 | 918 328 642 1421 | 754 291 642 1422 | 970 74 973 1423 | 296 55 952 1424 | 577 458 924 1425 | 645 507 523 1426 | 589 149 6 1427 | 491 933 297 1428 | 871 822 303 1429 | 436 938 577 1430 | 98 762 322 1431 | 368 875 708 1432 | 607 636 385 1433 | 488 362 722 1434 | 642 379 510 1435 | 271 30 954 1436 | 338 296 210 1437 | 125 279 887 1438 | 614 178 645 1439 | 268 237 471 1440 | 578 60 720 1441 | 776 691 995 1442 | 814 565 784 1443 | 58 358 474 1444 | 968 573 398 1445 | 358 613 323 1446 | 851 694 665 1447 | 109 4 181 1448 | 366 741 777 1449 | 447 747 870 1450 | 738 460 241 1451 | 905 694 448 1452 | 440 901 565 1453 | 293 278 940 1454 | 822 276 877 1455 | 746 2 338 1456 | 227 915 30 1457 | 604 733 486 1458 | 501 359 493 1459 | 536 79 751 1460 | 621 623 135 1461 | 524 547 812 1462 | 917 11 982 1463 | 505 55 826 1464 | 580 55 287 1465 | 228 805 345 1466 | 586 101 202 1467 | 624 829 465 1468 | 262 645 636 1469 | 942 775 496 1470 | 724 942 398 1471 | 803 499 16 1472 | 326 565 969 1473 | 751 977 964 1474 | 320 725 153 1475 | 258 772 689 1476 | 107 421 839 1477 | 402 399 578 1478 | 116 927 560 1479 | 508 685 100 1480 | 970 581 680 1481 | 119 98 451 1482 | 904 580 314 1483 | 207 186 373 1484 | 791 286 21 1485 | 917 199 388 1486 | 210 549 203 1487 | 212 270 266 1488 | 2 429 355 1489 | 297 647 659 1490 | 233 537 895 1491 | 142 284 332 1492 | 219 237 361 1493 | 246 247 401 1494 | 288 81 328 1495 | 360 346 279 1496 | 21 262 298 1497 | 343 211 50 1498 | 637 778 813 1499 | 820 240 32 1500 | 660 781 805 1501 | 638 470 759 1502 | 779 198 372 1503 | 158 392 433 1504 | 5 274 133 1505 | 189 346 169 1506 | 194 74 37 1507 | 13 767 447 1508 | 167 546 364 1509 | 176 618 336 1510 | 554 638 712 1511 | 615 663 776 1512 | 824 62 142 1513 | 582 320 499 1514 | 302 278 545 1515 | 751 296 71 1516 | 366 35 493 1517 | 196 657 381 1518 | 364 685 134 1519 | 888 756 128 1520 | 17 799 479 1521 | 872 685 363 1522 | 879 279 556 1523 | 665 164 40 1524 | 264 418 539 1525 | 627 575 589 1526 | 978 792 584 1527 | 662 693 9 1528 | 988 838 552 1529 | 870 299 11 1530 | 141 674 546 1531 | 460 912 693 1532 | 216 795 292 1533 | 531 699 441 1534 | 207 795 373 1535 | 719 461 831 1536 | 571 491 664 1537 | 142 282 59 1538 | 48 89 556 1539 | 147 278 506 1540 | 334 990 607 1541 | 483 42 370 1542 | 766 978 303 1543 | 343 336 215 1544 | 283 745 857 1545 | 306 587 642 1546 | 566 764 323 1547 | 372 267 609 1548 | 878 505 315 1549 | 282 877 342 1550 | 283 369 682 1551 | 4 823 926 1552 | 339 831 891 1553 | 521 33 942 1554 | 704 816 318 1555 | 416 621 503 1556 | 163 684 625 1557 | 514 141 646 1558 | 362 81 368 1559 | 134 819 425 1560 | 324 768 190 1561 | 985 309 356 1562 | 41 491 802 1563 | 997 793 905 1564 | 976 684 837 1565 | 368 954 863 1566 | 878 407 43 1567 | 216 662 557 1568 | 82 425 547 1569 | 286 486 43 1570 | 841 595 727 1571 | 809 169 417 1572 | 233 566 654 1573 | 547 419 783 1574 | 91 422 981 1575 | 628 1 945 1576 | 83 747 306 1577 | 399 806 592 1578 | 346 708 392 1579 | 813 865 624 1580 | 516 636 29 1581 | 592 753 610 1582 | 440 460 145 1583 | 457 457 114 1584 | 40 19 165 1585 | 494 659 248 1586 | 647 950 224 1587 | 810 965 241 1588 | 913 630 245 1589 | 919 652 409 1590 | 38 151 355 1591 | 430 239 96 1592 | 372 597 360 1593 | 711 494 370 1594 | 176 710 108 1595 | 130 230 503 1596 | 188 509 421 1597 | 850 394 702 1598 | 68 744 665 1599 | 919 923 873 1600 | -------------------------------------------------------------------------------- /input/5.txt: -------------------------------------------------------------------------------- 1 | ojvtpuvg 2 | -------------------------------------------------------------------------------- /input/6.txt: -------------------------------------------------------------------------------- 1 | vhrvabtc 2 | rzzdexux 3 | pixjplcd 4 | imtxrwpe 5 | jlowiwho 6 | iqrfoytc 7 | ulplfkix 8 | beracsou 9 | lnpbjpsd 10 | tjkoiwfm 11 | mbdwdtvc 12 | ijzmhthl 13 | afuxnmmo 14 | oalhgvyf 15 | cvnrvmmy 16 | phapcaaz 17 | qolkozza 18 | cslnokax 19 | cxmtylqr 20 | celecybh 21 | lhsefcli 22 | ncuttavx 23 | dwmgplhj 24 | dqclavvr 25 | jgxgitqy 26 | lkermczl 27 | pjaqasku 28 | nscotnwr 29 | lskrxypk 30 | rqufleiu 31 | dpebqpqm 32 | zrzqaknv 33 | ejtyokhl 34 | zezxsymz 35 | vprfwlmo 36 | qbzpmtvp 37 | ctrmxbgb 38 | vfuzasvt 39 | eksijxxj 40 | rmehmkmw 41 | qtyvhcgk 42 | rlzkcewq 43 | vhnnobqv 44 | fxpeanog 45 | anldlmad 46 | irzcakuk 47 | bqwlsnlm 48 | ajqajujz 49 | jdfncuag 50 | uogfnhhn 51 | kgovasxn 52 | ahnehmpt 53 | dupgxqzj 54 | ffvmbzcb 55 | hwwhqvuj 56 | ftbirfob 57 | sfpupoze 58 | dcqqagnh 59 | lqcfxgui 60 | slaqsusj 61 | zfnlsbod 62 | gkkgjgoe 63 | bhhwadtt 64 | lkcahmbn 65 | bygxiuuq 66 | yfziyvix 67 | tgxfibtw 68 | kkmtqoko 69 | dnpradkn 70 | whjuxqnf 71 | quxihhbp 72 | fvucbrjf 73 | seeczrga 74 | xxdtjtzm 75 | gibfcpip 76 | pebojxbf 77 | sqwjhqau 78 | zcyoibrj 79 | vvrdfjlu 80 | noiuyxer 81 | dqthjgoh 82 | tujhtems 83 | goqyxish 84 | icyzsfvv 85 | tidfdydu 86 | wmkqxvhg 87 | orojnwzl 88 | soffzhen 89 | kcfpfeig 90 | dutcqtwp 91 | nskossbo 92 | jdvatkfz 93 | lvamapuv 94 | olvjpcyz 95 | zkdaaszm 96 | xnutyfxf 97 | jqfrlpdb 98 | atjrmgbl 99 | srmrnnez 100 | tahfxtwy 101 | cgmbsgtt 102 | mjidtwrh 103 | ttaarqbz 104 | ecpeurzx 105 | bmperkew 106 | wrpkpzxy 107 | jxqukdgp 108 | padrejjf 109 | cykpjmti 110 | gawyzbwk 111 | ndwrqcnn 112 | qatvgyoo 113 | opptpjeb 114 | knfzqjsw 115 | jwqvgpfu 116 | ngvxvahq 117 | zcxpstzk 118 | scizdgxf 119 | rpijsqob 120 | fshiaxsc 121 | bkwyudab 122 | xndzhivu 123 | qabuelir 124 | xbbknsmi 125 | aymcyblg 126 | udoozwuy 127 | bxwhsfnq 128 | rxfuclda 129 | oviehgte 130 | iwgomjxf 131 | jxesodal 132 | tkkbgzvu 133 | cnbwowrp 134 | vsswuzxw 135 | qtgktieq 136 | nzgnvskg 137 | ealykgra 138 | feynkmtk 139 | lbkbojuq 140 | lawckzdr 141 | nserkqvj 142 | ppnnvegc 143 | qgifeoix 144 | xztbecrg 145 | tiylyrsn 146 | jfiramgc 147 | ugezzfle 148 | mhsbmxqz 149 | iaubkzne 150 | hozhztpo 151 | vujimqsj 152 | jycbwqmv 153 | zeiuejjb 154 | byuvzcyj 155 | ikhpmoqb 156 | ufjcsjgy 157 | cmcrbvst 158 | ayunldxp 159 | gipqzdno 160 | qmsdgeal 161 | sycayzfs 162 | mszlvokk 163 | xqwossfj 164 | jnqfghnm 165 | pluhjlnk 166 | czlzxzbm 167 | kyywqhju 168 | dajubdhf 169 | kehffmfy 170 | mybcatox 171 | zctxuwwk 172 | ybkxkawc 173 | zzwguxvv 174 | vlsswpcb 175 | vthsokmh 176 | zbwsbxws 177 | xstkrrwe 178 | hvsvgsgz 179 | qlqgzzmr 180 | hzuhclce 181 | yhfgpewt 182 | eboyknhs 183 | nqjvjcqf 184 | nschhfdp 185 | giupqixh 186 | dbzkbrsm 187 | ulhllnde 188 | fzhmfhrr 189 | uiparxqh 190 | dxnnpfra 191 | ludoygix 192 | doqggixp 193 | omvihuem 194 | anijqdak 195 | hovtlipy 196 | jvhulxyz 197 | azvkpvyc 198 | ozutdhjc 199 | sjaaziki 200 | hghouxnn 201 | tuudbkez 202 | cfbjttzq 203 | smtovjnc 204 | ucipmtlj 205 | gxmatiyy 206 | kipdggkw 207 | gpnweeun 208 | fyzkpqbk 209 | dctgbfih 210 | tuhfntly 211 | xoanamuk 212 | jlwxdjqp 213 | qzrnrjjz 214 | zffubqwg 215 | yujkbodi 216 | srgfxrag 217 | txvkzysv 218 | eedczuuz 219 | gosmfeex 220 | eesqfxhg 221 | bjldoflf 222 | vvcbcnex 223 | wriyojbf 224 | utdjpovq 225 | dxrbgdff 226 | ivwlxlfx 227 | uljthgnu 228 | asruzhqg 229 | qtxcvstv 230 | yfaylaqg 231 | wmnblvqo 232 | huscfikc 233 | eyqdkcvu 234 | njbdiyhc 235 | hvmeacpb 236 | ocxsnfca 237 | eybztcgg 238 | rkqvbcst 239 | umfkdhhp 240 | qepkcwqa 241 | xdnsscpw 242 | bsoaexkb 243 | kacsruck 244 | mwainqut 245 | pdoqwphw 246 | uvblhueb 247 | cwrbiibu 248 | opcbzfgv 249 | zzyqzgrq 250 | qfgcrmpm 251 | peujlgqi 252 | nrfglgja 253 | tfnfbtbi 254 | cyqyqrtb 255 | eqypdsvt 256 | ovdmqqvt 257 | hnukchfg 258 | bpfhlilo 259 | lkvwiusp 260 | zzhpkwbp 261 | gotqgblh 262 | mgcihbsc 263 | cvkatsjo 264 | nmtwcazc 265 | azenyubh 266 | ujtoqfwh 267 | qdwkjcaf 268 | hurclzab 269 | mrbbwxxa 270 | rtosiexf 271 | vjfyfzol 272 | kwzltbnp 273 | akjpxpnd 274 | rclhgeyv 275 | udsvnvkd 276 | trlzccds 277 | mdmcycpm 278 | yuqetosm 279 | yuyfnnbn 280 | jwylebau 281 | ybtynvca 282 | pzsbkdxs 283 | ipstuhyr 284 | rcnnyzrl 285 | ajgsynyt 286 | bzpifcnm 287 | ebhvzfpm 288 | laehwkbw 289 | fpinzejm 290 | hmevkjyz 291 | pijsuvoz 292 | kpnjusky 293 | imhxxryz 294 | bbykcphd 295 | eddgzrlt 296 | xofnilfp 297 | pdclvqub 298 | xvqviwku 299 | ahnximil 300 | zqmdysji 301 | sqoczvww 302 | xkmqsems 303 | qqraorxr 304 | dapbjpyi 305 | klospspq 306 | ugqocfpx 307 | ftjlpduh 308 | hpvzalgr 309 | lodrkkov 310 | xjtoerjr 311 | urfojzyy 312 | jmbwqsdp 313 | tybiwbro 314 | nqguwpsg 315 | wzjdbtvp 316 | uamnromw 317 | iiouocfq 318 | vbrifvdj 319 | zeylejin 320 | iueydkui 321 | ncyypjha 322 | oalcyjvc 323 | hjtigsai 324 | yqbuzvod 325 | hzjxaoxm 326 | ozdtjqrv 327 | umltuvsn 328 | cyfxwaut 329 | fpnrkktw 330 | bsrtevsi 331 | mwkpttud 332 | lnmxrvnz 333 | ohawlazx 334 | pgwxgzva 335 | wiqpvalw 336 | lckdpqpj 337 | fzfadbcn 338 | mivmracr 339 | xlezdrfw 340 | escxeztx 341 | dehufqkb 342 | ykaidzee 343 | kjxzlhxn 344 | wxearyjh 345 | fbtppgjb 346 | jatslhys 347 | mxiwwyoj 348 | wjxsoisz 349 | qvlainlc 350 | wrpwzzds 351 | ojylxjlk 352 | mnjgamga 353 | itdemmgx 354 | eppmhvav 355 | zudnruzi 356 | fqhjdhrx 357 | rgsjwufu 358 | cfmcdsnl 359 | qmyludch 360 | diczbwrc 361 | bptsolbs 362 | gregrfuk 363 | ggtdtdsr 364 | vekxaxzq 365 | iirnwtmj 366 | jwimmqtl 367 | ezrartxw 368 | mgzkopvx 369 | qtxhdjzl 370 | ueoefpys 371 | wryfgobw 372 | gibrxmfq 373 | kuozniuj 374 | ezctgdra 375 | fpxjfgww 376 | soeicyjv 377 | pookxsgw 378 | ctatvacc 379 | ymlpgowi 380 | aekhewub 381 | bogedhje 382 | aygzjewd 383 | bftmclcg 384 | twspjgiu 385 | xflvkyzm 386 | weeihqco 387 | bzqissdv 388 | knhseano 389 | powynbnq 390 | ylvewtrj 391 | jwidlbzx 392 | drienpvr 393 | rbndvvcn 394 | ynhpvfds 395 | sgvvoexs 396 | ynrsiahi 397 | yipvpmmm 398 | ixxdnogd 399 | ramwrfef 400 | ndlumxte 401 | tvkqfyeo 402 | llkyyijo 403 | gfcamayi 404 | fdbicttv 405 | giudovqr 406 | jduryykk 407 | ozsisrkr 408 | vymcyjnr 409 | fpoguwjh 410 | zzehbxvq 411 | bbzxtuco 412 | creeinoi 413 | pfgwqrcv 414 | ljypthio 415 | esyytrqx 416 | vilobaon 417 | yharsrty 418 | pcgygoak 419 | kdfzpikl 420 | olrosiss 421 | osivuyzn 422 | ovevojlo 423 | cwnxmqdo 424 | pfmjddkq 425 | znvujmtf 426 | vkalccja 427 | nvzhfpia 428 | hyujfngl 429 | ydefvfop 430 | kwiwltvo 431 | qjmowuox 432 | menbophm 433 | zmljxiea 434 | icighnas 435 | nssgwyle 436 | wpxpiyjz 437 | vxnupnmu 438 | bbqsjnas 439 | toveeodf 440 | ootrclyu 441 | jyklyedc 442 | rbktfwqd 443 | kbskmwua 444 | shnkkdta 445 | vxfkdxhh 446 | debrhmid 447 | itrzmodt 448 | ylaankij 449 | qcvlplpy 450 | xlwksxxk 451 | xdznurxi 452 | olwomzpf 453 | igqtqome 454 | xchlumws 455 | edcumpaz 456 | pwjmdors 457 | lhxozxei 458 | hufvylqn 459 | edfevfzc 460 | gigdwfgf 461 | xggpedlq 462 | mlghgbfa 463 | gjacxeph 464 | sxvheyge 465 | ckisqokq 466 | xndeieus 467 | gnxvdkwg 468 | ahqogfbx 469 | nxzgxhep 470 | xpsarftf 471 | zmgrmeqr 472 | bhalyhol 473 | ulejpxpy 474 | vhehrjzm 475 | wyqzpixv 476 | nkpjwbgq 477 | slwzvmua 478 | tubeisgw 479 | ojgqkxdv 480 | krjwyfcw 481 | mcittkjw 482 | sndxlapd 483 | xgdqjlcj 484 | rgozyuiz 485 | fprzkwln 486 | gwbgwqxm 487 | khwmbdkn 488 | rwnqxwvk 489 | agxbmadn 490 | hyqnrdhw 491 | dbomlwal 492 | fbvmeuwt 493 | qsfgenhl 494 | udrfskjk 495 | arajwwmn 496 | fghpeqbe 497 | bsjbfkdb 498 | gaixdesy 499 | ewchhofv 500 | trjuuipw 501 | eeumxzeh 502 | heqrqakk 503 | chjmlloy 504 | smxcvpfi 505 | vxwonanp 506 | piygrizh 507 | snxsnnfy 508 | txsifcfx 509 | rqitketb 510 | mcbljita 511 | mwmgeogt 512 | sgvmpaph 513 | prmpddbr 514 | rxevhtdm 515 | lyejgafv 516 | myveantx 517 | woyyuycb 518 | srovvzml 519 | vtudbulh 520 | xfouthsi 521 | kwgvwkzl 522 | mtwmvmxf 523 | ddtwlrzr 524 | gtzwowtm 525 | huzqtveo 526 | dcgmqyrn 527 | gtzzlhpe 528 | ruvncyfs 529 | lwsxibps 530 | waymjoru 531 | mmfdoxny 532 | rizwihlk 533 | cxaiotfr 534 | ypoqbnry 535 | anlquyqk 536 | bhhffkkp 537 | kkqhromq 538 | tqowsiao 539 | fqkzblsd 540 | toxdebej 541 | hozmnqou 542 | rcdonbwf 543 | usnojcyl 544 | ufmpsswg 545 | iefukrrp 546 | kuysztiv 547 | hnkytlvg 548 | nabjcyil 549 | tjtymamd 550 | zghngkdd 551 | mwbpuwmj 552 | jlpqmghg 553 | aslbbgqd 554 | dbutwlae 555 | oqdimirz 556 | npraupgz 557 | dakbvrfy 558 | yzrdqvag 559 | hrpaqgqj 560 | qakbxmpq 561 | utsimneu 562 | yjqtkmdz 563 | fqxlynyd 564 | wknsbcet 565 | kehwvrxu 566 | vxxrvhcd 567 | ctpfdlsc 568 | atjmqkye 569 | pkaaqbvv 570 | fnmyewwe 571 | dtlqqbjd 572 | wsfyghha 573 | nndsvqbi 574 | wbaltpka 575 | zjuhspig 576 | isrerule 577 | qugfdfjt 578 | efjenzge 579 | wadqbjcc 580 | tvlcndmn 581 | cbveiint 582 | kkujfulr 583 | wtnyfzoe 584 | lmzgpulq 585 | ihajkabg 586 | pqiahufq 587 | ravmkrdo 588 | ldmftjct 589 | rhgdweob 590 | ahjzgzkw 591 | vvgrueiq 592 | hiyxhnim 593 | gwynwuoc 594 | wonxvgee 595 | jxwtxmau 596 | rggtslej 597 | pbkwjyqf 598 | ykanbgrg 599 | xqcwldyk 600 | nmlqdjws 601 | yvpcihki 602 | vwljaurh 603 | wucszart 604 | sshxhwid 605 | lfxnrqmt 606 | jvvkxeht 607 | siobukus 608 | edchngzp 609 | mkmuhoyd 610 | hidqtpid 611 | wvocqxbp 612 | jvwqvvpt 613 | grxtjncl 614 | eyqiipyy 615 | yuxcubml 616 | fksvcuss 617 | apdkwcqd 618 | bokchryh 619 | ipbukstv 620 | ifsynwcy 621 | odcgknnc 622 | omcsclgb 623 | zhjrucwj 624 | zloeydhr 625 | -------------------------------------------------------------------------------- /input/8.txt: -------------------------------------------------------------------------------- 1 | rect 1x1 2 | rotate row y=0 by 6 3 | rect 1x1 4 | rotate row y=0 by 3 5 | rect 1x1 6 | rotate row y=0 by 5 7 | rect 1x1 8 | rotate row y=0 by 4 9 | rect 2x1 10 | rotate row y=0 by 5 11 | rect 2x1 12 | rotate row y=0 by 2 13 | rect 1x1 14 | rotate row y=0 by 5 15 | rect 4x1 16 | rotate row y=0 by 2 17 | rect 1x1 18 | rotate row y=0 by 3 19 | rect 1x1 20 | rotate row y=0 by 3 21 | rect 1x1 22 | rotate row y=0 by 2 23 | rect 1x1 24 | rotate row y=0 by 6 25 | rect 4x1 26 | rotate row y=0 by 4 27 | rotate column x=0 by 1 28 | rect 3x1 29 | rotate row y=0 by 6 30 | rotate column x=0 by 1 31 | rect 4x1 32 | rotate column x=10 by 1 33 | rotate row y=2 by 16 34 | rotate row y=0 by 8 35 | rotate column x=5 by 1 36 | rotate column x=0 by 1 37 | rect 7x1 38 | rotate column x=37 by 1 39 | rotate column x=21 by 2 40 | rotate column x=15 by 1 41 | rotate column x=11 by 2 42 | rotate row y=2 by 39 43 | rotate row y=0 by 36 44 | rotate column x=33 by 2 45 | rotate column x=32 by 1 46 | rotate column x=28 by 2 47 | rotate column x=27 by 1 48 | rotate column x=25 by 1 49 | rotate column x=22 by 1 50 | rotate column x=21 by 2 51 | rotate column x=20 by 3 52 | rotate column x=18 by 1 53 | rotate column x=15 by 2 54 | rotate column x=12 by 1 55 | rotate column x=10 by 1 56 | rotate column x=6 by 2 57 | rotate column x=5 by 1 58 | rotate column x=2 by 1 59 | rotate column x=0 by 1 60 | rect 35x1 61 | rotate column x=45 by 1 62 | rotate row y=1 by 28 63 | rotate column x=38 by 2 64 | rotate column x=33 by 1 65 | rotate column x=28 by 1 66 | rotate column x=23 by 1 67 | rotate column x=18 by 1 68 | rotate column x=13 by 2 69 | rotate column x=8 by 1 70 | rotate column x=3 by 1 71 | rotate row y=3 by 2 72 | rotate row y=2 by 2 73 | rotate row y=1 by 5 74 | rotate row y=0 by 1 75 | rect 1x5 76 | rotate column x=43 by 1 77 | rotate column x=31 by 1 78 | rotate row y=4 by 35 79 | rotate row y=3 by 20 80 | rotate row y=1 by 27 81 | rotate row y=0 by 20 82 | rotate column x=17 by 1 83 | rotate column x=15 by 1 84 | rotate column x=12 by 1 85 | rotate column x=11 by 2 86 | rotate column x=10 by 1 87 | rotate column x=8 by 1 88 | rotate column x=7 by 1 89 | rotate column x=5 by 1 90 | rotate column x=3 by 2 91 | rotate column x=2 by 1 92 | rotate column x=0 by 1 93 | rect 19x1 94 | rotate column x=20 by 3 95 | rotate column x=14 by 1 96 | rotate column x=9 by 1 97 | rotate row y=4 by 15 98 | rotate row y=3 by 13 99 | rotate row y=2 by 15 100 | rotate row y=1 by 18 101 | rotate row y=0 by 15 102 | rotate column x=13 by 1 103 | rotate column x=12 by 1 104 | rotate column x=11 by 3 105 | rotate column x=10 by 1 106 | rotate column x=8 by 1 107 | rotate column x=7 by 1 108 | rotate column x=6 by 1 109 | rotate column x=5 by 1 110 | rotate column x=3 by 2 111 | rotate column x=2 by 1 112 | rotate column x=1 by 1 113 | rotate column x=0 by 1 114 | rect 14x1 115 | rotate row y=3 by 47 116 | rotate column x=19 by 3 117 | rotate column x=9 by 3 118 | rotate column x=4 by 3 119 | rotate row y=5 by 5 120 | rotate row y=4 by 5 121 | rotate row y=3 by 8 122 | rotate row y=1 by 5 123 | rotate column x=3 by 2 124 | rotate column x=2 by 3 125 | rotate column x=1 by 2 126 | rotate column x=0 by 2 127 | rect 4x2 128 | rotate column x=35 by 5 129 | rotate column x=20 by 3 130 | rotate column x=10 by 5 131 | rotate column x=3 by 2 132 | rotate row y=5 by 20 133 | rotate row y=3 by 30 134 | rotate row y=2 by 45 135 | rotate row y=1 by 30 136 | rotate column x=48 by 5 137 | rotate column x=47 by 5 138 | rotate column x=46 by 3 139 | rotate column x=45 by 4 140 | rotate column x=43 by 5 141 | rotate column x=42 by 5 142 | rotate column x=41 by 5 143 | rotate column x=38 by 1 144 | rotate column x=37 by 5 145 | rotate column x=36 by 5 146 | rotate column x=35 by 1 147 | rotate column x=33 by 1 148 | rotate column x=32 by 5 149 | rotate column x=31 by 5 150 | rotate column x=28 by 5 151 | rotate column x=27 by 5 152 | rotate column x=26 by 5 153 | rotate column x=17 by 5 154 | rotate column x=16 by 5 155 | rotate column x=15 by 4 156 | rotate column x=13 by 1 157 | rotate column x=12 by 5 158 | rotate column x=11 by 5 159 | rotate column x=10 by 1 160 | rotate column x=8 by 1 161 | rotate column x=2 by 5 162 | rotate column x=1 by 5 163 | -------------------------------------------------------------------------------- /input/9.txt: -------------------------------------------------------------------------------- 1 | (27x3)ZFPNOWLAEAEMVDZHFYHXDUVOFWJ(6x3)SBKNUX(26x2)JEAITUGDSJCXZBKGKMKEQKTZCN(21x1)LYEAWHPDVHFAAZNAZJRFF(254x15)(77x8)(2x8)BK(13x13)JUMLYCIPCRDVB(4x14)LHFS(18x7)DYVAEHFFSFVXABCNPP(10x4)FWITZUOJMQ(58x13)(16x11)GWNBAWGAFWGNSBEL(5x3)NBNBP(7x9)WNTSXXO(1x9)X(2x8)UK(47x2)(3x9)RYP(25x8)IRIVPFDRIDXEACDDXHESJFJSW(3x6)VIZ(32x15)(11x1)MBLCVOGPHAB(9x11)MCLTFSDPO(9x8)TQJCJWPUX(87x11)(53x4)(3x4)IGQ(9x11)ZMQZMVAZW(5x9)AEKYP(7x10)DRULUQK(1x13)F(22x4)TEDTYLHOAIZWKTXAXOABQB(223x9)(20x11)WQXDKEOXTKIHPSNZVQLL(39x8)(9x6)POXRCHKWS(12x3)GFNJEWYVMJZS(1x14)H(60x6)(3x9)OVM(9x1)XUKFYIZOV(4x6)YFRY(3x14)ZEA(14x6)WAYJMQCOGOLCGZ(28x2)(12x4)ONTVVSCSPUEV(4x11)RSZS(44x13)(22x10)GLTNHFLPRIBLUASCEJDMTD(9x15)LDLBOQHCI(5277x5)(2195x11)(247x12)(3x2)LRN(231x12)(224x3)(95x15)(55x13)LVECVMMGEDAWVZJQLLCTPOEPVVRZTWQBQJFLOZCKMRBBXHPXLWMRQPB(3x12)ECW(8x7)HVTJDIJQ(6x6)TNQGGB(11x14)(5x12)TFYAW(23x2)(4x7)HAHC(9x9)JDGEEOECL(6x5)IOAHRC(58x5)(5x12)WXXEX(1x9)N(10x11)TIYYUPOXXM(7x7)YHNFHBI(6x10)XDVZRK(1070x5)(172x13)(108x6)(4x8)WUFS(3x11)SFP(33x12)(2x6)OK(20x4)MGJRZAIPLVIDZUWHOCWQ(24x5)(8x3)ZAEAMDII(6x5)IFZZKB(14x4)(9x5)PZJVKBTSK(31x2)(25x4)(10x12)HGLQWJZIKI(3x7)LGC(13x15)CHMSXVIQWDLWJ(514x4)(201x10)(56x11)(6x3)CJIXKA(2x13)AY(4x6)ULPY(21x15)JCHZGIATGEPOSHVWTZONZ(54x12)(4x12)NIHH(38x9)NUNHDZWCUFYPKAAGXNPRRYQNLSFFUJXPEYVSSL(9x9)IICLETSDO(57x4)(8x7)NXEBWFRZ(14x9)WHHKMUSEXISVYQ(6x10)JNHJVN(6x13)SDNSWT(107x14)(11x3)(5x12)JASOZ(32x13)CVOFYBURCMJSSQWQAQTSRDUVAHAUNTBK(45x6)RWTYKPISUMHAIWRYSCQVKGUHJJUKYEENWCBZFVLQKQHDV(47x10)(19x10)(12x11)RYNNMPJYQBGI(5x2)IFLEY(6x6)WOLYOC(118x8)(11x13)UVMVEDKAELE(93x14)(37x4)RRYWHHQMCDTJCMQYONQBIPXYRDSTAJGKEDFTU(4x15)ARAM(2x11)VZ(18x15)DWPLVWIECVEWIBMBCS(1x14)C(6x7)AWFIIG(194x9)(144x1)(18x15)(12x8)HMBRLEEAHJSS(11x15)LHZIMXZFYMV(7x15)HKMWTJD(12x10)LMINNHKFEFDE(62x10)EGVFTHXWVTNZTUKKLEVTPDLYJNHXFTLGDLJJAANTKCCIFAPHYIQGIDCTRRAVTM(2x5)YR(10x8)(5x7)MUXQD(14x3)SFKCACRZALUGKL(7x6)(2x9)DE(148x13)(48x7)(11x9)(6x4)YYQLQD(3x11)RKQ(16x8)(2x7)MS(3x11)GJY(29x15)(22x10)(9x9)FSOJATSNV(3x8)HMV(51x11)(8x7)BNNMBHDS(32x3)ZTIGRCHVSGEUTUUZKXBLBSMOCXVTPDEV(572x13)(6x4)YINUUC(7x10)(1x11)O(541x9)(165x5)(71x4)(20x10)CFCCFOBMWMROEVACPVSG(19x2)YRQZDODFUCJRUVSZHAK(4x8)VENF(5x6)UHOYP(70x9)(18x8)CCBZKJKTXVSJCBVHVB(14x6)RZWHOCEGCHBEXD(4x1)KLFR(11x4)ZFPLKUXMMGK(7x3)QUQPYAY(218x11)(66x8)(5x9)OIQLP(3x12)BWF(6x9)IXBKPW(1x7)Z(24x5)XVWHHLXYEJPIGGKEGTXMVCAZ(2x1)RY(42x7)(23x12)UZRCRLQDQTPENKQXTNULCJI(7x5)DABGRHN(32x11)CBSSWDNKZYEKQESOVTYQNRNSLBACJZCY(45x13)(39x1)EHFNDIULZXKEVAKONKBRZFZOUDUFCVKLSJIYWYA(4x8)IDKX(127x9)(47x4)(11x9)GPEHUAOQWBB(7x4)PATPNZD(4x12)ECZO(3x2)LIH(19x14)QIYZKUNNXQOPVCJLPXE(35x4)(3x9)BWT(21x7)VWELQYZHGGIWUGQRVXIXQ(2x8)VY(275x3)(267x12)(87x5)(59x4)(2x11)DC(6x10)NPIFMV(22x10)EORCVUQYOZMXGSLNXXGOQO(4x10)JSSJ(16x5)ACPKJDHXLDSZDUHB(9x11)(3x12)WQW(151x10)(60x14)(9x10)RNSEQJTFW(5x3)KBVOW(29x5)KMLPKNMTAEEYFMTPUTSNJFDGHAOEV(78x1)(31x8)OWPDMEMJVHFBWVJAPCYDGNHOCAVYCMC(15x2)MBLVECVFEBVZSTA(13x13)EEUQTMYCULLSD(436x15)(11x3)FYXIDULGLJR(202x13)(14x13)LXYUYXUOESDYJI(66x10)(59x10)(14x5)(8x15)UCNRLHPS(16x8)(10x4)COMHYGKDBA(11x6)GQUXKAFUBNF(101x2)(95x3)(78x6)(6x9)NDRYYR(1x9)B(4x12)DAAR(18x14)QDXXJBXSKXZZTWGQWX(19x14)GHJLDUVWEWPERCHKXWH(5x15)UXYSR(2x8)ZX(7x10)BEGSFII(181x10)(173x14)(165x15)(88x8)(2x15)LC(6x15)YQSJLU(1x7)R(47x6)STNWZGRULRFBJPOAQMDYBGNTOEROREPLSJXGXMAKWLOEJTK(3x12)ACA(18x9)(5x9)CKMTS(3x8)JXD(4x4)NKBX(24x10)JCHKOHVMKKKOHBTZMZIUKBXZ(2x7)UR(65x5)(59x6)(2x12)ZF(45x2)(39x3)(18x15)LQPWJXVEYTUVVKAFIG(9x2)QESNAGCLP(2129x4)(18x7)(12x2)TYEUPBDNLQMO(15x4)LQZIUPRYOXCLLKS(844x12)(105x5)(21x2)(14x11)XGVMJYQLDGUFFG(72x3)(37x1)(8x8)QUSDYNWE(1x3)V(12x3)YTYEZDLLBBLW(23x5)(2x2)KR(10x1)LNIEFSQFCV(185x3)(127x9)(97x14)(32x12)CEQKIWQSFKGBFSNIYJNTKZJGHGOBAJFO(8x1)YIDIGWHS(4x12)DJNL(21x2)MWNSGVGIPNRFFXQVGZZXN(2x14)RC(16x14)EQZODROVWENVROPH(10x15)IYSZVVICFF(27x15)(3x9)NAU(1x11)E(7x2)UOAHTOE(3x7)EVE(344x5)(41x5)(1x7)D(1x9)G(6x15)MTIDXB(11x7)JDQXCWJOSPL(124x10)(10x5)OCYKHUOLGR(75x6)(15x2)XQJTWBRSINDHBOG(11x6)FSKHGXPGVER(1x3)Z(24x14)RJEYSCHURRHQAUTTJGLUOVPL(21x9)WTWWNNSYCJWJSVOCUQDZZ(81x11)(1x10)J(11x3)(6x2)XJTCOQ(28x6)(4x4)DMNT(13x6)NXGJVYHTGBTJD(16x10)(10x1)OCQCWVYGWA(71x3)(64x14)(1x1)D(17x7)ZLBJRQMHOQZZUABHF(4x5)ZIJC(7x7)SSFJUSB(9x7)OWJWNWGYR(173x11)(10x13)XKARUGLQTV(63x11)(27x11)(5x15)YIJGY(10x7)LPGDSVEUUT(23x5)(17x2)MRDIJSDEIQLTIIWGI(79x12)(66x2)(19x12)VJIHLLVBJCLCWVUOHAZ(3x13)AWM(3x3)HEO(5x11)USXNK(7x9)VOJWMRU(1x13)K(399x9)(392x4)(191x5)(9x15)BPQRYTJJM(13x7)RUAVPVMGYXFWR(14x9)(8x15)XKODKNVW(54x6)(20x10)KGDOCRDHKSTFOMGJJDTW(20x15)ROCYEMUHNVHDCRGASNQW(71x7)(4x15)GYNN(4x13)VECH(22x2)MPZNOTXREKIJOOWRLPKKLU(7x8)JERZVVF(5x10)LHVFW(1x9)S(16x9)(10x2)FVQWLMRLPX(7x8)(2x8)WK(147x6)(18x2)SFUYDWAPKXBOUUTMSA(116x2)(25x1)VAWLILYMEGUNRPLZHYQEVCQMX(11x4)KXGUPUQNJYK(28x14)UDXFMEOJJYWPFPTOZNJSDRWPZFBZ(4x10)XEHN(17x5)ZHRQBIYYWWCHRCUHI(818x13)(209x13)(77x15)(12x4)BXQQLTHYDSAO(1x12)N(46x7)(4x5)SFZM(2x3)YQ(15x5)EFCMPJRJFXDYYTM(3x11)CCJ(2x10)YT(2x13)QQ(14x6)EVRRLOMOFNXGOZ(83x1)(29x14)(23x8)YOFCXJZACKTRRWVNPVIXZTP(40x13)(10x12)ONOAEXURXZ(16x12)NPHGPHXPIDWGJSIX(594x2)(127x7)(92x1)(4x2)LJPF(36x3)OSHCFVBGDCAXNARFWKLNTINZCVXPNWGOXKDF(13x5)ZPWKVFAMJZBMY(6x14)CAYZSQ(4x15)EBXB(22x12)(15x14)FMRMGNAJARFULBS(171x2)(1x3)U(67x2)(11x12)JICSMQXTSEX(16x4)REWSYOOICWKNSKER(20x14)IOHUIDFGMTWCHLBAOOIV(34x9)(1x9)N(2x12)HU(14x8)QWOWZACTRWVRDB(20x4)(5x4)IRLFA(5x2)FLYHX(20x7)(14x7)ANUYZTGIKGGUVO(134x6)(52x3)(9x11)GMRLDBENK(7x5)CAXVMLP(12x11)RKHQBZQQGZOQ(1x3)L(3x8)DHP(51x12)(34x13)GXNXQJTCCXRLGFOSCICHVROKNDRLMUWLJZ(5x9)GGHFT(5x1)OPZAO(114x13)(14x6)(8x11)MLDPANTH(11x9)JQMZNNGEWWQ(49x15)(4x13)QEPL(32x15)HTYDAQGNLURZGPLVUKEBLVTNQBBIKGPC(15x5)TTUXJQOBVOGWZWU(13x6)(7x11)(1x10)D(413x15)(77x2)(71x6)(4x12)MION(55x8)(21x1)(9x7)HUXICLGEA(2x3)OV(22x3)(3x8)CQE(9x8)BTABUERCO(322x11)(129x10)(122x4)(10x2)KZRRUUXXQI(65x1)(1x10)E(19x9)OMTEFUVUUKPURKKMGAW(13x7)BYMSGGZOTDEIO(8x13)EXBJWEXR(28x14)(22x9)VJAQZTRWNWWKYECHTESZYL(142x6)(135x2)(42x13)(5x11)GMMLJ(24x11)PPRMLWWZDEWPXLPGMRFXEBKT(79x12)(19x9)ZGKGNYAALKUQLRHQHVD(36x1)MIPYDVUODWGXQBCTZVXGZCEOCVORSZRJPKVY(6x10)RGYZFF(14x5)KQPBLOMGLGTWRP(10x4)WGXYVZRJLI(3372x11)(2352x10)(1123x5)(222x14)(19x15)(5x7)YFROH(4x8)JZEX(170x9)(17x11)TXPYYKEDAAEIIHIQR(3x14)DDA(33x3)WEUQKNHZKSULIDTJLKSHRZAVGQSRAGLXJ(23x4)AZLXNPVGKFLNFNWCIYZFRJO(62x14)(21x12)VOELKVXNJPFKZXUXUFPNM(10x14)NJHLTGPRRM(10x13)QQVHCFJNIL(13x4)LZQORYCLGZDLW(621x8)(53x13)(46x12)(5x6)AGWBH(13x8)CRHEPUJGRCSRG(10x14)WBOGSBRMRB(179x12)(63x3)(2x4)IS(50x3)HROWDECXXSDBPOAGVNOJDEQIZBOQKTATRHVHBZKULTIWMEJCAC(5x6)NUIPA(48x9)(9x8)WHFUZGMJE(8x1)TXNYJRTY(8x15)YVICNVTL(2x4)GL(26x14)JSKGYJNSZOMFQUAZOPKHRJXZCB(8x2)XGTNBUPL(186x6)(1x10)D(45x2)(12x12)XNGBVKIWFHIP(1x8)B(13x14)XTZRKDYSHJUBZ(20x11)(7x6)OHJDEDR(2x11)JK(38x9)(3x14)RNJ(1x6)T(16x15)QPEVXIISOYVITEPB(50x11)(10x9)MQOZENDALR(16x4)PTHFKKBJVGOBAAAC(7x9)HMTIXKQ(5x7)YNMXS(164x7)(32x15)(6x5)SWOXAB(15x2)FTKGPRBTHJUKTCW(19x7)CYPIKMBVTAMYVQWRXRV(93x15)(16x5)VELTNEKICGGTHSIG(33x1)SHMTTUDQAMFSZYVWRSXMECMTRREIOISUM(2x2)PY(8x8)HBXZGGTW(7x4)JJLREPF(243x15)(55x6)(12x9)VOHPPKUUVVCZ(7x12)DGJXYQW(18x5)(2x10)HC(5x7)SAXCK(45x13)(3x7)MEY(31x1)(13x2)AEYYRHZQRJSGM(7x1)EGTALZM(108x5)(11x5)ROWNCUDQNQJ(28x2)SEEZKTZZPEIDPKPMTDCUAJHDLDNN(51x2)(3x13)AGT(5x9)XIUKR(12x10)IWVWHPFQTINU(7x14)BTEANZL(1x11)F(2x13)LS(8x13)(3x2)LUC(1213x6)(663x15)(137x14)(84x7)(6x1)TMXBWH(7x14)VKYQRRQ(8x7)WFIEIKOQ(3x14)QCC(31x12)ZCKJULCEOWGNUWUIBHNVEGIJRCSJMOM(31x13)(2x11)LM(8x15)SFBCSQJL(4x6)QHCM(3x11)CBC(195x9)(64x1)(33x7)WEYTJBSGQYIVAXOKOKLPQDLCMKWSQIOOM(4x13)OCQZ(9x12)YLLJTYSZN(99x3)(12x14)HMIJNELRDESH(19x7)WMLAMTNMVHNXLVXCDOM(15x7)GUFPYVLLWEBPNMA(28x6)ANXIOHZQVAMXSPVHVCEXWEZOFUWY(13x15)WWUPLLIZHXOHB(80x15)(38x4)RWDFBSRYHIALVZBVTRDHFEGCMVIKHUBZTXUOHN(5x14)OWFNV(11x14)(5x11)YQUNB(1x14)Z(175x10)(14x13)OXUNCZBDMFOKFS(13x9)MRVEIVOPPZGZI(75x11)(22x13)LYHFTFARQYEKPPLMKXDRDN(8x14)BGLVGHSC(4x13)RYAA(3x3)JXF(8x11)QQKDURUW(16x4)CRITQZIDQXWLOPEE(24x11)(5x13)OHSDS(7x15)BIUHVFN(40x7)(1x9)F(27x11)(14x3)SNTAPIIPSNTYPH(2x9)IZ(36x4)(30x1)QFEILBXHHDPZOIWMHCMIPDDLQBFSPQ(233x3)(6x4)(1x2)I(15x14)(9x15)HXTGXRPAO(41x14)(23x10)(8x6)OVMQIBCH(4x10)TEFD(5x10)CQVBQ(47x4)(41x4)(7x15)TBBIDLP(12x7)WCSIUGLOVTCE(5x3)XUZEB(92x11)(48x6)(24x15)HMMZXFKDJTHJRVNHGYRXLWAJ(10x10)ZBVSMVFVXU(6x6)UBPFNN(21x4)OHPFKGINXHHNTVGEXWUWJ(238x14)(100x7)(1x11)F(13x7)KTMNHBVUTETXV(48x10)(3x6)WMS(16x1)RNBJYFNNLGOCNDZD(12x3)OTLUNTYHCBUX(12x10)(6x12)RIWZBS(8x14)SGNEDXZU(109x14)(2x12)SW(1x10)N(13x14)GCSHUVMYCCMTZ(68x4)(15x15)SBNDGRGMFURIDAQ(1x9)D(4x12)TQTY(24x4)JXQJHMLQYGZVVVVNMULCBTVI(8x13)KCTVUZQD(1002x13)(28x9)(21x10)XJWDEAFPYBEAACUSBTTAI(1x13)B(954x7)(871x8)(286x14)(6x2)EGSZVB(68x1)(10x15)JCQYVSYFUB(5x4)KFNLK(7x10)ISBLBFY(8x14)MBSLSQKL(8x14)MYNVUQLQ(92x9)(28x15)RQMUIKORYEKRKVNEROAHYMVEFJAG(4x13)VPRO(3x3)UJT(32x14)FHELRVLWQYIZWELORJNQZQHUJRXLQOQQ(41x15)(2x15)DX(19x1)FCNCSZOUPBCHJOCUPUX(3x6)EOM(48x11)(10x9)TDGPCGLCNP(5x3)SCMAY(1x5)G(3x2)CLN(3x9)SQC(147x10)(88x14)(30x3)DEZNWROIXRCOQQSLSTNIFNKYJDYJSN(5x4)YKMRT(3x9)OLC(20x13)UGOOSFJZYQEVLZCNMCLS(2x9)EC(27x9)(9x2)BEMGTGSWW(8x3)WCAQPONY(13x6)(2x8)RR(1x2)E(163x1)(1x11)I(30x8)OSIRHUOUAWGEYPOPNXCFCFRIIBKANK(45x4)SIUTVWEAMACMZZEDPTEQGTSIXEBBILUHFDCPQNAVZKWWU(34x14)(9x5)CJZUUSTAG(7x10)HDMWUSL(2x4)XU(21x11)(5x11)VLIOR(5x4)NEWZO(163x8)(19x8)(13x9)ROYCUMVOSFOOY(50x12)(7x12)RISUJGZ(7x5)MCHHDAS(2x4)MF(6x3)QVXFNN(1x14)W(31x2)(24x12)NCPVZEEMELEELVJMOLNBTOTE(15x13)QBQDROIBCFETDZR(16x4)TGKTDUURIZBJWMNM(75x11)(68x12)(4x5)FCFL(2x6)TI(9x4)NERSBDUOR(31x15)EQALNPDFIGUCULGYOFTUCGNGQZIVMMC(7x3)FNSLZWW(58x3)(13x11)NQNQCRYFKISDK(32x5)(26x6)(2x13)UN(11x10)HUTTNNOMCHO(4677x4)(1938x10)(613x10)(112x2)(104x13)(98x1)(8x2)QPRBPGYG(12x12)ANPHJWZOCNFO(16x4)OTKPPEDIOVFFSCSV(13x10)MGAHOEIEPYWXD(17x13)APOVIDOSFIFSXXWTU(460x15)(27x8)HKNYIOBAGFYDWMZOZRDLABEMTVV(7x13)KDJAPEF(172x3)(11x10)NWXZPBYOKCY(6x1)XSSZVP(44x1)(12x12)OLPAYUOZFZWH(10x2)IFQGWKKMVV(3x15)WXI(87x6)(7x11)YLUPIDJ(6x11)HEBMEO(10x2)BXVERSJGBZ(15x9)KPYVQEPNIEOJAGE(18x15)CLECVIUKEBUSAQBNOE(213x12)(17x6)(2x14)UL(4x3)TTXF(65x2)(11x9)APULVPDBMBC(11x11)OBNFWDSYNSM(16x7)YNSXLFVFUFLFQITJ(3x1)CSE(29x8)(5x8)GPCEP(5x11)HFCHE(3x8)MFC(78x8)(1x9)K(3x15)HEB(6x13)CWOKRI(23x4)PAPGFEVZGRDFWZMYCRMKOAS(16x3)FLRLJVNQXCLKPNHF(9x1)KBIPXKFIZ(20x5)HNHJSKIIKQNHSPLGRHTC(99x5)(18x13)IMANEECWKKFNKBYVXE(67x15)(49x3)(43x3)(6x13)FDUETL(17x14)MUJRAQUUSFMDHXQFI(2x2)AI(7x1)HHDIVBG(277x13)(124x4)(35x8)(29x5)HWBBWDKTDHLUKLFYNRPPSMYVHJEBV(27x1)(20x12)RDTQGXSQFMCWHYLVVBRM(3x9)QQS(10x1)KHCHMMQOEA(20x8)(13x12)ICXOXCTKZNPNQ(126x6)(93x15)(87x1)(7x8)BXBQLBJ(9x3)YWKKXWGKN(15x10)VWUDDWDDPJDUJPZ(5x10)AQYPW(22x9)SBBTYEWZBRHWXTDKDRUBQE(20x3)(8x3)XXHVXISU(1x13)G(8x9)(3x9)VDK(906x14)(242x6)(96x8)(3x6)TJY(26x2)(20x9)RUJQRZUILLFLBYKABOLO(17x5)DFRLLLBUKXIOKEHGO(21x8)SRUBCXYPTJELXKNWTHOXV(1x4)S(132x12)(64x8)(29x6)DTADXEUJQEUQOCEVGVJUXKRVCMLHD(5x10)HRKEC(12x8)GCQRBZQZEJRI(10x11)CMAXESUBKZ(39x5)(20x7)DSBVZVCSXFHJJWVVUQUT(7x15)BVOJMIW(286x5)(51x4)(7x1)GWBWCTG(19x14)UVYVPIUGFKYTGLEOWRW(8x4)WGRLVUIA(105x1)(14x13)XMLZUFWDXGWTDB(78x1)(10x14)WEEBNADHPI(11x8)UBTFBDHQIRL(6x12)MTEFKN(3x9)EDA(18x9)FKUODUDJLGUSMNSFJK(19x13)(13x3)YSANOEAZOULFX(4x11)YRDI(74x13)(25x3)VVDTNONHGTDAHSLQSIPSSSUAM(37x6)(30x10)LPENUYPQFZNJXBJIZXKODKMWYQEDSO(168x11)(101x8)(5x8)WFEYY(84x15)(1x4)K(28x8)AJYOVLVQDUJXSYKSCOVLQIXVJXZR(9x5)KDFQRVACM(7x12)MGQOIJF(11x1)TGAESLVRLBU(53x11)(9x9)FRUFXUWTZ(12x7)GOMMFRTUAIJF(15x1)UQVMQVBVRWTAHIJ(181x2)(61x3)(20x6)(6x7)BHVEGR(4x8)OYSO(29x5)(3x10)GKT(5x1)QCOIT(5x1)MHCYU(90x7)(15x9)CKCWUPSKCHQGAYP(57x4)(7x7)IWZWQEP(6x14)CHEXAQ(27x6)PFOUKHLGDFNMPYGDSQXVDTXKUQN(1x8)N(11x10)FJYPDWPXBBJ(7x13)HFWUVVA(1556x3)(823x10)(458x7)(8x8)(3x7)LEI(79x8)(14x3)GPIPWXBCMRABNU(27x9)YXJUFLIAGXQOWBIVBLONZCQCXRT(20x6)CSLFHVLUEPHKDBUEUPII(55x10)(4x13)VKTM(26x7)(4x1)BDCB(10x11)KTKSUQAYEX(2x8)TK(1x5)Y(1x10)H(284x4)(46x4)(8x10)TQIUJTYC(6x4)PTBZJT(3x3)VWQ(8x2)OKFWPOGJ(55x6)(12x9)XAGCMCMLFFMO(1x9)O(25x4)CXMCEGMCJPBSDEJNSWTRRPSMN(84x13)(7x1)LCPFFDL(13x9)QLVDNLOCHVCCT(24x4)ZZRKEMEJGRHENVAVDJJLJISS(3x13)EQS(9x5)YUNNSHHBF(67x14)(9x3)IDOKKCMQE(6x12)JCDFGP(9x6)WGUPQNKYR(8x3)MWPGGKPB(9x6)RMIWVZRVO(1x8)L(286x8)(131x2)(63x10)(19x14)JCEMKPNPJTETWYJVZWC(5x15)JAZRL(10x14)EIMGJVUYEN(3x13)NTB(6x8)IDCSBH(44x9)VZXXRMBILTMTKGEIQPQXMQFMWZCBHZYJVAIEKYIERTSH(140x14)(5x8)PEPUT(50x11)(2x12)RY(3x7)OFE(15x14)VSRBAGROMMJSXVC(7x2)PCECVOF(67x7)(14x4)JHXBGLRRAXMQQQ(4x11)WATN(5x15)RHAWF(14x8)NQCTCWEJWKIPWY(1x9)K(43x13)XQVWOJAXHINCECWZSGUTXUOVHCXBFFRGMMXPCNAXCQJ(9x14)SPDEDLKUA(718x8)(260x1)(25x10)(10x10)FPYZQHJSAA(3x7)DKR(14x13)PWFFFDYVONHDMQ(68x4)(62x8)(13x4)MQSLGJDWYQRQM(1x3)I(1x1)L(3x4)YBS(17x1)FJSCQNYGZHSSDAKTW(125x12)(101x11)(29x3)OQTKNJEQTDALQMQOAUAHPTDVQTWSB(3x7)NJZ(18x11)UIIJPTFKBWBPBTHEUB(12x15)NQJJJHSHDMMT(9x2)MHVQRZJFU(2x7)QZ(4x6)MHYD(184x4)(151x7)(78x11)(20x12)SIPUJQSKVOXTSPRJQJTW(2x8)IE(16x15)DSTVLUGJCQDFYGNW(4x7)GWZY(7x8)CQFFNUL(3x7)CIO(52x4)(12x4)XFJTPGWJBYEB(2x13)TK(7x9)AIJAHZN(3x7)ZQC(1x1)L(19x13)AGIRUIDVWKVMNKKDNEY(253x8)(145x2)(79x11)(19x12)TZIPIRGURKPTNHBKTWI(13x6)VPCUTZRRTHUES(19x15)YMGUFKRLWJGZKBCJESL(2x12)IT(53x2)(2x12)BH(24x15)LOMDVBAPFKPLSMYGIJUQOIAI(9x6)ZYMTSXODW(4x7)XMPG(85x12)(21x11)IMZHIEREVBWIZZLQAEKKR(35x11)(7x11)ETBXSQY(9x4)ZYSMOBWXX(2x10)IP(2x7)OH(2x10)BE(1158x5)(1004x15)(14x15)OUOMXGSDJINKFC(22x9)AXKODOZIXXBGJSFPOMPHEA(475x1)(77x3)(70x12)(23x3)PEASGWSUEWLMMNKZVCIFXYJ(2x4)SS(9x1)LOVSTWXST(1x11)M(8x8)VREHUKRQ(127x11)(7x11)IRKPRUL(56x9)(1x5)U(13x11)QRDESWPYXSMNU(6x15)WWOYOS(11x15)QAEUGZTYFER(17x5)(10x13)LTTMYSHCUD(7x4)ZGAXPQM(10x15)EFSIOUMNZD(23x4)(4x6)VEPR(9x5)TKMCUAZMQ(186x5)(4x9)CXNU(125x2)(1x4)D(20x7)NIKRVWXIYQSNJFXFEHRT(25x13)AUMLVHGXPLRVOUWQXJQLAWZVS(20x12)VITQFKSIGDIXXRGTWRKM(28x9)YOPGHLHIXMJYCZVDYVSRHEUVERJU(39x5)(6x6)WMGMWZ(5x14)WJRCB(11x1)FUOIDYNIFPB(28x14)(1x5)C(15x14)(1x11)M(2x10)FH(466x9)(205x9)(54x2)(2x13)BI(1x14)L(14x12)VGLGAQCJFTEGEQ(2x6)EU(5x13)MSFIY(2x2)AB(15x12)JRSCMSFZGAPBXFD(1x6)O(102x10)(32x3)XAWIRJWNNRJZTTRAQQBSHTMLVCDMIXZE(1x12)S(9x1)SMMHANCJY(15x11)LCBJBWQNCYPEWZX(15x9)AXWQXLBJYULSQYP(8x6)XHWIBTUM(207x9)(80x8)(21x7)XQUMFXKIUDCQPYJYKEWSU(14x4)RKBFMJZXNOIRLV(6x14)CATRWA(7x11)EKXSRXI(3x3)QTQ(2x9)QT(36x15)(5x5)AEACG(8x13)FQAHVRXJ(1x9)X(1x8)Q(64x11)(10x1)BCPSDNDTJR(18x4)PXTQLHXQVPWCWTNTKX(1x11)C(3x10)SRU(3x2)XCM(20x11)(6x7)PJDAQS(3x10)QRO(3x14)GYY(128x10)(121x7)(113x14)(1x9)H(22x4)(15x13)ULRJNYJZUWIMRTH(72x10)(48x7)SLCTDFCDFNDQWSJDKLOTILXMEFSAYGDNHMOWEJNSUFZOTYQJ(12x9)IYDHCVLBGTCQ(1730x2)(1047x13)(698x7)(73x10)(66x12)(60x3)(5x11)GFHDX(6x13)IEVPHZ(14x5)AOYCKZACHNPHKU(1x14)A(5x2)QTWEP(277x11)(140x8)(3x14)SFF(2x12)XP(16x12)LRMOAXXWONAQCRLJ(30x9)(18x8)PMICAVSANUXARFVMGK(1x1)N(57x13)(7x3)ILPNNZC(11x14)MPKYDJOCESY(21x8)LHYOFMHVKXIVTAZUUVUMY(15x14)(9x14)SJFBKPBFF(12x2)AREVFZGHAWNP(84x2)(11x13)NYCOYNWXIVG(5x10)RAWPP(48x11)(3x13)AAV(15x4)DLOQNWPGVFAPVXW(2x7)LE(5x12)EOBEN(326x8)(26x15)(4x7)HWRH(10x13)WHUZSXHXCA(172x3)(9x15)(4x9)ZPRR(14x6)HHZJCCFUHPFHPB(13x2)(7x13)VAHPPYJ(60x9)(6x11)NGHIFI(1x11)U(6x11)WYHPXT(23x5)QIINGGFKUULCXAEOLOCTYGF(45x11)NVSZANULDOCFNSRRPBMZYCUBBEUBJIUVBQDOSOHDEJMZT(107x5)(7x13)(1x11)K(7x5)VVZWLJD(1x4)F(13x4)NCRWEBMMYRSCU(50x10)(10x13)UCINUMHVPX(4x11)WRWR(2x13)FD(4x5)TQDV(1x9)K(265x11)(235x13)(14x15)(8x11)(3x3)VLT(26x6)VAHQBOYIAISMAIWDNIXCAPDCYM(175x5)(17x10)WAUBAFUCJKHLXAUMF(16x1)(3x12)BGR(2x5)BW(29x14)(4x9)TDDG(7x5)LDHVTSX(2x11)FW(87x2)(11x6)UVQJHUJCGZE(20x6)UXXTYGCYMJFUGZBKGHEE(1x7)L(19x9)DYDJVYHSZQKPLFJOOUD(7x15)YZZTSHM(16x2)FJAWRKOWWDLKZTYE(50x12)(22x7)TIWZCZIIIGATCIOKUPPERX(16x4)UQEQZEXMVZPTWFWY(7x7)(1x12)O(645x6)(630x7)(64x6)(2x6)RK(51x7)(45x8)(2x15)RY(13x14)OAGUJKEIWNSDJ(10x10)XSRJJQXDWB(335x10)(2x8)AH(174x5)(64x5)(2x10)MA(19x10)KGQXRSJLHBINZOTMWXR(1x5)L(7x9)TEEIUFG(6x10)EFXFRE(21x15)(5x3)LJQOL(5x12)GHTAP(38x15)(14x2)AULDLZXJBHHQPC(6x2)XVOHEM(2x2)IA(17x8)JOMPQUZELKQZVQIYQ(3x6)EZO(18x1)JXWHVNDXNITXUJLRYK(86x11)(1x8)E(16x2)FLGLNIEIUKAGVRAJ(9x9)(3x11)JAZ(38x9)(2x11)WD(8x15)ZTMQQKDC(10x6)QOYFLIULHQ(24x6)(18x2)PHAZAPOEWFLSECGQBX(210x6)(54x4)(47x12)(13x4)MHFPUTJZWZZUW(5x15)EWAQT(1x7)N(5x15)BGAGR(10x3)FZLXPYVCMD(10x15)(5x5)APRTF(14x15)RUCIVNEFFQEVUG(90x7)(44x15)(11x9)LJZXZOALAZX(4x3)UXPD(11x15)CNERQVSROLD(19x11)MJKMMHNKIRFPZXEFUXI(8x9)CJVGTIYJ(2x10)TM(3x5)QWZ(9x6)ZQMCTBXQZ(2998x1)(1281x1)(243x13)(142x5)(3x14)LAD(60x2)(43x11)YFKBKWRZQKSTRCSNTJWDCCHQLTIIMCFDRFKUBMOCFOC(5x3)SABWE(61x2)(15x8)(2x1)OV(2x12)TP(10x1)SHYIOMQRQL(17x15)ZERPZXPMQZYVSSZNK(7x3)KSYCJQY(76x9)(63x7)(14x8)GFTMOFZMOPGZXN(5x1)VMIME(27x2)(3x1)ATW(7x15)NQVEMOP(1x4)X(2x5)NY(10x5)OEOUOELBLO(1006x7)(86x13)(79x14)(32x9)(4x11)BVYW(4x6)ZIIU(2x8)LM(1x5)G(34x15)(27x12)JLZCGLGDZEUKNRQENVASLBXDPTR(2x7)BQ(347x3)(178x9)(50x3)(1x3)L(27x14)NFAVMKWGKWAWEZOUGSBKKUPJPAE(5x3)JWJCZ(15x1)SGXXIQWTYCLPTEM(79x3)(4x8)ZOYS(5x6)GAYER(34x9)BYVDMCVDLCCSGOLGAURHTNZPUDZGFBENTJ(14x3)YTEUXQQXFHIAYC(10x1)(5x4)RDBKM(141x7)(12x1)KYQCKNNVJAGC(35x8)(10x7)UGLLWJGANY(13x3)WYGIMJUZOPRNY(29x8)(2x7)IH(16x6)OIFBOOGDTNMVBKBW(18x15)UYOFFTLLTYDJXARCGL(16x8)XHPRIHKNBZEQSGWB(9x2)WFVASAAFX(203x13)(195x14)(13x1)(8x2)RPSDRVHB(1x13)Q(70x3)(5x10)OABFO(16x9)JEDFCWBXOYNVUPPP(3x5)UAL(22x12)PGZRHGQMOGIIRUBVPORUVL(35x12)(7x3)LLOSKJY(17x1)PCNKJUHRHZAYONLFS(45x4)(18x3)ORJWHFDNVYHLEMPROC(2x7)EZ(9x3)UJHCZDOYJ(334x7)(214x12)(51x5)(33x12)SQWVVCZEJJUELBLJFZCPSJKESRKJMMIKK(5x10)AVJRQ(2x13)ZM(110x11)(32x14)YJQVZYUOVYMSYPEKGXTLGKKYDMUDFSCS(17x9)EATJLTANIUXWYKCML(10x3)GSPFLSNRKV(7x3)CTXKMWU(14x2)YHNFZUUGDYFDKE(16x6)OIUVPDUSXYAKGCFQ(3x10)XYQ(7x6)IVRNXNQ(56x13)(29x1)(22x13)WOAAMMDLMMDFPJDUIYPWGL(3x4)PWD(7x10)AFPZAXR(6x7)PJMKNK(19x11)LSCZBAHWGACIUQIUSQS(5x6)LBLPV(11x7)XBWAVKYVWSK(749x9)(189x11)(182x1)(111x8)(7x7)MJPULGA(24x7)IVNYKMQQRYICBDMVYVPSHYJF(57x7)(14x14)RIAHDZDHUMRDDF(2x13)UH(4x5)LGIQ(5x2)OKPCC(4x6)DLGK(1x2)A(57x14)(28x6)BDWHSWUIRSRHZSZBMTVCCFUUMPHJ(17x9)WFWYRFJEYAOIRLVHH(12x2)(6x12)ALRQWZ(56x10)(50x7)(44x7)(38x3)(4x5)VOEB(22x13)KEGQNPLJAXDQMNAIQHBXJY(442x7)(321x9)(3x13)ZNE(305x1)(82x12)(4x14)VARC(17x11)VOGEKOJMAUSKPCGUE(1x8)S(35x10)EZHQXIYWEXMOCTKWVHKNDJKKYWACLOKWQXC(63x9)(8x1)KKCBDKDR(6x11)RDGOEI(15x10)UQTPSFUTZAWLIIM(10x7)JKEPYMIGWI(56x14)(18x5)GNCZZMXQVVXALVLUFW(14x7)KTIRAHNTLSEGCL(6x12)IGJDAK(58x15)(15x4)WWCZOZPHHCQNWWK(1x15)J(15x11)SFNVYTOQYNLTSFF(3x4)HOL(13x5)CAWRJXZRUINLC(66x13)(60x1)(40x1)(7x6)DWOFGBV(10x1)GSSUZIFBIB(6x13)DFCOWN(8x12)VSEMJCLC(5x15)TQLYB(23x12)YYSVPWEHHYTKFZPPQUBBARM(15x11)QHOMIAHVSKMADON(919x5)(845x7)(161x7)(141x5)(99x11)(37x1)BQFZNRGANQOTMIPRYIJGPAJXECYTQSAICKHYC(2x12)HP(4x12)AMZI(19x15)XBQOLHYLZHQXQKDVNCS(7x9)KQHPWKY(7x11)ZKUUYIH(15x14)XVKENJACBFKNDZD(7x11)QIHNYZS(5x3)UJZKC(26x10)(20x8)(1x2)O(9x8)EXKRBXKZN(627x2)(166x3)(56x15)(2x5)FQ(2x15)KC(8x4)IWGFOKMR(22x3)NILSAQOHXIHTYPVMCYQTPW(13x15)JSIKXUAKZXMSS(71x2)(2x6)HA(5x5)MJCZA(1x6)H(42x1)BDJQXMKPMJHIMAOYOMOMMOMENRCYZBBDDSLFAECTXB(1x1)K(245x14)(98x14)(14x2)VBUTNIWNBBHZKW(10x11)EBQPXQGWOH(33x12)FJQUUHNFDXNZCPMYVXKRIIDQPYMCAAUGG(8x6)VUJPEWVP(2x13)FN(4x2)DTPI(64x13)(22x12)ETENSOEGFPUSCVBDVRIQHN(3x7)QVA(8x13)WJAOLFTQ(8x2)RJFQGBTK(54x6)(8x13)RPZVGZSK(1x14)M(14x9)HBZWCWIKKIECKS(1x8)C(1x12)H(187x7)(32x13)PGFKFCVWRHVLZWUPETPWQJBFBKLKEVQP(13x5)(7x10)MZXGRCU(84x5)(11x8)XJIWBTQAINI(24x12)ZOADVAJIDKRPQLTWHWGKWZDO(7x14)UZAPNFF(17x2)KUDTCAQGWZPOHXLTP(17x11)PZRVJSMARQWATRCXQ(9x14)OLIIATFZF(2x5)CD(61x9)(42x1)AMRDDEXDMPFZNFDXCJLIYPCGIIXPSJOYQBKMPNIXMG(8x9)MISCZWWO(3x3)YWE(12x9)RQFDUYVCWWVP(94x4)(55x11)(12x3)EXJZRABNQCQM(3x3)VQB(23x3)CEIZADMRYNYDKZTQCMZVTXP(2x14)WX(17x13)TCVJAPAJBGWWWZKNU(193x9)(71x13)(4x3)OJBO(15x12)OKDYKBYJVQRTUEO(7x7)JUPXPDG(15x9)ZSBSAJXXRXLOXKL(2x3)MC(1x14)R(33x12)(5x9)LCZSE(16x13)UFOJUKIRLJOGKLOM(38x12)(1x6)F(10x7)UKQEDWEZGI(2x8)LG(3x11)RIP(17x9)EFDWSPUEYWQRANHNI(24x4)(6x13)GDERFU(7x2)(2x9)CJ(55x4)YRIVLPZWKERMEAKAPBXHCETTWPEMIOBJMOTREOYAASVIRSJKFHJJHJS 2 | -------------------------------------------------------------------------------- /lib/AdventOfCode.hs: -------------------------------------------------------------------------------- 1 | module AdventOfCode 2 | ( loadDay 3 | , runDay 4 | , Day(..) 5 | , module P 6 | , module S 7 | ) where 8 | 9 | import Text.Parsec as P hiding (State) 10 | import Text.Parsec.String as P 11 | import Search as S 12 | import System.Environment (getArgs) 13 | import Control.Monad (when) 14 | 15 | data Day i = Day 16 | { dayNum :: Int 17 | , dayParser :: Parser i 18 | , dayPartA :: i -> IO String 19 | , dayPartB :: i -> IO String 20 | } 21 | 22 | loadDay :: Day i -> IO i 23 | loadDay d = do 24 | result <- 25 | parseFromFile (dayParser d <* eof) ("input/" ++ show (dayNum d) ++ ".txt") 26 | case result of 27 | Right input -> return input 28 | Left e -> error (show e) 29 | 30 | runDay :: Day i -> IO () 31 | runDay d = do 32 | args <- getArgs 33 | input <- loadDay d 34 | when (null args || "a" `elem` args) $ 35 | do putStrLn $ banner "a" 36 | putStrLn =<< dayPartA d input 37 | when (null args || "b" `elem` args) $ 38 | do putStrLn $ "\n" ++ banner "b" 39 | putStrLn =<< dayPartB d input 40 | where 41 | banner ab = "==== DAY " ++ show (dayNum d) ++ ab ++ " ====\n" 42 | -------------------------------------------------------------------------------- /lib/Search.hs: -------------------------------------------------------------------------------- 1 | -- These are pretty much borrowed verbatim from glguy: see 2 | -- https://github.com/glguy/advent2016/blob/master/lib/Search.hs 3 | module Search 4 | ( bfs 5 | , bfsOn 6 | , astar 7 | , astarOn 8 | ) where 9 | 10 | import qualified Data.Set as Set 11 | import qualified Data.IntMap as IntMap 12 | import Data.IntMap (IntMap) 13 | import Data.Foldable (foldl') 14 | 15 | bfsOn 16 | :: Ord b 17 | => (a -> b) -> (a -> [a]) -> a -> [a] 18 | bfsOn rep next start = go Set.empty [start] [] 19 | where 20 | go _ [] [] = [] 21 | go seen [] ys = go seen (reverse ys) [] 22 | go seen (x:xs) ys 23 | | rep x `Set.member` seen = go seen xs ys 24 | | otherwise = x : go (rep x `Set.insert` seen) xs (next x ++ ys) 25 | 26 | bfs 27 | :: Ord a 28 | => (a -> [a]) -> a -> [a] 29 | bfs = bfsOn id 30 | 31 | astar 32 | :: Ord a 33 | => (a -> [(a, Int, Int)]) -> a -> [(a, Int)] 34 | astar = astarOn id 35 | 36 | astarOn 37 | :: Ord b 38 | => (a -> b) -> (a -> [(a, Int, Int)]) -> a -> [(a, Int)] 39 | astarOn rep nexts start = go Set.empty (IntMap.singleton 0 [(0, start)]) 40 | where 41 | go seen work = 42 | case pqueueNext work of 43 | Nothing -> [] 44 | Just ((cost, x), work1) 45 | | Set.member r seen -> go seen work1 46 | | otherwise -> (x, cost) : go seen' work2 47 | where r = rep x 48 | seen' = Set.insert r seen 49 | work2 = foldl' addWork work1 (nexts x) 50 | addWork w (x', stepcost, heuristic) = 51 | let cost' = cost + stepcost 52 | in cost' `seq` pqueuePush (cost' + heuristic) (cost', x') w 53 | 54 | pqueuePush :: Int -> a -> IntMap [a] -> IntMap [a] 55 | pqueuePush k v = IntMap.alter aux k 56 | where 57 | aux Nothing = Just [v] 58 | aux (Just vs) = Just (v : vs) 59 | 60 | pqueueNext :: IntMap [a] -> Maybe (a, IntMap [a]) 61 | pqueueNext q = do 62 | ((k, xs), q1) <- IntMap.minViewWithKey q 63 | case xs of 64 | [] -> error "Malformed queue" 65 | [x] -> Just (x, q1) 66 | x:rest -> 67 | let q2 = IntMap.insert k rest q1 68 | in q2 `seq` Just (x, q2) 69 | -------------------------------------------------------------------------------- /src/Day1.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TupleSections #-} 2 | 3 | module Main where 4 | 5 | import AdventOfCode 6 | import qualified Data.Set as S 7 | 8 | data TurnDirection 9 | = L 10 | | R 11 | 12 | data Instruction = Instruction 13 | { iDir :: TurnDirection 14 | , iBlocks :: Blocks 15 | } 16 | 17 | data Direction 18 | = N 19 | | E 20 | | S 21 | | W 22 | deriving (Show) 23 | 24 | type Blocks = Int 25 | 26 | data Position = Position 27 | { pNetN :: Blocks 28 | , pNetE :: Blocks 29 | } deriving (Eq, Ord, Show) 30 | 31 | shortestDistance :: Position -> Blocks 32 | shortestDistance (Position n e) = abs n + abs e 33 | 34 | move :: Position -> Direction -> Position 35 | move p@(Position n e) N = 36 | p 37 | { pNetN = n + 1 38 | } 39 | move p@(Position n e) S = 40 | p 41 | { pNetN = n - 1 42 | } 43 | move p@(Position n e) E = 44 | p 45 | { pNetE = e + 1 46 | } 47 | move p@(Position n e) W = 48 | p 49 | { pNetE = e - 1 50 | } 51 | 52 | rotate :: Direction -> TurnDirection -> Direction 53 | rotate N L = W 54 | rotate E L = N 55 | rotate S L = E 56 | rotate W L = S 57 | rotate d R = rotate (rotate (rotate d L) L) L 58 | 59 | parseInstruction :: Parser Instruction 60 | parseInstruction = Instruction <$> parseDirection <*> parseNumber 61 | where 62 | parseDirection = try (string "R" *> return R) <|> (string "L" *> return L) 63 | parseNumber = read <$> many1 digit 64 | 65 | parseFile :: String -> IO (Either ParseError [Instruction]) 66 | parseFile = 67 | parseFromFile (sepBy parseInstruction (string ", ") <* newline <* eof) 68 | 69 | runInstructions :: [Instruction] -> [Position] 70 | runInstructions instrs = scanl move (Position 0 0) moves 71 | where 72 | moves = concatMap expand (zip directions distances) 73 | expand (dir, dist) = replicate dist dir 74 | directions = tail $ scanl rotate N (iDir <$> instrs) 75 | distances = iBlocks <$> instrs 76 | 77 | firstDuplicate 78 | :: Ord a 79 | => [a] -> Maybe a 80 | firstDuplicate = go S.empty 81 | where 82 | go _ [] = Nothing 83 | go seen (x:xs) = 84 | if x `S.member` seen 85 | then Just x 86 | else go (S.insert x seen) xs 87 | 88 | main :: IO () 89 | main = 90 | runDay $ 91 | Day 92 | 1 93 | (sepBy parseInstruction (string ", ") <* newline) 94 | (return . show . shortestDistance . last . runInstructions) 95 | (return . show . fmap shortestDistance . firstDuplicate . runInstructions) 96 | -------------------------------------------------------------------------------- /src/Day10.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.Map (Map) 5 | import qualified Data.Map as M 6 | import Control.Monad.State 7 | import Control.Monad.Writer 8 | import Data.List (sort) 9 | import Data.Maybe (fromMaybe) 10 | 11 | newtype BotNo = 12 | BotNo Int 13 | deriving (Eq, Ord, Show) 14 | 15 | newtype OutputNo = OutputNo 16 | { getOutputNo :: Int 17 | } deriving (Eq, Ord, Show) 18 | 19 | data Receiver 20 | = BotReceiver BotNo 21 | | OutputReceiver OutputNo 22 | 23 | data Instr 24 | = PassLowHigh BotNo 25 | Receiver 26 | Receiver 27 | | Input Int 28 | BotNo 29 | 30 | parseInstr :: Parser Instr 31 | parseInstr = 32 | (Input <$> (string "value " *> number) <*> (string " goes to bot " *> botno)) <|> 33 | (PassLowHigh <$> (string "bot " *> botno) <*> 34 | (string " gives low to " *> receiver) <*> 35 | (string " and high to " *> receiver)) 36 | where 37 | botno = BotNo <$> number 38 | number = read <$> many1 digit 39 | receiver = 40 | (BotReceiver <$> (string "bot " *> botno)) <|> 41 | (OutputReceiver . OutputNo <$> (string "output " *> number)) 42 | 43 | type BotState = WriterT [(OutputNo, Int)] (State (Map BotNo [Int])) 44 | 45 | runInstrs :: [Instr] -> BotState () 46 | runInstrs [] = return () 47 | runInstrs (Input v b:xs) = putVal b v >> runInstrs xs 48 | runInstrs (p@(PassLowHigh b lo hi):xs) = do 49 | vals <- getVal b 50 | case sort vals of 51 | [v1, v2] -> do 52 | passVal lo v1 53 | passVal hi v2 54 | runInstrs xs 55 | _ -> runInstrs (xs ++ [p]) 56 | 57 | passVal :: Receiver -> Int -> BotState () 58 | passVal (BotReceiver b) v = putVal b v 59 | passVal (OutputReceiver b) v = tell [(b, v)] 60 | 61 | getVal :: BotNo -> BotState [Int] 62 | getVal b = (fromMaybe [] . M.lookup b) <$> get 63 | 64 | putVal :: BotNo -> Int -> BotState () 65 | putVal b i = do 66 | vals <- getVal b 67 | modify (M.insert b (i : vals)) 68 | 69 | partA :: [Instr] -> [(BotNo, [Int])] 70 | partA = 71 | filter (\(_, vs) -> sort vs == [17, 61]) . 72 | M.toList . flip execState M.empty . runWriterT . runInstrs 73 | 74 | partB :: [Instr] -> Int 75 | partB instrs = 76 | product $ map snd $ filter ((`elem` [0, 1, 2]) . getOutputNo . fst) outputs 77 | where 78 | outputs = flip evalState M.empty $ execWriterT (runInstrs instrs) 79 | 80 | main = 81 | runDay $ 82 | Day 83 | 10 84 | (many1 (parseInstr <* newline)) 85 | (return . show . partA) 86 | (return . show . partB) 87 | -------------------------------------------------------------------------------- /src/Day11.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import qualified Data.Set as S 5 | import Data.List (intercalate, find, sort, tails, groupBy) 6 | import Data.Monoid ((<>)) 7 | import Data.Function (on) 8 | 9 | data Building = Building 10 | { bLevel :: !Int 11 | , bItems :: ![(Item, Int)] 12 | } deriving (Eq, Ord) 13 | 14 | data Direction 15 | = Up 16 | | Down 17 | deriving (Eq, Ord, Show) 18 | 19 | data ItemType 20 | = Generator 21 | | Microchip 22 | deriving (Eq, Ord) 23 | 24 | data Element 25 | = Thulium 26 | | Polonium 27 | | Promethium 28 | | Ruthenium 29 | | Cobalt 30 | | Hydrogen 31 | | Lithium 32 | | Elerium 33 | | Dilithium 34 | deriving (Eq, Ord, Show) 35 | 36 | data Item = Item 37 | { iType :: !ItemType 38 | , iElement :: !Element 39 | } deriving (Eq) 40 | 41 | instance Ord Item where 42 | compare (Item t1 e1) (Item t2 e2) = compare (e1, t1) (e2, t2) 43 | 44 | data Step = 45 | Step !Direction 46 | ![Item] 47 | deriving (Show) 48 | 49 | instance Show Building where 50 | show (Building level items) = unlines (showlevel <$> reverse [0 .. 3]) 51 | where 52 | showlevel n = 53 | show (n + 1) ++ 54 | (if n == level 55 | then " > " 56 | else " ") ++ 57 | intercalate 58 | " " 59 | [ show i 60 | | (i, f) <- sort items 61 | , f == n ] 62 | 63 | instance Show Item where 64 | show (Item Generator e) = "G-" ++ show e 65 | show (Item Microchip e) = "M-" ++ show e 66 | 67 | fingerprint :: Building -> (Int, [[Int]]) 68 | fingerprint (Building level items) = (level, sort pairFloors) 69 | where 70 | pairFloors = fmap snd <$> groupBy ((==) `on` iElement . fst) (sort items) 71 | 72 | bestFrom :: Building -> Maybe (Building, [Step]) 73 | bestFrom b = find (complete . fst) (bfsOn (fingerprint . fst) nexts (b, [])) 74 | 75 | complete :: Building -> Bool 76 | complete (Building _ items) = all ((== 3) . snd) items 77 | 78 | isSafe :: Building -> Bool 79 | isSafe (Building _ floors) = all chipIsSafeOnFloor chips 80 | where 81 | chips = 82 | [ (el, fl) 83 | | (Item Microchip el, fl) <- floors ] 84 | chipIsSafeOnFloor (el, chipFloor) = null gensHere || el `elem` gensHere 85 | where 86 | gensHere = 87 | [ el' 88 | | (Item Generator el', f) <- floors 89 | , f == chipFloor ] 90 | 91 | runStep :: Building -> Step -> Building 92 | runStep (Building level floors) (Step dir items) = Building level' floors' 93 | where 94 | level' = 95 | if dir == Up 96 | then level + 1 97 | else level - 1 98 | floors' = maybeMove <$> floors 99 | maybeMove (i, f) = 100 | if i `elem` items 101 | then (i, level') 102 | else (i, f) 103 | 104 | nexts :: (Building, [Step]) -> [(Building, [Step])] 105 | nexts (bldg, steps) = 106 | [ (bldg', steps ++ [s]) 107 | | s <- possibleSteps bldg 108 | , let bldg' = runStep bldg s 109 | , isSafe bldg' ] 110 | 111 | possibleSteps :: Building -> [Step] 112 | possibleSteps (Building level floors) = 113 | Step <$> validDirections <*> onesOrTwos currentItems 114 | where 115 | validDirections = 116 | (if level < 3 117 | then pure Up 118 | else mempty) <> 119 | (if level > 0 120 | then pure Down 121 | else mempty) 122 | currentItems = 123 | [ i 124 | | (i, n) <- floors 125 | , n == level ] 126 | 127 | onesOrTwos :: [a] -> [[a]] 128 | onesOrTwos xs = 129 | [ [x, y] 130 | | x:ys <- tails xs 131 | , y <- ys ] <> 132 | map pure xs 133 | 134 | exampleBuilding :: Building 135 | exampleBuilding = 136 | Building 137 | 0 138 | [ (Item Microchip Hydrogen, 0) 139 | , (Item Microchip Lithium, 0) 140 | , (Item Generator Hydrogen, 1) 141 | , (Item Generator Lithium, 2) 142 | ] 143 | 144 | buildingA :: Building 145 | buildingA = 146 | Building 147 | 0 148 | [ (Item Generator Polonium, 0) 149 | , (Item Generator Thulium, 0) 150 | , (Item Microchip Thulium, 0) 151 | , (Item Generator Promethium, 0) 152 | , (Item Generator Ruthenium, 0) 153 | , (Item Microchip Ruthenium, 0) 154 | , (Item Generator Cobalt, 0) 155 | , (Item Microchip Cobalt, 0) 156 | , (Item Microchip Polonium, 1) 157 | , (Item Microchip Promethium, 1) 158 | ] 159 | 160 | buildingB :: Building 161 | buildingB = 162 | buildingA 163 | { bItems = 164 | bItems buildingA ++ 165 | [ (Item Generator Elerium, 0) 166 | , (Item Microchip Elerium, 0) 167 | , (Item Generator Dilithium, 0) 168 | , (Item Microchip Dilithium, 0) 169 | ] 170 | } 171 | 172 | solve :: Building -> Maybe Int 173 | solve = fmap (length . snd) . bestFrom 174 | 175 | test :: Building -> IO () 176 | test b = putStrLn $ unlines $ concatMap (\(b', s) -> [b', "", s, ""]) stages 177 | where 178 | stages = zip ("" : numberedSteps) (show <$> scanl runStep b steps) 179 | Just (_, steps) = bestFrom b 180 | numberedSteps = 181 | [ show n ++ ": " ++ show s 182 | | (n, s) <- zip [(1 :: Int) ..] steps ] 183 | 184 | main :: IO () 185 | main = 186 | runDay $ 187 | Day 188 | 11 189 | (many anyChar) 190 | (return . show . const (solve buildingA)) 191 | (return . show . const (solve buildingB)) 192 | -------------------------------------------------------------------------------- /src/Day12.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Control.Monad.State 5 | import Control.Monad.Reader 6 | import Data.Maybe (fromMaybe) 7 | import Data.Map (Map) 8 | import qualified Data.Map as M 9 | 10 | data Reg = 11 | Reg Char 12 | deriving (Show) 13 | 14 | data Value 15 | = LitVal Int 16 | | RegVal Reg 17 | deriving (Show) 18 | 19 | data Instr 20 | = Copy Value 21 | Reg 22 | | JumpNotZero Value 23 | Int 24 | | Inc Reg 25 | | Dec Reg 26 | deriving (Show) 27 | 28 | parseInstr :: Parser Instr 29 | parseInstr = 30 | (Dec <$> (string "dec " *> reg)) <|> (Inc <$> (string "inc " *> reg)) <|> 31 | (JumpNotZero <$> (string "jnz " *> val) <*> (string " " *> step)) <|> 32 | (Copy <$> (string "cpy " *> val) <*> (string " " *> reg)) 33 | where 34 | reg = Reg <$> letter 35 | val = (RegVal <$> reg) <|> (LitVal <$> num) 36 | step = num 37 | num = do 38 | sign <- option '+' (char '-') 39 | digits <- many1 digit 40 | return $ 41 | (if sign == '-' 42 | then -1 43 | else 1) * 44 | read digits 45 | 46 | data SimState = SimState 47 | { stPos :: Int 48 | , stRegs :: (Map Char Int) 49 | } 50 | 51 | type Sim = ReaderT [Instr] (State SimState) 52 | 53 | run :: Sim () 54 | run = do 55 | pos <- gets stPos 56 | instrs <- ask 57 | when (pos >= 0 && pos < length instrs) $ 58 | do step <- lift $ runInstr (instrs !! pos) 59 | modify 60 | (\st -> 61 | st 62 | { stPos = stPos st + step 63 | }) 64 | run 65 | 66 | modifyReg :: Reg -> (Int -> Int) -> State SimState () 67 | modifyReg r@(Reg n) f = do 68 | prev <- getReg r 69 | modify 70 | (\st -> 71 | let regs = stRegs st 72 | in st 73 | { stRegs = M.insert n (f prev) regs 74 | }) 75 | 76 | getReg :: Reg -> State SimState Int 77 | getReg (Reg n) = (fromMaybe 0 . M.lookup n) <$> gets stRegs 78 | 79 | getVal :: Value -> State SimState Int 80 | getVal (LitVal v) = return v 81 | getVal (RegVal r) = getReg r 82 | 83 | runInstr :: Instr -> State SimState Int 84 | runInstr (Copy val reg) = (getVal val >>= modifyReg reg . const) >> return 1 85 | runInstr (JumpNotZero val step) = do 86 | v <- getVal val 87 | return $ 88 | if v /= 0 89 | then step 90 | else 1 91 | runInstr (Inc reg) = modifyReg reg (+ 1) >> return 1 92 | runInstr (Dec reg) = modifyReg reg (\i -> i - 1) >> return 1 93 | 94 | finalA :: Map Char Int -> [Instr] -> Int 95 | finalA regs = 96 | (M.! 'a') . stRegs . flip execState (SimState 0 regs) . runReaderT run 97 | 98 | partA = finalA M.empty 99 | 100 | partB = finalA (M.singleton 'c' 1) 101 | 102 | main = 103 | runDay $ 104 | Day 105 | 12 106 | (many (parseInstr <* newline)) 107 | (return . show . partA) 108 | (return . show . partB) 109 | -------------------------------------------------------------------------------- /src/Day13.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.Bits (popCount) 5 | import Data.List (nub) 6 | import Data.Tree (Tree) 7 | import qualified Data.Tree as T 8 | import Data.Set (Set) 9 | import qualified Data.Set as S 10 | 11 | type Coord = (Int, Int) 12 | 13 | puzzleInput = 1350 14 | 15 | isOpen :: Coord -> Bool 16 | isOpen (x, y) = even $ bitsSet $ x * x + 3 * x + 2 * x * y + y + y * y + puzzleInput 17 | where 18 | bitsSet = popCount 19 | 20 | nextPaths :: [Coord] -> [[Coord]] 21 | nextPaths p@(cur:_) = (: p) <$> nextPositions cur 22 | nextPaths _ = undefined 23 | 24 | nextPositions :: Coord -> [Coord] 25 | nextPositions (x, y) = 26 | [ newpos 27 | | newpos@(x', y') <- [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)] 28 | , x' >= 0 && y' >= 0 29 | , isOpen newpos ] 30 | 31 | showMap :: Int -> Int -> String 32 | showMap w h = unlines $ showRow <$> [0 .. h] 33 | where 34 | showRow y = 35 | [ if isOpen (x, y) 36 | then '.' 37 | else '#' 38 | | x <- [0 .. w] ] 39 | 40 | paths = bfsOn head nextPaths [(1, 1)] 41 | 42 | partA = length (head $ dropWhile ((/= (31, 39)) . head) paths) - 1 43 | 44 | partB = length $ nub $ concat $ takeWhile ((<= 51) . length) paths 45 | 46 | main = 47 | runDay $ 48 | Day 49 | 13 50 | (many anyChar) 51 | (return . show . const partA) 52 | (return . show . const partB) 53 | -------------------------------------------------------------------------------- /src/Day14.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import qualified Crypto.Hash as H 5 | import Data.ByteString (ByteString) 6 | import Data.String (fromString) 7 | import Data.List (isInfixOf, tails) 8 | import Control.Arrow ((&&&)) 9 | 10 | hexMD5 :: String -> String 11 | hexMD5 = show . md5 . fromString 12 | where 13 | md5 :: ByteString -> H.Digest H.MD5 14 | md5 = H.hash 15 | 16 | hash :: Int -> String -> Int -> String 17 | hash stretches salt n = iterate hexMD5 (salt ++ show n) !! stretches 18 | 19 | keys :: (Int -> String) -> [(Int, String)] 20 | keys hasher = go ((id &&& hasher) <$> [0 ..]) 21 | where 22 | go (h@(n, s):hs) = 23 | [ h 24 | | c <- 25 | take 26 | 1 27 | [ x 28 | | x:y:z:_ <- tails s 29 | , x == y 30 | , y == z ] 31 | , any (replicate 5 c `isInfixOf`) (snd <$> take 1000 hs) ] ++ 32 | go hs 33 | 34 | solve stretches = (!! 63) . keys . hash stretches 35 | 36 | main = 37 | runDay $ 38 | Day 39 | 14 40 | (many1 letter <* newline) 41 | (return . show . solve 1) 42 | (return . show . solve 2017) 43 | -------------------------------------------------------------------------------- /src/Day15.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | 5 | data Disc = Disc 6 | { dSize :: Int 7 | , dPos :: Int 8 | } 9 | 10 | partA discs = 11 | take 12 | 1 13 | [ t 14 | | t <- [0 ..] 15 | , all 16 | (== 0) 17 | [ pos + (t + t') `mod` size 18 | | (Disc size pos, t') <- zip discs [1 ..] ] ] 19 | 20 | partB = partA . (++ [Disc 11 0]) 21 | 22 | exampleDiscs = [Disc 5 4, Disc 2 1] 23 | 24 | parseDisc :: Parser Disc 25 | parseDisc = 26 | Disc <$> 27 | (string "Disc #" >> number >> string " has " *> number <* string " positions") <*> 28 | (string "; at time=0, it is at position " *> number <* string ".") 29 | where 30 | number = read <$> many1 digit 31 | 32 | main = 33 | runDay $ 34 | Day 35 | 15 36 | (many1 (parseDisc <* newline)) 37 | (return . show . partA) 38 | (return . show . partB) 39 | -------------------------------------------------------------------------------- /src/Day16.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | 5 | expandData :: String -> String 6 | expandData a = a ++ "0" ++ (dNot <$> reverse a) 7 | where 8 | dNot '0' = '1' 9 | dNot '1' = '0' 10 | dNot _ = error "bad dNot arg" 11 | 12 | fill :: Int -> String -> String 13 | fill len input = checksum rawData 14 | where 15 | rawData = take len minExpansion 16 | minExpansion = head $ dropWhile ((<= len) . length) expansions 17 | expansions = iterate expandData input 18 | 19 | checksum :: String -> String 20 | checksum xs = head $ dropWhile (even . length) $ iterate go xs 21 | where 22 | go ys@(a:b:_) = 23 | (if a == b 24 | then '1' 25 | else '0') : 26 | go (drop 2 ys) 27 | go _ = [] 28 | 29 | main = 30 | runDay $ 31 | Day 32 | 16 33 | (many (oneOf "01") <* newline) 34 | (return . fill 272) 35 | (return . fill 35651584) 36 | -------------------------------------------------------------------------------- /src/Day17.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import qualified Crypto.Hash as H 5 | import Data.ByteString (ByteString) 6 | import Data.String (fromString) 7 | 8 | hexMD5 :: String -> String 9 | hexMD5 = show . md5 . fromString 10 | where 11 | md5 :: ByteString -> H.Digest H.MD5 12 | md5 = H.hash 13 | 14 | type Pos = (Int, Int) 15 | 16 | paths :: String -> (String, Pos) -> [(String, Pos)] 17 | paths seed start = go [start] 18 | where 19 | go [] = [] 20 | go (x@(path, pos):xs) = x : go (xs ++ nexts) 21 | where 22 | hash = hexMD5 (seed ++ path) 23 | nexts = 24 | [ (path ++ [dir], pos') 25 | | (dir, c) <- zip "UDLR" hash 26 | , c `elem` "bcdef" 27 | , pos /= (3, 3) 28 | , let pos'@(x', y') = move pos dir 29 | , x' >= 0 30 | , x' <= 3 31 | , y' >= 0 32 | , y' <= 3 ] 33 | 34 | move (x, y) 'U' = (x, y - 1) 35 | move (x, y) 'D' = (x, y + 1) 36 | move (x, y) 'L' = (x - 1, y) 37 | move (x, y) 'R' = (x + 1, y) 38 | move _ _ = error "bad move" 39 | 40 | solutions = fmap fst . filter (((3, 3) ==) . snd) . flip paths ("", (0, 0)) 41 | 42 | partA :: String -> String 43 | partA = head . solutions 44 | 45 | partB :: String -> Int 46 | partB = length . last . solutions 47 | 48 | main = 49 | runDay $ 50 | Day 17 (many letter <* newline) (return . partA) (return . show . partB) 51 | -------------------------------------------------------------------------------- /src/Day18.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.List (tails) 5 | 6 | data Tile 7 | = Safe 8 | | Trap 9 | deriving (Eq) 10 | 11 | next :: [Tile] -> [Tile] 12 | next tiles = 13 | fmap tripleToNext . 14 | take (length tiles) . fmap (take 3) . tails . cycle . (Safe :) $ 15 | tiles 16 | where 17 | tripleToNext :: [Tile] -> Tile 18 | tripleToNext [Trap, Trap, Safe] = Trap 19 | tripleToNext [Safe, Trap, Trap] = Trap 20 | tripleToNext [Trap, Safe, Safe] = Trap 21 | tripleToNext [Safe, Safe, Trap] = Trap 22 | tripleToNext _ = Safe 23 | 24 | safeInRows n = length . filter (== Safe) . concat . take n . iterate next 25 | 26 | partA = safeInRows 40 27 | 28 | partB = safeInRows 400000 29 | 30 | parseTile = (char '.' *> return Safe) <|> (char '^' *> return Trap) 31 | 32 | main = 33 | runDay $ 34 | Day 35 | 18 36 | (many1 parseTile <* newline) 37 | (return . show . partA) 38 | (return . show . partB) 39 | -------------------------------------------------------------------------------- /src/Day19.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.Sequence (Seq) 5 | import qualified Data.Sequence as S 6 | 7 | elves :: (Seq Elf -> Seq Elf) -> Int -> Elf 8 | elves f n = (`S.index` 0) . f $ makeElves n 9 | 10 | runElvesA es 11 | | S.length es >= 2 = runElvesA (S.drop 2 es S.>< S.take 1 es) 12 | runElvesA es = es 13 | 14 | runElvesB es 15 | | S.length es >= 2 = 16 | runElvesB (beforeSteal S.>< S.drop 1 fromSteal S.>< first) 17 | where 18 | (first, rest) = S.splitAt 1 es 19 | (beforeSteal, fromSteal) = S.splitAt (nSteal - 1) rest 20 | nSteal = S.length es `div` 2 21 | runElvesB es = es 22 | 23 | data Elf = Elf 24 | { eNum :: !Int 25 | } deriving (Show) 26 | 27 | makeElves n = Elf <$> S.iterateN n (+ 1) 1 28 | 29 | main = 30 | runDay $ 31 | Day 32 | 19 33 | ((read <$> many1 digit) <* newline) 34 | (return . show . elves runElvesA) 35 | (return . show . elves runElvesB) 36 | -------------------------------------------------------------------------------- /src/Day2.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import qualified Data.Map as M 5 | import Data.Maybe (fromMaybe) 6 | 7 | data Direction 8 | = U 9 | | D 10 | | L 11 | | R 12 | 13 | data Button = Button 14 | { bNum :: String 15 | , bPos :: (Int, Int) 16 | } deriving (Show) 17 | 18 | type Grid = (Int, Int) -> Maybe String 19 | 20 | makeGrid :: [String] -> Grid 21 | makeGrid gridRows = flip M.lookup gridMap 22 | where 23 | gridMap = 24 | M.fromList 25 | [ ((x, y), [c]) 26 | | (y, l) <- lines 27 | , (x, c) <- line l 28 | , c /= ' ' ] 29 | lines = zip [0 ..] gridRows 30 | line = zip [0 ..] 31 | 32 | squareGrid = makeGrid ["123", "456", "798"] 33 | 34 | diamondGrid = makeGrid [" 1 ", " 234 ", "56789", " ABC ", " D "] 35 | 36 | maybeButton :: Grid -> (Int, Int) -> Maybe Button 37 | maybeButton grid pos = flip Button pos <$> grid pos 38 | 39 | neighbour :: Grid -> Button -> Direction -> Maybe Button 40 | neighbour grid (Button _ (x, y)) U = maybeButton grid (x, y - 1) 41 | neighbour grid (Button _ (x, y)) D = maybeButton grid (x, y + 1) 42 | neighbour grid (Button _ (x, y)) L = maybeButton grid (x - 1, y) 43 | neighbour grid (Button _ (x, y)) R = maybeButton grid (x + 1, y) 44 | 45 | move :: Grid -> Button -> Direction -> Button 46 | move grid b d = fromMaybe b $ neighbour grid b d 47 | 48 | code :: Grid -> Button -> [[Direction]] -> String 49 | code grid init lines = concatMap bNum $ tail (scanl followLine init lines) 50 | where 51 | followLine = foldl (move grid) 52 | 53 | parseDirection :: Parser Direction 54 | parseDirection = 55 | string "U" *> return U <|> string "D" *> return D <|> string "L" *> return L <|> 56 | string "R" *> return R 57 | 58 | main = 59 | runDay $ 60 | Day 61 | 2 62 | (many1 (many1 parseDirection <* newline)) 63 | (return . code squareGrid (Button "5" (1, 1))) 64 | (return . code diamondGrid (Button "5" (0, 2))) 65 | -------------------------------------------------------------------------------- /src/Day20.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TupleSections #-} 2 | 3 | module Main where 4 | 5 | import AdventOfCode 6 | import Data.List (sort) 7 | 8 | type IPRange = (Integer, Integer) 9 | 10 | rangeLen (a, b) = 1 + (b - a) 11 | 12 | parseIP :: Parser IPRange 13 | parseIP = (,) <$> parseInt <*> (char '-' *> parseInt) 14 | where 15 | parseInt = read <$> many1 digit 16 | 17 | lowest :: [IPRange] -> Integer 18 | lowest = go 1 . combineRanges 19 | where 20 | go n [] = n 21 | go n ((a, _):_) 22 | | n < a = n 23 | go _ ((_, b):xs) = go (b + 1) xs 24 | 25 | combineRanges :: [IPRange] -> [IPRange] 26 | combineRanges = combine . sort 27 | where 28 | combine (r1@(_, b):r2@(a', _):xs) 29 | | a' > b = r1 : combine (r2 : xs) 30 | combine ((a, b):(_, b'):xs) = combine ((a, max b b') : xs) 31 | combine x = x 32 | 33 | partA = lowest 34 | 35 | partB = (4294967296 -) . sum . map rangeLen . combineRanges 36 | 37 | main = 38 | runDay $ 39 | Day 40 | 20 41 | (many1 (parseIP <* newline)) 42 | (return . show . partA) 43 | (return . show . partB) 44 | -------------------------------------------------------------------------------- /src/Day21.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.Foldable (toList) 5 | import Data.Monoid ((<>)) 6 | import Data.Maybe (fromMaybe) 7 | import Data.Sequence (Seq) 8 | import qualified Data.Sequence as S 9 | 10 | data Direction 11 | = DirLeft 12 | | DirRight 13 | 14 | data Instr 15 | = SwapPos Int 16 | Int 17 | | SwapLetters Char 18 | Char 19 | | Rotate Direction 20 | Int 21 | | RotatePosition Char 22 | | Reverse Int 23 | Int 24 | | Move Int 25 | Int 26 | 27 | type Password = Seq Char 28 | 29 | apply :: Password -> Instr -> Password 30 | apply s (SwapPos x y) = 31 | S.update x (s `S.index` y) (S.update y (s `S.index` x) s) 32 | apply s (SwapLetters a b) = replacement <$> s 33 | where 34 | replacement c 35 | | c == a = b 36 | | c == b = a 37 | | otherwise = c 38 | apply s (Rotate DirLeft n) = 39 | uncurry (flip (<>)) (S.splitAt (n `mod` S.length s) s) 40 | apply s (Rotate DirRight n) = apply s (Rotate DirLeft (S.length s - n)) 41 | apply s (RotatePosition c) = apply s (Rotate DirRight off) 42 | where 43 | off = 44 | 1 + nc + 45 | (if nc >= 4 46 | then 1 47 | else 0) 48 | nc = fromMaybe (error "no such char") $ c `S.elemIndexL` s 49 | apply s (Reverse x y) 50 | | y >= x = 51 | let (pre, rest) = S.splitAt x s 52 | (middle, end) = S.splitAt (y - x + 1) rest 53 | in pre <> S.reverse middle <> end 54 | apply s (Move x y) = beforeY <> S.take 1 fromX <> fromY 55 | where 56 | (beforeX, fromX) = S.splitAt x s 57 | (beforeY, fromY) = S.splitAt y (beforeX <> S.drop 1 fromX) 58 | 59 | unapply :: Password -> Instr -> Password 60 | unapply s (Rotate DirRight n) = apply s $ Rotate DirLeft n 61 | unapply s (Rotate DirLeft n) = apply s $ Rotate DirRight n 62 | unapply s (SwapPos a b) = apply s $ SwapPos b a 63 | unapply s (SwapLetters a b) = apply s $ SwapLetters b a 64 | unapply s r@(RotatePosition _) = 65 | head 66 | [ s' 67 | | n <- [0 .. (length s)] 68 | , let s' = apply s (Rotate DirLeft n) 69 | , apply s' r == s ] 70 | unapply s r@(Reverse _ _) = apply s r 71 | unapply s (Move a b) = apply s $ Move b a 72 | 73 | partA :: [Instr] -> String 74 | partA = toList . foldl apply (S.fromList "abcdefgh") 75 | 76 | partB :: [Instr] -> String 77 | partB = toList . foldl unapply (S.fromList "fbgdceah") . reverse 78 | 79 | parseInstr :: Parser Instr 80 | parseInstr = 81 | try 82 | (SwapPos <$> (string "swap position " *> num) <*> 83 | (string " with position " *> num)) <|> 84 | try 85 | (SwapLetters <$> (string "swap letter " *> anyChar) <*> 86 | (string " with letter " *> anyChar)) <|> 87 | try 88 | (Rotate <$> (string "rotate " *> direction) <*> 89 | (string " " *> num <* string " step" <* optional (char 's'))) <|> 90 | try 91 | (RotatePosition <$> 92 | (string "rotate based on position of letter " *> anyChar)) <|> 93 | try 94 | (Reverse <$> (string "reverse positions " *> num) <*> 95 | (string " through " *> num)) <|> 96 | try 97 | (Move <$> (string "move position " *> num) <*> 98 | (string " to position " *> num)) 99 | where 100 | num = read <$> many1 digit 101 | direction = 102 | (string "left" *> pure DirLeft) <|> (string "right" *> pure DirRight) 103 | 104 | main = 105 | runDay $ 106 | Day 21 (many1 (parseInstr <* newline)) (return . partA) (return . partB) 107 | -------------------------------------------------------------------------------- /src/Day22.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.List (delete) 5 | import Data.Maybe (mapMaybe, fromJust, listToMaybe) 6 | import Data.Map (Map) 7 | import qualified Data.Map as M 8 | import Control.Arrow ((&&&)) 9 | import Data.Function (on) 10 | 11 | data Pos = Pos 12 | { px :: !Int 13 | , py :: !Int 14 | } deriving (Eq, Show) 15 | 16 | instance Ord Pos where 17 | compare = compare `on` (py &&& px) 18 | 19 | data Node = Node 20 | { nPos :: !Pos 21 | , nSize :: !Int 22 | , nUsed :: !Int 23 | } deriving (Eq, Ord, Show) 24 | 25 | parseNode :: Parser Node 26 | parseNode = 27 | Node <$> 28 | (Pos <$> (string "/dev/grid/node-x" *> number) <*> (string "-y" *> number)) <*> 29 | amountCol <*> 30 | (amountCol <* manyTill anyChar newline) 31 | where 32 | number = read <$> many1 digit 33 | amountCol = many1 space *> number <* char 'T' 34 | 35 | viablePairs :: [Node] -> [(Node, Node)] 36 | viablePairs nodes = 37 | [ (n1, n2) 38 | | n1 <- nodes 39 | , n2 <- delete n1 nodes 40 | , viable n1 n2 ] 41 | 42 | viable :: Node -> Node -> Bool 43 | viable n1 n2 = n1 /= n2 && nUsed n1 > 0 && nUsed n1 <= (nSize n2 - nUsed n2) 44 | 45 | data Grid = Grid 46 | { gridNodes :: !(Map Pos Node) 47 | , gridBottomRight :: !Pos 48 | , gridGoalData :: !Pos 49 | } deriving (Eq, Ord) 50 | 51 | makeGrid :: [Node] -> Grid 52 | makeGrid nodes = Grid (M.fromList ((nPos &&& id) <$> nodes)) bottomRight topRight 53 | where 54 | bottomRight = maximum (nPos <$> nodes) 55 | topRight = Pos (px bottomRight) 0 56 | 57 | findNode :: Grid -> Pos -> Maybe Node 58 | findNode g p = p `M.lookup` gridNodes g 59 | 60 | neighbours :: Grid -> Node -> [Node] 61 | neighbours g (Node (Pos x y) _ _) = 62 | mapMaybe 63 | (findNode g . uncurry Pos) 64 | [(x + 1, y), (x - 1, y), (x, y - 1), (x, y + 1)] 65 | 66 | origin :: Pos 67 | origin = Pos 0 0 68 | 69 | manhattanDistance :: Pos -> Pos -> Int 70 | manhattanDistance (Pos x1 y1) (Pos x2 y2) = abs (x2 - x1) + abs (y2 - y1) 71 | 72 | partA :: [Node] -> Int 73 | partA = length . viablePairs 74 | 75 | partB :: [Node] -> (State, Int) 76 | partB nodes = head $ filter (reachedOrigin . fst) $ astar (nexts grid) initialState 77 | where 78 | reachedOrigin = (origin ==) . sGoalData 79 | initialState = State (fromJust (findEmpty grid)) (gridGoalData grid) 80 | grid = makeGrid nodes 81 | 82 | findEmpty :: Grid -> Maybe Pos 83 | findEmpty = listToMaybe . fmap nPos . filter ((== 0) . nUsed) . M.elems . gridNodes 84 | 85 | data State = State 86 | { sEmpty :: !Pos 87 | , sGoalData :: !Pos 88 | } deriving (Eq, Ord, Show) 89 | 90 | nexts :: Grid -> State -> [(State, Int, Int)] 91 | nexts g (State emptypos goalpos) = 92 | let empty = fromJust (findNode g emptypos) 93 | in do neighbour <- 94 | [ n 95 | | n <- neighbours g empty 96 | , nUsed n <= nSize empty ] 97 | let goalpos' = 98 | if goalpos == nPos neighbour 99 | then emptypos 100 | else goalpos 101 | empty' = nPos neighbour 102 | return 103 | ( State empty' goalpos' 104 | , 1 105 | , manhattanDistance goalpos' origin + manhattanDistance empty' goalpos' - 106 | 1) 107 | 108 | main :: IO () 109 | main = runDay day22 110 | 111 | day22 :: Day [Node] 112 | day22 = 113 | Day 114 | 22 115 | (count 2 (manyTill anyChar newline) *> many1 parseNode) 116 | (return . show . partA) 117 | (return . show . partB) 118 | -------------------------------------------------------------------------------- /src/Day23.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Control.Monad.State 5 | import Data.Maybe (fromMaybe) 6 | import Data.Map (Map) 7 | import Data.Foldable (toList) 8 | import qualified Data.Map as M 9 | import Data.Sequence (Seq) 10 | import qualified Data.Sequence as Sq 11 | 12 | newtype Reg = 13 | Reg Char 14 | deriving (Eq, Show) 15 | 16 | data Value 17 | = LitVal !Int 18 | | RegVal !Reg 19 | deriving (Eq, Show) 20 | 21 | data Instr 22 | = Copy !Value 23 | !Reg 24 | | JumpNotZero !Value 25 | !Value 26 | | Inc !Reg 27 | | Dec !Reg 28 | | Toggle !Value 29 | | Mult !Value 30 | !Value 31 | !Reg 32 | | NoOp 33 | deriving (Eq, Show) 34 | 35 | parseInstr :: Parser Instr 36 | parseInstr = 37 | (Dec <$> (string "dec " *> reg)) <|> (Inc <$> (string "inc " *> reg)) <|> 38 | (JumpNotZero <$> (string "jnz " *> val) <*> (string " " *> val)) <|> 39 | (Toggle <$> (string "tgl " *> val)) <|> 40 | (Copy <$> (string "cpy " *> val) <*> (string " " *> reg)) 41 | where 42 | reg = Reg <$> letter 43 | val = (RegVal <$> reg) <|> (LitVal <$> num) 44 | num = do 45 | sign <- option '+' (char '-') 46 | digits <- many1 digit 47 | return $ 48 | (if sign == '-' 49 | then -1 50 | else 1) * 51 | read digits 52 | 53 | data SimState = SimState 54 | { stPos :: Int 55 | , stRegs :: Map Char Int 56 | , stInstrs :: Seq Instr 57 | } 58 | 59 | instance Show SimState where 60 | show (SimState pos regs instrs) = 61 | unlines (show regs : toList (Sq.mapWithIndex showins instrs)) 62 | where 63 | showins n i = 64 | show n ++ 65 | (if n == pos 66 | then ">> " 67 | else " ") ++ 68 | show i 69 | 70 | type Sim = (State SimState) 71 | 72 | run :: Sim () 73 | run = do 74 | ran <- runNext 75 | when ran run 76 | 77 | runNext :: Sim Bool 78 | runNext = do 79 | pos <- gets stPos 80 | nextInstrs <- Sq.take 6 . Sq.drop pos <$> gets stInstrs 81 | if Sq.null nextInstrs 82 | then return False 83 | else do 84 | step <- 85 | if nextInstrs == multPattern 86 | then runMult 87 | else runInstr (nextInstrs `Sq.index` 0) 88 | modify 89 | (\st -> 90 | st 91 | { stPos = stPos st + step 92 | }) 93 | return True 94 | 95 | modifyReg :: Reg -> (Int -> Int) -> Sim () 96 | modifyReg r@(Reg n) f = do 97 | prev <- getReg r 98 | modify 99 | (\st -> 100 | let regs = stRegs st 101 | in st 102 | { stRegs = M.insert n (f prev) regs 103 | }) 104 | 105 | getReg :: Reg -> Sim Int 106 | getReg (Reg n) = (fromMaybe 0 . M.lookup n) <$> gets stRegs 107 | 108 | getVal :: Value -> Sim Int 109 | getVal (LitVal v) = return v 110 | getVal (RegVal r) = getReg r 111 | 112 | runMult :: Sim Int 113 | runMult = do 114 | void $ runInstr (Mult (RegVal (Reg 'b')) (RegVal (Reg 'd')) (Reg 'a')) 115 | void $ runInstr (Copy (LitVal 0) (Reg 'c')) 116 | void $ runInstr (Copy (LitVal 0) (Reg 'd')) 117 | return 6 118 | 119 | multPattern :: Seq Instr 120 | multPattern = 121 | Sq.fromList 122 | [ Copy (RegVal (Reg 'b')) (Reg 'c') 123 | , Inc (Reg 'a') 124 | , Dec (Reg 'c') 125 | , JumpNotZero (RegVal (Reg 'c')) (LitVal (-2)) 126 | , Dec (Reg 'd') 127 | , JumpNotZero (RegVal (Reg 'd')) (LitVal (-5)) 128 | ] 129 | 130 | runInstr :: Instr -> Sim Int 131 | runInstr (Copy val reg) = (getVal val >>= modifyReg reg . const) >> return 1 132 | runInstr (JumpNotZero val1 val2) = do 133 | v <- getVal val1 134 | v2 <- getVal val2 135 | return $ 136 | if v /= 0 137 | then v2 138 | else 1 139 | runInstr (Inc reg) = modifyReg reg (+ 1) >> return 1 140 | runInstr (Dec reg) = modifyReg reg (\i -> i - 1) >> return 1 141 | runInstr (Toggle val) = do 142 | offset <- getVal val 143 | pos <- gets stPos 144 | toggleInstrAt (pos + offset) 145 | return 1 146 | runInstr NoOp = return 1 147 | runInstr (Mult val1 val2 reg) = do 148 | v1 <- getVal val1 149 | v2 <- getVal val2 150 | modifyReg reg (const (v1 * v2)) 151 | return 1 152 | 153 | toggleInstrAt :: Int -> Sim () 154 | toggleInstrAt pos = 155 | modify 156 | (\s -> 157 | s 158 | { stInstrs = Sq.adjust toggleInstr pos (stInstrs s) 159 | }) 160 | 161 | toggleInstr :: Instr -> Instr 162 | toggleInstr NoOp = error "toggling no-op" 163 | toggleInstr (Copy val reg) = JumpNotZero val (RegVal reg) 164 | toggleInstr (JumpNotZero val1 (RegVal val2)) = Copy val1 val2 165 | toggleInstr (Inc reg) = Dec reg 166 | toggleInstr (Dec reg) = Inc reg 167 | toggleInstr (Toggle (RegVal reg)) = Inc reg 168 | toggleInstr _ = NoOp 169 | 170 | finalA :: Map Char Int -> [Instr] -> Int 171 | finalA regs instrs = 172 | (M.! 'a') $ stRegs $ execState run (SimState 0 regs (Sq.fromList instrs)) 173 | 174 | partA :: [Instr] -> Int 175 | partA = finalA (M.singleton 'a' 7) 176 | 177 | partB :: [Instr] -> Int 178 | partB = finalA (M.singleton 'a' 12) 179 | 180 | main :: IO () 181 | main = runDay day23 182 | 183 | day23 :: Day [Instr] 184 | day23 = 185 | Day 186 | 23 187 | (many (parseInstr <* newline)) 188 | (return . show . partA) 189 | (return . show . partB) 190 | -------------------------------------------------------------------------------- /src/Day24.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.Monoid ((<>)) 5 | import Control.Monad (guard) 6 | import Data.Map (Map) 7 | import qualified Data.Map as M 8 | import Data.Maybe (fromJust) 9 | import Data.Function (on) 10 | import Data.List (find, sort, permutations, minimumBy) 11 | import Control.Arrow ((&&&)) 12 | 13 | data Pos = Pos 14 | { px :: Int 15 | , py :: Int 16 | } deriving (Eq, Ord, Show) 17 | 18 | data Grid = Grid 19 | { gSquares :: Map Pos Square 20 | , gGoals :: [(Int, Pos)] 21 | } 22 | 23 | data Square 24 | = Wall 25 | | Open 26 | | Goal Int 27 | deriving (Eq) 28 | 29 | goalPos :: Grid -> Int -> Maybe Pos 30 | goalPos g n = lookup n (gGoals g) 31 | 32 | goalPositions :: Grid -> [Pos] 33 | goalPositions = map snd . gGoals 34 | 35 | type Path = [Pos] 36 | 37 | squareAt :: Grid -> Pos -> Maybe Square 38 | squareAt g p = p `M.lookup` gSquares g 39 | 40 | manhattanDist :: Pos -> Pos -> Int 41 | manhattanDist p1 p2 = abs (px p2 - px p1) + abs (py p2 - py p1) 42 | 43 | shortestPathFrom :: Grid -> Pos -> Pos -> Maybe Path 44 | shortestPathFrom g start dest = 45 | fst <$> find ((dest ==) . head . fst) (astarOn head nexts [start]) 46 | where 47 | nexts path@(x:_) = 48 | [ (n : path, 1, manhattanDist n dest) 49 | | n <- openNeighbours g x ] 50 | nexts _ = error "empty path" 51 | 52 | openNeighbours :: Grid -> Pos -> [Pos] 53 | openNeighbours g (Pos x y) = do 54 | p' <- [Pos (x - 1) y, Pos (x + 1) y, Pos x (y - 1), Pos x (y + 1)] 55 | let Just s = squareAt g p' 56 | guard (s /= Wall) 57 | return p' 58 | 59 | makeGrid :: [[Square]] -> Grid 60 | makeGrid sqs = Grid squareMap goals 61 | where 62 | goals = 63 | sort 64 | [ (n, p) 65 | | (p, Goal n) <- M.toList squareMap ] 66 | squareMap = 67 | M.fromList 68 | [ (Pos x y, sq) 69 | | (y, row) <- zip [0 ..] sqs 70 | , (x, sq) <- zip [0 ..] row ] 71 | 72 | parseGrid :: Parser Grid 73 | parseGrid = makeGrid <$> many1 (many1 square <* newline) 74 | where 75 | square = 76 | (char '#' *> pure Wall) <|> (char '.' *> pure Open) <|> 77 | (Goal . read <$> count 1 digit) 78 | 79 | main :: IO () 80 | main = runDay day24 81 | 82 | shortestVariation :: Grid 83 | -> ([(Int, Pos)] -> [[(Int, Pos)]]) 84 | -> ([(Int, Pos)], Int) 85 | shortestVariation g goalVariations = 86 | minimumBy (compare `on` snd) ((id &&& distance) <$> goalVariations goals) 87 | where 88 | distance gs = sum ((fromJust . (`lookup` distances)) <$> zip gs (drop 1 gs)) 89 | goals = gGoals g 90 | distances = 91 | [ ((start, dest), length path - 1) 92 | | start <- goals 93 | , dest <- goals 94 | , start /= dest 95 | , let Just path = shortestPathFrom g (snd start) (snd dest) ] 96 | 97 | partA :: Grid -> ([(Int, Pos)], Int) 98 | partA g = shortestVariation g makePaths 99 | where 100 | makePaths goals = (take 1 goals ++) <$> permutations (drop 1 goals) 101 | 102 | partB :: Grid -> ([(Int, Pos)], Int) 103 | partB g = shortestVariation g makePaths 104 | where 105 | makePaths goals = 106 | (\middle -> first <> middle <> first) <$> permutations (drop 1 goals) 107 | where 108 | first = take 1 goals 109 | 110 | day24 :: Day Grid 111 | day24 = Day 24 parseGrid (return . show . partA) (return . show . partB) 112 | -------------------------------------------------------------------------------- /src/Day25.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Control.Monad.State 5 | import Data.Maybe (fromMaybe) 6 | import Data.Map (Map) 7 | import Data.Foldable (toList) 8 | import Data.List (find) 9 | import qualified Data.Map as M 10 | import Data.Sequence (Seq) 11 | import qualified Data.Sequence as Sq 12 | 13 | newtype Reg = 14 | Reg Char 15 | deriving (Eq, Show) 16 | 17 | data Value 18 | = LitVal !Int 19 | | RegVal !Reg 20 | deriving (Eq, Show) 21 | 22 | data Instr 23 | = Copy !Value 24 | !Reg 25 | | JumpNotZero !Value 26 | !Value 27 | | Inc !Reg 28 | | Dec !Reg 29 | | Toggle !Value 30 | | Mult !Value 31 | !Value 32 | !Reg 33 | | NoOp 34 | | Out !Value 35 | deriving (Eq, Show) 36 | 37 | parseInstr :: Parser Instr 38 | parseInstr = 39 | (Dec <$> (string "dec " *> reg)) <|> (Inc <$> (string "inc " *> reg)) <|> 40 | (JumpNotZero <$> (string "jnz " *> val) <*> (string " " *> val)) <|> 41 | (Toggle <$> (string "tgl " *> val)) <|> 42 | (Copy <$> (string "cpy " *> val) <*> (string " " *> reg)) <|> 43 | (Out <$> (string "out " *> val)) 44 | where 45 | reg = Reg <$> letter 46 | val = (RegVal <$> reg) <|> (LitVal <$> num) 47 | num = do 48 | sign <- option '+' (char '-') 49 | digits <- many1 digit 50 | return $ 51 | (if sign == '-' 52 | then -1 53 | else 1) * 54 | read digits 55 | 56 | data SimState = SimState 57 | { stPos :: Int 58 | , stRegs :: Map Char Int 59 | , stInstrs :: Seq Instr 60 | , stOutput :: Seq Int 61 | , stFinished :: SimState -> Bool 62 | } 63 | 64 | instance Show SimState where 65 | show (SimState pos regs instrs output _) = 66 | unlines (show regs : show output : toList (Sq.mapWithIndex showins instrs)) 67 | where 68 | showins n i = 69 | show n ++ 70 | (if n == pos 71 | then ">> " 72 | else " ") ++ 73 | show i 74 | 75 | type Sim = (State SimState) 76 | 77 | run :: Sim () 78 | run = do 79 | ran <- runNext 80 | when ran run 81 | 82 | runNext :: Sim Bool 83 | runNext = do 84 | pos <- gets stPos 85 | finished <- checkFinished 86 | nextInstrs <- Sq.take 6 . Sq.drop pos <$> gets stInstrs 87 | if Sq.null nextInstrs || finished 88 | then return False 89 | else do 90 | step <- 91 | if nextInstrs == multPattern 92 | then runMult 93 | else runInstr (nextInstrs `Sq.index` 0) 94 | modify 95 | (\st -> 96 | st 97 | { stPos = stPos st + step 98 | }) 99 | return True 100 | 101 | checkFinished :: Sim Bool 102 | checkFinished = do 103 | checker <- gets stFinished 104 | st <- get 105 | return (checker st) 106 | 107 | modifyReg :: Reg -> (Int -> Int) -> Sim () 108 | modifyReg r@(Reg n) f = do 109 | prev <- getReg r 110 | modify 111 | (\st -> 112 | let regs = stRegs st 113 | in st 114 | { stRegs = M.insert n (f prev) regs 115 | }) 116 | 117 | getReg :: Reg -> Sim Int 118 | getReg (Reg n) = (fromMaybe 0 . M.lookup n) <$> gets stRegs 119 | 120 | getVal :: Value -> Sim Int 121 | getVal (LitVal v) = return v 122 | getVal (RegVal r) = getReg r 123 | 124 | runMult :: Sim Int 125 | runMult = do 126 | void $ runInstr (Mult (RegVal (Reg 'b')) (RegVal (Reg 'd')) (Reg 'a')) 127 | void $ runInstr (Copy (LitVal 0) (Reg 'c')) 128 | void $ runInstr (Copy (LitVal 0) (Reg 'd')) 129 | return 6 130 | 131 | multPattern :: Seq Instr 132 | multPattern = 133 | Sq.fromList 134 | [ Copy (RegVal (Reg 'b')) (Reg 'c') 135 | , Inc (Reg 'a') 136 | , Dec (Reg 'c') 137 | , JumpNotZero (RegVal (Reg 'c')) (LitVal (-2)) 138 | , Dec (Reg 'd') 139 | , JumpNotZero (RegVal (Reg 'd')) (LitVal (-5)) 140 | ] 141 | 142 | runInstr :: Instr -> Sim Int 143 | runInstr (Copy val reg) = (getVal val >>= modifyReg reg . const) >> return 1 144 | runInstr (JumpNotZero val1 val2) = do 145 | v <- getVal val1 146 | v2 <- getVal val2 147 | return $ 148 | if v /= 0 149 | then v2 150 | else 1 151 | runInstr (Inc reg) = modifyReg reg (+ 1) >> return 1 152 | runInstr (Dec reg) = modifyReg reg (\i -> i - 1) >> return 1 153 | runInstr (Toggle val) = do 154 | offset <- getVal val 155 | pos <- gets stPos 156 | toggleInstrAt (pos + offset) 157 | return 1 158 | runInstr NoOp = return 1 159 | runInstr (Mult val1 val2 reg) = do 160 | v1 <- getVal val1 161 | v2 <- getVal val2 162 | modifyReg reg (const (v1 * v2)) 163 | return 1 164 | runInstr (Out val) = do 165 | v <- getVal val 166 | modify 167 | (\s -> 168 | s 169 | { stOutput = stOutput s Sq.|> v 170 | }) 171 | return 1 172 | 173 | toggleInstrAt :: Int -> Sim () 174 | toggleInstrAt pos = 175 | modify 176 | (\s -> 177 | s 178 | { stInstrs = Sq.adjust toggleInstr pos (stInstrs s) 179 | }) 180 | 181 | toggleInstr :: Instr -> Instr 182 | toggleInstr NoOp = error "toggling no-op" 183 | toggleInstr (Copy val reg) = JumpNotZero val (RegVal reg) 184 | toggleInstr (JumpNotZero val1 (RegVal val2)) = Copy val1 val2 185 | toggleInstr (Inc reg) = Dec reg 186 | toggleInstr (Dec reg) = Inc reg 187 | toggleInstr (Toggle (RegVal reg)) = Inc reg 188 | toggleInstr _ = NoOp 189 | 190 | runSim :: (SimState -> Bool) -> Map Char Int -> [Instr] -> SimState 191 | runSim done regs instrs = 192 | execState run (SimState 0 regs (Sq.fromList instrs) Sq.empty done) 193 | 194 | partA :: [Instr] -> Maybe Int 195 | partA instrs = find ((target ==) . stOutput . runA) [0 ..] 196 | where 197 | runA a = runSim done (M.singleton 'a' a) instrs 198 | done s = 199 | let output = stOutput s 200 | outlen = Sq.length output 201 | in (output /= Sq.take outlen target) || outlen >= Sq.length target 202 | target = Sq.fromList (take 100 (cycle [0, 1])) 203 | 204 | main :: IO () 205 | main = runDay day25 206 | 207 | day25 :: Day [Instr] 208 | day25 = 209 | Day 210 | 25 211 | (many (parseInstr <* newline)) 212 | (return . show . partA) 213 | (return . show . const "TODO") 214 | -------------------------------------------------------------------------------- /src/Day3.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.List (transpose, splitAt) 5 | 6 | data Triangle = 7 | Triangle Int 8 | Int 9 | Int 10 | 11 | possible :: Triangle -> Bool 12 | possible (Triangle a b c) = 13 | all valid $ zip3 sides (drop 1 $ cycle sides) (drop 2 $ cycle sides) 14 | where 15 | sides = [a, b, c] 16 | valid (s1, s2, s3) = s1 + s2 > s3 17 | 18 | spaceNumber :: Parser Int 19 | spaceNumber = spaces *> parseInt 20 | where 21 | parseInt = read <$> many1 digit 22 | 23 | groupsOf :: Int -> [a] -> [[a]] 24 | groupsOf = go [] 25 | where 26 | go acc _ [] = acc 27 | go acc n xs = go (before : acc) n after 28 | where 29 | (before, after) = splitAt n xs 30 | 31 | toTriangle [a, b, c] = Triangle a b c 32 | 33 | main = 34 | runDay $ 35 | Day 36 | 3 37 | (many1 (count 3 spaceNumber <* newline)) 38 | (return . show . length . filter possible . fmap toTriangle) 39 | (return . 40 | show . length . filter possible . fmap toTriangle . groupsOf 3 . concat . transpose) 41 | -------------------------------------------------------------------------------- /src/Day4.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.List (group, sort, sortBy) 5 | 6 | data Room = Room 7 | { encName :: [String] 8 | , sectorID :: Int 9 | , checksum :: String 10 | } deriving (Show) 11 | 12 | real :: Room -> Bool 13 | real room = checksum room == calcChecksum room 14 | 15 | decrypt :: Room -> String 16 | decrypt room = unwords $ decryptWord <$> encName room 17 | where 18 | decryptWord = map rotateLetter 19 | rotateLetter l = ([l .. 'z'] ++ ['a' ..]) !! (sectorID room `mod` 26) 20 | 21 | calcChecksum :: Room -> String 22 | calcChecksum = take 5 . map snd . sortBy comparison . hist 23 | where 24 | hist = map (\s@(c:_) -> (length s, c)) . group . sort . concat . encName 25 | comparison (l1, c1) (l2, c2) = 26 | case compare l2 l1 of 27 | EQ -> compare c1 c2 28 | x -> x 29 | 30 | example = Room ["aaaaa", "bbb", "z", "y", "x"] 123 "abxyz" 31 | 32 | example2 = Room ["qzmt", "zixmtkozy", "ivhz"] 343 "abxyz" 33 | 34 | parseRoom :: Parser Room 35 | parseRoom = 36 | Room <$> many1 (many1 letter <* string "-") <*> parseInt <*> 37 | (string "[" *> many1 letter <* string "]") 38 | where 39 | parseInt = read <$> many1 digit 40 | 41 | main = 42 | runDay $ 43 | Day 44 | 4 45 | (many1 (parseRoom <* newline)) 46 | (return . show . sum . fmap sectorID . filter real) 47 | (return . 48 | show . filter (("northpole object storage" ==) . decrypt) . filter real) 49 | -------------------------------------------------------------------------------- /src/Day5.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Crypto.Hash 5 | import Data.ByteString (ByteString) 6 | import qualified Data.Map as M 7 | import Data.Maybe (catMaybes) 8 | import Data.String (fromString) 9 | 10 | hashes :: String -> [String] 11 | hashes seed = hexMD5 . (seed ++) . show <$> [(0 :: Integer) ..] 12 | 13 | hexMD5 :: String -> String 14 | hexMD5 = show . md5 . fromString 15 | where 16 | md5 :: ByteString -> Digest MD5 17 | md5 = hash 18 | 19 | interesting :: String -> Bool 20 | interesting s = "00000" == take 5 s 21 | 22 | interestingHashes :: String -> [String] 23 | interestingHashes seed = filter interesting (hashes seed) 24 | 25 | solutionA :: [String] -> String 26 | solutionA hs = take 8 $ (!! 5) <$> hs 27 | 28 | solutionB :: [String] -> String 29 | solutionB hs = M.elems $ head $ dropWhile incomplete $ scanl addPair M.empty pairs 30 | where 31 | addPair m (p, c) = 32 | if p `M.member` m 33 | then m 34 | else M.insert p c m 35 | incomplete m = M.keys m /= "01234567" 36 | pairs = catMaybes $ (posAndChar . drop 5) <$> hs 37 | posAndChar (p:c:_) 38 | | p >= '0' && p < '8' = Just (p, c) 39 | posAndChar _ = Nothing 40 | 41 | main = 42 | runDay $ 43 | Day 44 | 5 45 | (many1 letter <* newline) 46 | (return . solutionA . hashes) 47 | (return . solutionB . hashes) 48 | -------------------------------------------------------------------------------- /src/Day6.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.List (sort, group, transpose) 5 | import Control.Arrow ((&&&)) 6 | 7 | decode :: ([(Int, Char)] -> (Int, Char)) -> [String] -> String 8 | decode chooser = map ((snd . chooser) . column) . transpose 9 | where 10 | column = map (length &&& head) . group . sort 11 | 12 | decodeMostFrequent :: [String] -> String 13 | decodeMostFrequent = decode maximum 14 | 15 | decodeLeastFrequent :: [String] -> String 16 | decodeLeastFrequent = decode minimum 17 | 18 | main = 19 | runDay $ 20 | Day 21 | 6 22 | (many1 (many1 letter <* newline)) 23 | (return . decodeMostFrequent) 24 | (return . decodeLeastFrequent) 25 | -------------------------------------------------------------------------------- /src/Day7.hs: -------------------------------------------------------------------------------- 1 | {-# LANGUAGE TupleSections #-} 2 | 3 | module Main where 4 | 5 | import AdventOfCode 6 | import Data.List (partition, isInfixOf) 7 | 8 | data Net 9 | = Super 10 | | Hyper 11 | 12 | newtype IPAddress = 13 | IPAddress [(Net, String)] 14 | 15 | abba :: String -> Bool 16 | abba (a:b:c:d:_) 17 | | a /= b && a == d && b == c = True 18 | abba (_:xs) = abba xs 19 | abba _ = False 20 | 21 | canTLS :: IPAddress -> Bool 22 | canTLS (IPAddress parts) = abbas super && not (abbas hyper) 23 | where 24 | abbas = any abba . fmap snd 25 | (super, hyper) = partition supernet parts 26 | supernet (Super, _) = True 27 | supernet _ = False 28 | 29 | canSSL :: IPAddress -> Bool 30 | canSSL (IPAddress parts) = 31 | or 32 | [ [b, a, b] `isInfixOf` hyper 33 | | (Super, super) <- parts 34 | , [a, b, _] <- abas super 35 | , (Hyper, hyper) <- parts ] 36 | 37 | abas :: String -> [String] 38 | abas = go [] 39 | where 40 | go acc s@(a:b:c:_) 41 | | a /= b && a == c = go ([a, b, c] : acc) (drop 1 s) 42 | go acc (_:xs) = go acc xs 43 | go acc _ = acc 44 | 45 | parseIPAddress :: Parser IPAddress 46 | parseIPAddress = 47 | IPAddress <$> 48 | many1 49 | (((Super, ) <$> many1 letter) <|> 50 | ((Hyper, ) <$> (string "[" *> many1 letter <* string "]"))) 51 | 52 | main = 53 | runDay $ 54 | Day 55 | 7 56 | (many1 (parseIPAddress <* newline)) 57 | (return . show . length . filter canTLS) 58 | (return . show . length . filter canSSL) 59 | -------------------------------------------------------------------------------- /src/Day8.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | import Data.Set (Set) 5 | import qualified Data.Set as S 6 | 7 | type PixelSet = Set (Int, Int) 8 | 9 | data Screen = Screen 10 | { sMaxX :: Int 11 | , sMaxY :: Int 12 | , sPix :: PixelSet 13 | } 14 | 15 | instance Show Screen where 16 | show s = unlines $ map showRow [0 .. (sMaxY s - 1)] 17 | where 18 | showRow :: Int -> String 19 | showRow y = 20 | [ if (x, y) `S.member` sPix s 21 | then '#' 22 | else '.' 23 | | x <- [0 .. (sMaxX s - 1)] ] 24 | 25 | initialScreen :: Screen 26 | initialScreen = Screen 50 6 S.empty 27 | 28 | modScreen :: Screen -> (PixelSet -> PixelSet) -> Screen 29 | modScreen s f = 30 | s 31 | { sPix = f (sPix s) 32 | } 33 | 34 | applyInstruction :: Screen -> Instruction -> Screen 35 | applyInstruction s (Rect w h) = modScreen s (S.union newPix) 36 | where 37 | newPix = 38 | S.fromList 39 | [ (x, y) 40 | | x <- [0 .. (w - 1)] 41 | , y <- [0 .. (h - 1)] ] 42 | applyInstruction s (Rotate Col idx off) = modScreen s (S.map rotateCol) 43 | where 44 | rotateCol (x, y) = 45 | if x == idx 46 | then (x, (y + off) `mod` sMaxY s) 47 | else (x, y) 48 | applyInstruction s (Rotate Row idx off) = modScreen s (S.map rotateRow) 49 | where 50 | rotateRow (x, y) = 51 | if y == idx 52 | then ((x + off) `mod` sMaxX s, y) 53 | else (x, y) 54 | 55 | litPixels :: Screen -> Int 56 | litPixels = length . S.toList . sPix 57 | 58 | data Axis 59 | = Col 60 | | Row 61 | 62 | data Instruction 63 | = Rect { rectW :: Int 64 | , rectH :: Int} 65 | | Rotate { rotAxis :: Axis 66 | , rotIndex :: Int 67 | , rotOffset :: Int} 68 | 69 | parseInstruction :: Parser Instruction 70 | parseInstruction = 71 | try (Rect <$> (string "rect " *> number) <*> (string "x" *> number)) <|> 72 | (string "rotate " *> 73 | ((Rotate Col <$> (string "column x=" *> number) <*> (string " by " *> number)) <|> 74 | (Rotate Row <$> (string "row y=" *> number) <*> (string " by " *> number)))) 75 | where 76 | number = read <$> many1 digit 77 | 78 | run :: [Instruction] -> Screen 79 | run = foldl applyInstruction initialScreen 80 | 81 | main = 82 | runDay $ 83 | Day 84 | 8 85 | (many1 (parseInstruction <* newline)) 86 | (return . show . litPixels . run) 87 | (return . show . run) 88 | -------------------------------------------------------------------------------- /src/Day9.hs: -------------------------------------------------------------------------------- 1 | module Main where 2 | 3 | import AdventOfCode 4 | 5 | data Block 6 | = Repeat Int 7 | String 8 | [Block] 9 | | Plain String 10 | deriving (Show) 11 | 12 | blockLenA :: Block -> Int 13 | blockLenA (Repeat n s _) = n * length s 14 | blockLenA (Plain s) = length s 15 | 16 | blockLenB :: Block -> Int 17 | blockLenB (Repeat n _ bs) = n * sum (blockLenB <$> bs) 18 | blockLenB (Plain s) = length s 19 | 20 | parseBlock :: Parser Block 21 | parseBlock = try parseRepeat <|> (Plain <$> many1 letter) 22 | where 23 | parseRepeat = do 24 | len <- char '(' *> number <* char 'x' 25 | mult <- number <* char ')' 26 | rest <- count len anyChar 27 | case runP (many parseBlock <* eof) () "block" rest of 28 | Right subBlocks -> pure $ Repeat mult rest subBlocks 29 | Left err -> fail (show err) 30 | number = read <$> many1 digit 31 | 32 | main = 33 | runDay $ 34 | Day 35 | 9 36 | (many1 parseBlock <* newline) 37 | (return . show . sum . fmap blockLenA) 38 | (return . show . sum . fmap blockLenB) 39 | -------------------------------------------------------------------------------- /stack.yaml: -------------------------------------------------------------------------------- 1 | # This file was automatically generated by 'stack init' 2 | # 3 | # Some commonly used options have been documented as comments in this file. 4 | # For advanced use and comprehensive documentation of the format, please see: 5 | # http://docs.haskellstack.org/en/stable/yaml_configuration/ 6 | 7 | # Resolver to choose a 'specific' stackage snapshot or a compiler version. 8 | # A snapshot resolver dictates the compiler version and the set of packages 9 | # to be used for project dependencies. For example: 10 | # 11 | # resolver: lts-3.5 12 | # resolver: nightly-2015-09-21 13 | # resolver: ghc-7.10.2 14 | # resolver: ghcjs-0.1.0_ghc-7.10.2 15 | # resolver: 16 | # name: custom-snapshot 17 | # location: "./custom-snapshot.yaml" 18 | resolver: lts-9.5 19 | 20 | # User packages to be built. 21 | # Various formats can be used as shown in the example below. 22 | # 23 | # packages: 24 | # - some-directory 25 | # - https://example.com/foo/bar/baz-0.0.2.tar.gz 26 | # - location: 27 | # git: https://github.com/commercialhaskell/stack.git 28 | # commit: e7b331f14bcffb8367cd58fbfc8b40ec7642100a 29 | # - location: https://github.com/commercialhaskell/stack/commit/e7b331f14bcffb8367cd58fbfc8b40ec7642100a 30 | # extra-dep: true 31 | # subdirs: 32 | # - auto-update 33 | # - wai 34 | # 35 | # A package marked 'extra-dep: true' will only be built if demanded by a 36 | # non-dependency (i.e. a user package), and its test suites and benchmarks 37 | # will not be run. This is useful for tweaking upstream packages. 38 | packages: 39 | - '.' 40 | # Dependency packages to be pulled from upstream that are not in the resolver 41 | # (e.g., acme-missiles-0.3) 42 | extra-deps: [] 43 | 44 | # Override default flag values for local packages and extra-deps 45 | flags: {} 46 | 47 | # Extra package databases containing global packages 48 | extra-package-dbs: [] 49 | 50 | # Control whether we use the GHC we find on the path 51 | # system-ghc: true 52 | # 53 | # Require a specific version of stack, using version ranges 54 | # require-stack-version: -any # Default 55 | # require-stack-version: ">=1.1" 56 | # 57 | # Override the architecture used by stack, especially useful on Windows 58 | # arch: i386 59 | # arch: x86_64 60 | # 61 | # Extra directories used by stack for building 62 | # extra-include-dirs: [/path/to/dir] 63 | # extra-lib-dirs: [/path/to/dir] 64 | # 65 | # Allow a newer minor version of GHC than the snapshot specifies 66 | # compiler-check: newer-minor 67 | --------------------------------------------------------------------------------