├── .gitignore ├── LICENSE ├── README.md ├── doc ├── day1.md └── intro.md ├── project.clj ├── resources ├── 2017 │ ├── day01 │ ├── day02 │ ├── day04 │ ├── day05 │ ├── day06 │ ├── day07 │ ├── day08 │ ├── day09 │ ├── day11 │ ├── day12 │ ├── day13 │ ├── day16 │ ├── day18 │ ├── day19 │ ├── day20 │ ├── day21 │ ├── day22 │ ├── day23 │ ├── day24 │ └── day25 ├── day1 ├── day10 ├── day12 ├── day2 ├── day20 ├── day21 ├── day22 ├── day23 ├── day24 ├── day25 ├── day3 ├── day4 ├── day6 ├── day7 ├── day8 └── day9 ├── src ├── advent_of_clojure_2016 │ ├── core.clj │ ├── day1.clj │ ├── day10.clj │ ├── day11.clj │ ├── day12.clj │ ├── day13.clj │ ├── day14.clj │ ├── day15.clj │ ├── day16.clj │ ├── day17.clj │ ├── day18.clj │ ├── day19.clj │ ├── day2.clj │ ├── day20.clj │ ├── day21.clj │ ├── day22.clj │ ├── day23.clj │ ├── day24.clj │ ├── day25.clj │ ├── day3.clj │ ├── day4.clj │ ├── day5.clj │ ├── day6.clj │ ├── day7.clj │ ├── day8.clj │ ├── day9.clj │ └── utils.clj └── advent_of_clojure_2017 │ ├── day01.clj │ ├── day02.clj │ ├── day03.clj │ ├── day04.clj │ ├── day05.clj │ ├── day06.clj │ ├── day07.clj │ ├── day08.clj │ ├── day09.clj │ ├── day10.clj │ ├── day11.clj │ ├── day12.clj │ ├── day13.clj │ ├── day14.clj │ ├── day15.clj │ ├── day16.clj │ ├── day17.clj │ ├── day18.clj │ ├── day19.clj │ ├── day20.clj │ ├── day21.clj │ ├── day22.clj │ ├── day23.clj │ ├── day24.clj │ └── day25.clj └── test └── advent_of_clojure_2016 └── core_test.clj /.gitignore: -------------------------------------------------------------------------------- 1 | resources/public 2 | /target 3 | /classes 4 | /checkouts 5 | pom.xml 6 | pom.xml.asc 7 | *.jar 8 | *.class 9 | /.lein-* 10 | /.nrepl-port 11 | .hgignore 12 | .hg/ 13 | .\#* 14 | 15 | resources/day22.cjmurphy 16 | figwheel_server.log 17 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC 2 | LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM 3 | CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. 4 | 5 | 1. DEFINITIONS 6 | 7 | "Contribution" means: 8 | 9 | a) in the case of the initial Contributor, the initial code and 10 | documentation distributed under this Agreement, and 11 | 12 | b) in the case of each subsequent Contributor: 13 | 14 | i) changes to the Program, and 15 | 16 | ii) additions to the Program; 17 | 18 | where such changes and/or additions to the Program originate from and are 19 | distributed by that particular Contributor. A Contribution 'originates' from 20 | a Contributor if it was added to the Program by such Contributor itself or 21 | anyone acting on such Contributor's behalf. Contributions do not include 22 | additions to the Program which: (i) are separate modules of software 23 | distributed in conjunction with the Program under their own license 24 | agreement, and (ii) are not derivative works of the Program. 25 | 26 | "Contributor" means any person or entity that distributes the Program. 27 | 28 | "Licensed Patents" mean patent claims licensable by a Contributor which are 29 | necessarily infringed by the use or sale of its Contribution alone or when 30 | combined with the Program. 31 | 32 | "Program" means the Contributions distributed in accordance with this 33 | Agreement. 34 | 35 | "Recipient" means anyone who receives the Program under this Agreement, 36 | including all Contributors. 37 | 38 | 2. GRANT OF RIGHTS 39 | 40 | a) Subject to the terms of this Agreement, each Contributor hereby grants 41 | Recipient a non-exclusive, worldwide, royalty-free copyright license to 42 | reproduce, prepare derivative works of, publicly display, publicly perform, 43 | distribute and sublicense the Contribution of such Contributor, if any, and 44 | such derivative works, in source code and object code form. 45 | 46 | b) Subject to the terms of this Agreement, each Contributor hereby grants 47 | Recipient a non-exclusive, worldwide, royalty-free patent license under 48 | Licensed Patents to make, use, sell, offer to sell, import and otherwise 49 | transfer the Contribution of such Contributor, if any, in source code and 50 | object code form. This patent license shall apply to the combination of the 51 | Contribution and the Program if, at the time the Contribution is added by the 52 | Contributor, such addition of the Contribution causes such combination to be 53 | covered by the Licensed Patents. The patent license shall not apply to any 54 | other combinations which include the Contribution. No hardware per se is 55 | licensed hereunder. 56 | 57 | c) Recipient understands that although each Contributor grants the licenses 58 | to its Contributions set forth herein, no assurances are provided by any 59 | Contributor that the Program does not infringe the patent or other 60 | intellectual property rights of any other entity. Each Contributor disclaims 61 | any liability to Recipient for claims brought by any other entity based on 62 | infringement of intellectual property rights or otherwise. As a condition to 63 | exercising the rights and licenses granted hereunder, each Recipient hereby 64 | assumes sole responsibility to secure any other intellectual property rights 65 | needed, if any. For example, if a third party patent license is required to 66 | allow Recipient to distribute the Program, it is Recipient's responsibility 67 | to acquire that license before distributing the Program. 68 | 69 | d) Each Contributor represents that to its knowledge it has sufficient 70 | copyright rights in its Contribution, if any, to grant the copyright license 71 | set forth in this Agreement. 72 | 73 | 3. REQUIREMENTS 74 | 75 | A Contributor may choose to distribute the Program in object code form under 76 | its own license agreement, provided that: 77 | 78 | a) it complies with the terms and conditions of this Agreement; and 79 | 80 | b) its license agreement: 81 | 82 | i) effectively disclaims on behalf of all Contributors all warranties and 83 | conditions, express and implied, including warranties or conditions of title 84 | and non-infringement, and implied warranties or conditions of merchantability 85 | and fitness for a particular purpose; 86 | 87 | ii) effectively excludes on behalf of all Contributors all liability for 88 | damages, including direct, indirect, special, incidental and consequential 89 | damages, such as lost profits; 90 | 91 | iii) states that any provisions which differ from this Agreement are offered 92 | by that Contributor alone and not by any other party; and 93 | 94 | iv) states that source code for the Program is available from such 95 | Contributor, and informs licensees how to obtain it in a reasonable manner on 96 | or through a medium customarily used for software exchange. 97 | 98 | When the Program is made available in source code form: 99 | 100 | a) it must be made available under this Agreement; and 101 | 102 | b) a copy of this Agreement must be included with each copy of the Program. 103 | 104 | Contributors may not remove or alter any copyright notices contained within 105 | the Program. 106 | 107 | Each Contributor must identify itself as the originator of its Contribution, 108 | if any, in a manner that reasonably allows subsequent Recipients to identify 109 | the originator of the Contribution. 110 | 111 | 4. COMMERCIAL DISTRIBUTION 112 | 113 | Commercial distributors of software may accept certain responsibilities with 114 | respect to end users, business partners and the like. While this license is 115 | intended to facilitate the commercial use of the Program, the Contributor who 116 | includes the Program in a commercial product offering should do so in a 117 | manner which does not create potential liability for other Contributors. 118 | Therefore, if a Contributor includes the Program in a commercial product 119 | offering, such Contributor ("Commercial Contributor") hereby agrees to defend 120 | and indemnify every other Contributor ("Indemnified Contributor") against any 121 | losses, damages and costs (collectively "Losses") arising from claims, 122 | lawsuits and other legal actions brought by a third party against the 123 | Indemnified Contributor to the extent caused by the acts or omissions of such 124 | Commercial Contributor in connection with its distribution of the Program in 125 | a commercial product offering. The obligations in this section do not apply 126 | to any claims or Losses relating to any actual or alleged intellectual 127 | property infringement. In order to qualify, an Indemnified Contributor must: 128 | a) promptly notify the Commercial Contributor in writing of such claim, and 129 | b) allow the Commercial Contributor to control, and cooperate with the 130 | Commercial Contributor in, the defense and any related settlement 131 | negotiations. The Indemnified Contributor may participate in any such claim 132 | at its own expense. 133 | 134 | For example, a Contributor might include the Program in a commercial product 135 | offering, Product X. That Contributor is then a Commercial Contributor. If 136 | that Commercial Contributor then makes performance claims, or offers 137 | warranties related to Product X, those performance claims and warranties are 138 | such Commercial Contributor's responsibility alone. Under this section, the 139 | Commercial Contributor would have to defend claims against the other 140 | Contributors related to those performance claims and warranties, and if a 141 | court requires any other Contributor to pay any damages as a result, the 142 | Commercial Contributor must pay those damages. 143 | 144 | 5. NO WARRANTY 145 | 146 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON 147 | AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER 148 | EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR 149 | CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A 150 | PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the 151 | appropriateness of using and distributing the Program and assumes all risks 152 | associated with its exercise of rights under this Agreement , including but 153 | not limited to the risks and costs of program errors, compliance with 154 | applicable laws, damage to or loss of data, programs or equipment, and 155 | unavailability or interruption of operations. 156 | 157 | 6. DISCLAIMER OF LIABILITY 158 | 159 | EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY 160 | CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, 161 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION 162 | LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 163 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 164 | ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE 165 | EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY 166 | OF SUCH DAMAGES. 167 | 168 | 7. GENERAL 169 | 170 | If any provision of this Agreement is invalid or unenforceable under 171 | applicable law, it shall not affect the validity or enforceability of the 172 | remainder of the terms of this Agreement, and without further action by the 173 | parties hereto, such provision shall be reformed to the minimum extent 174 | necessary to make such provision valid and enforceable. 175 | 176 | If Recipient institutes patent litigation against any entity (including a 177 | cross-claim or counterclaim in a lawsuit) alleging that the Program itself 178 | (excluding combinations of the Program with other software or hardware) 179 | infringes such Recipient's patent(s), then such Recipient's rights granted 180 | under Section 2(b) shall terminate as of the date such litigation is filed. 181 | 182 | All Recipient's rights under this Agreement shall terminate if it fails to 183 | comply with any of the material terms or conditions of this Agreement and 184 | does not cure such failure in a reasonable period of time after becoming 185 | aware of such noncompliance. If all Recipient's rights under this Agreement 186 | terminate, Recipient agrees to cease use and distribution of the Program as 187 | soon as reasonably practicable. However, Recipient's obligations under this 188 | Agreement and any licenses granted by Recipient relating to the Program shall 189 | continue and survive. 190 | 191 | Everyone is permitted to copy and distribute copies of this Agreement, but in 192 | order to avoid inconsistency the Agreement is copyrighted and may only be 193 | modified in the following manner. The Agreement Steward reserves the right to 194 | publish new versions (including revisions) of this Agreement from time to 195 | time. No one other than the Agreement Steward has the right to modify this 196 | Agreement. The Eclipse Foundation is the initial Agreement Steward. The 197 | Eclipse Foundation may assign the responsibility to serve as the Agreement 198 | Steward to a suitable separate entity. Each new version of the Agreement will 199 | be given a distinguishing version number. The Program (including 200 | Contributions) may always be distributed subject to the version of the 201 | Agreement under which it was received. In addition, after a new version of 202 | the Agreement is published, Contributor may elect to distribute the Program 203 | (including its Contributions) under the new version. Except as expressly 204 | stated in Sections 2(a) and 2(b) above, Recipient receives no rights or 205 | licenses to the intellectual property of any Contributor under this 206 | Agreement, whether expressly, by implication, estoppel or otherwise. All 207 | rights in the Program not expressly granted under this Agreement are 208 | reserved. 209 | 210 | This Agreement is governed by the laws of the State of New York and the 211 | intellectual property laws of the United States of America. No party to this 212 | Agreement will bring a legal action under this Agreement more than one year 213 | after the cause of action arose. Each party waives its rights to a jury trial 214 | in any resulting litigation. 215 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Deprecated repository 2 | 3 | Please refer to the [advent_of_clojure repo](https://github.com/bhauman/advent-of-clojure) to see my [Advent of Code](http://adventofcode.com) problem solutions. 4 | 5 | 6 | -------------------------------------------------------------------------------- /doc/day1.md: -------------------------------------------------------------------------------- 1 | You're airdropped near Easter Bunny Headquarters in a city somewhere. "Near", unfortunately, is as close as you can get - the instructions on the Easter Bunny Recruiting Document the Elves intercepted start here, and nobody had time to work them out further. 2 | 3 | The Document indicates that you should start at the given coordinates (where you just landed) and face North. Then, follow the provided sequence: either turn left (L) or right (R) 90 degrees, then walk forward the given number of blocks, ending at a new intersection. 4 | 5 | There's no time to follow such ridiculous instructions on foot, though, so you take a moment and work out the destination. Given that you can only walk on the street grid of the city, how far is the shortest path to the destination? 6 | 7 | For example: 8 | 9 | Following R2, L3 leaves you 2 blocks East and 3 blocks North, or 5 blocks away. 10 | R2, R2, R2 leaves you 2 blocks due South of your starting position, which is 2 blocks away. 11 | R5, L5, R5, R3 leaves you 12 blocks away. 12 | 13 | How many blocks away is Easter Bunny HQ? 14 | 15 | -------------------------------------------------------------------------------- /doc/intro.md: -------------------------------------------------------------------------------- 1 | # Introduction to advent-of-clojure-2016 2 | 3 | TODO: write [great documentation](http://jacobian.org/writing/what-to-write/) 4 | -------------------------------------------------------------------------------- /project.clj: -------------------------------------------------------------------------------- 1 | (defproject advent-of-clojure-2016 "0.1.0-SNAPSHOT" 2 | :description "FIXME: write description" 3 | :url "http://example.com/FIXME" 4 | :license {:name "Eclipse Public License" 5 | :url "http://www.eclipse.org/legal/epl-v10.html"} 6 | :dependencies [[org.clojure/clojure "1.9.0-alpha14"] 7 | [digest "1.4.4"] 8 | [medley "0.8.4"] 9 | [criterium "0.4.4"] 10 | [net.mikera/core.matrix "0.57.0"] 11 | [org.clojure/math.combinatorics "0.1.1"] 12 | [org.clojure/core.match "0.2.2"]]) 13 | -------------------------------------------------------------------------------- /resources/2017/day01: -------------------------------------------------------------------------------- 1 | 5672987533353956199629683941564528646262567117433461547747793928322958646779832484689174151918261551689221756165598898428736782194511627829355718493723961323272136452517987471351381881946883528248611611258656199812998632682668749683588515362946994415852337196718476219162124978836537348924591957188827929753417884942133844664636969742547717228255739959316351852731598292529837885992781815131876183578461135791315287135243541659853734343376618419952776165544829717676988897684141328138348382882699672957866146524759879236555935723655326743713542931693477824289283542468639522271643257212833248165391957686226311246517978319253977276663825479144321155712866946255992634876158822855382331452649953283788863248192338245943966269197421474555779135168637263279579842885347152287275679811576594376535226167894981226866222987522415785244875882556414956724976341627123557214837873872723618395529735349273241686548287549763993653379539445435319698825465289817663294436458194867278623978745981799283789237555242728291337538498616929817268211698649236646127899982839523784837752863458819965485149812959121884771849954723259365778151788719941888128618552455879369919511319735525621198185634342538848462461833332917986297445388515717463168515123732455576143447454835849565757773325367469763383757677938748319968971312267871619951657267913817242485559771582167295794259441256284168356292785568858527184122231262465193612127961685513913835274823892596923786613299747347259254823531262185328274367529265868856512185135329652635938373266759964119863494798222245536758792389789818646655287856173534479551364115976811459677123592747375296313667253413698823655218254168196162883437389718167743871216373164865426458794239496224858971694877159591215772938396827435289734165853975267521291574436567193473814247981877735223376964125359992555885137816647382139596646856417424617847981855532914872251686719394341764324395254556782277426326331441981737557262581762412544849689472281645835957667217384334435391572985228286537574388834835693416821419655967456137395465649249256572866516984318344482684936625486311718525523265165 -------------------------------------------------------------------------------- /resources/2017/day02: -------------------------------------------------------------------------------- 1 | 626 2424 2593 139 2136 163 1689 367 2235 125 2365 924 135 2583 1425 2502 2 | 183 149 3794 5221 5520 162 5430 4395 2466 1888 3999 3595 195 181 6188 4863 3 | 163 195 512 309 102 175 343 134 401 372 368 321 350 354 183 490 4 | 2441 228 250 2710 200 1166 231 2772 1473 2898 2528 2719 1736 249 1796 903 5 | 3999 820 3277 3322 2997 1219 1014 170 179 2413 183 3759 3585 2136 3700 188 6 | 132 108 262 203 228 104 205 126 69 208 235 311 313 258 110 117 7 | 963 1112 1106 50 186 45 154 60 1288 1150 986 232 872 433 48 319 8 | 111 1459 98 1624 2234 2528 93 1182 97 583 2813 3139 1792 1512 1326 3227 9 | 371 374 459 83 407 460 59 40 42 90 74 163 494 250 488 444 10 | 1405 2497 2079 2350 747 1792 2412 2615 89 2332 1363 102 81 2346 122 1356 11 | 1496 2782 2257 2258 961 214 219 2998 400 230 2676 3003 2955 254 2250 2707 12 | 694 669 951 455 2752 216 1576 3336 251 236 222 2967 3131 3456 1586 1509 13 | 170 2453 1707 2017 2230 157 2798 225 1891 945 943 2746 186 206 2678 2156 14 | 3632 3786 125 2650 1765 1129 3675 3445 1812 3206 99 105 1922 112 1136 3242 15 | 6070 6670 1885 1994 178 230 5857 241 253 5972 7219 252 806 6116 4425 3944 16 | 2257 155 734 228 204 2180 175 2277 180 2275 2239 2331 2278 1763 112 2054 -------------------------------------------------------------------------------- /resources/2017/day05: -------------------------------------------------------------------------------- 1 | 2 2 | 1 3 | -1 4 | -2 5 | 0 6 | -1 7 | 1 8 | -1 9 | -7 10 | -6 11 | 1 12 | -4 13 | -1 14 | -12 15 | -7 16 | -3 17 | -12 18 | -5 19 | -6 20 | -13 21 | -7 22 | -17 23 | -13 24 | -11 25 | -3 26 | -7 27 | -3 28 | -2 29 | -6 30 | -27 31 | -20 32 | -15 33 | -23 34 | -23 35 | -33 36 | 0 37 | -10 38 | -35 39 | -29 40 | -6 41 | -10 42 | -5 43 | -20 44 | -38 45 | -30 46 | -38 47 | -12 48 | -23 49 | 1 50 | -4 51 | -48 52 | -45 53 | -1 54 | -30 55 | -38 56 | -27 57 | -23 58 | -53 59 | -36 60 | 0 61 | -3 62 | -45 63 | -32 64 | -39 65 | -32 66 | -46 67 | -23 68 | -40 69 | -10 70 | -54 71 | -38 72 | -37 73 | -44 74 | 1 75 | -56 76 | -11 77 | -74 78 | -41 79 | -73 80 | -34 81 | -31 82 | -42 83 | -49 84 | -75 85 | -8 86 | -48 87 | -49 88 | -82 89 | -21 90 | -58 91 | -40 92 | -75 93 | -66 94 | -31 95 | -34 96 | -35 97 | -52 98 | -23 99 | -56 100 | -58 101 | -60 102 | -18 103 | -34 104 | -50 105 | -27 106 | -1 107 | -3 108 | -6 109 | -70 110 | -93 111 | -36 112 | -15 113 | -1 114 | -51 115 | 0 116 | -110 117 | -7 118 | -7 119 | -56 120 | -14 121 | -66 122 | -93 123 | -56 124 | -100 125 | -19 126 | -54 127 | -79 128 | -81 129 | -19 130 | -112 131 | -13 132 | -24 133 | -40 134 | -90 135 | -8 136 | -10 137 | -14 138 | -27 139 | -62 140 | -45 141 | -137 142 | -53 143 | -53 144 | -89 145 | -48 146 | -86 147 | -139 148 | -91 149 | -146 150 | -109 151 | -52 152 | -6 153 | -32 154 | -6 155 | -113 156 | -78 157 | -12 158 | -4 159 | -113 160 | -42 161 | -145 162 | -23 163 | -64 164 | -97 165 | -98 166 | -77 167 | -155 168 | -133 169 | -65 170 | -64 171 | -59 172 | -164 173 | -155 174 | -27 175 | -65 176 | -57 177 | -133 178 | -140 179 | -95 180 | -104 181 | -46 182 | -16 183 | -139 184 | -55 185 | -15 186 | -26 187 | -63 188 | -141 189 | -93 190 | -146 191 | -51 192 | -104 193 | -84 194 | -82 195 | -87 196 | -149 197 | -19 198 | -77 199 | -154 200 | -118 201 | -96 202 | -117 203 | -96 204 | -140 205 | -47 206 | -188 207 | -158 208 | -141 209 | -192 210 | -63 211 | -58 212 | -191 213 | -63 214 | -52 215 | -135 216 | -142 217 | -109 218 | -42 219 | -134 220 | -4 221 | -11 222 | -135 223 | -13 224 | -24 225 | -39 226 | -4 227 | -183 228 | -158 229 | -25 230 | -136 231 | -35 232 | -49 233 | -54 234 | -78 235 | -18 236 | -92 237 | -19 238 | -142 239 | -40 240 | -237 241 | -119 242 | -147 243 | -198 244 | -132 245 | -73 246 | -238 247 | -106 248 | -82 249 | -51 250 | -72 251 | -9 252 | -44 253 | -151 254 | -164 255 | -35 256 | -74 257 | -252 258 | -219 259 | -40 260 | -154 261 | -229 262 | -169 263 | -130 264 | -238 265 | -64 266 | -171 267 | -174 268 | -161 269 | -67 270 | -205 271 | -160 272 | -112 273 | -191 274 | 1 275 | -60 276 | -147 277 | 0 278 | -43 279 | -67 280 | -190 281 | -256 282 | -66 283 | -189 284 | -76 285 | -86 286 | -91 287 | -243 288 | -10 289 | -142 290 | -163 291 | -52 292 | -112 293 | -162 294 | -169 295 | -269 296 | -98 297 | -188 298 | -282 299 | -212 300 | -286 301 | -28 302 | -33 303 | -6 304 | -114 305 | -89 306 | -237 307 | -90 308 | -95 309 | -202 310 | -266 311 | -72 312 | -215 313 | -50 314 | -52 315 | -78 316 | -286 317 | -32 318 | -235 319 | -7 320 | -56 321 | -194 322 | -6 323 | -32 324 | -73 325 | -48 326 | -77 327 | -69 328 | -43 329 | -279 330 | -236 331 | -79 332 | -286 333 | -105 334 | -295 335 | -61 336 | -320 337 | -130 338 | -99 339 | -90 340 | -238 341 | -294 342 | -120 343 | -9 344 | -302 345 | -327 346 | -165 347 | -267 348 | -228 349 | -250 350 | -153 351 | -28 352 | -126 353 | -187 354 | -138 355 | -163 356 | -140 357 | -26 358 | -217 359 | -197 360 | -180 361 | -338 362 | -39 363 | -71 364 | -6 365 | -56 366 | -151 367 | -272 368 | -276 369 | -246 370 | -189 371 | -183 372 | -38 373 | -249 374 | 0 375 | -185 376 | -8 377 | -193 378 | -213 379 | -296 380 | -3 381 | -340 382 | -76 383 | -97 384 | -87 385 | -1 386 | -172 387 | -235 388 | -38 389 | -274 390 | -169 391 | -70 392 | -162 393 | -320 394 | -78 395 | -222 396 | -69 397 | -222 398 | -219 399 | -213 400 | -313 401 | -179 402 | -182 403 | -253 404 | -135 405 | -206 406 | -54 407 | -167 408 | -101 409 | -397 410 | -367 411 | -54 412 | -143 413 | -147 414 | -156 415 | -293 416 | -144 417 | -47 418 | -254 419 | -169 420 | -307 421 | -223 422 | -339 423 | -398 424 | -414 425 | -23 426 | -107 427 | -235 428 | -302 429 | -321 430 | -111 431 | -167 432 | -345 433 | -55 434 | -64 435 | -315 436 | -266 437 | -191 438 | -265 439 | -248 440 | -426 441 | -47 442 | -409 443 | -212 444 | -212 445 | -401 446 | -87 447 | -389 448 | -146 449 | -97 450 | -65 451 | -286 452 | -447 453 | -168 454 | -26 455 | -371 456 | -153 457 | -297 458 | -285 459 | -164 460 | -215 461 | -336 462 | -14 463 | -416 464 | -278 465 | -233 466 | -234 467 | -392 468 | -113 469 | -80 470 | -237 471 | -342 472 | -85 473 | 0 474 | -145 475 | -75 476 | -101 477 | -88 478 | -292 479 | -285 480 | -344 481 | -254 482 | -47 483 | -310 484 | -227 485 | -60 486 | -320 487 | -102 488 | -364 489 | -131 490 | -338 491 | -17 492 | -239 493 | -124 494 | -266 495 | -380 496 | -421 497 | -217 498 | -311 499 | -287 500 | -233 501 | -223 502 | -242 503 | -16 504 | -326 505 | -407 506 | -482 507 | -470 508 | -247 509 | -365 510 | -75 511 | -278 512 | -44 513 | -404 514 | -195 515 | -348 516 | -81 517 | -309 518 | -181 519 | -176 520 | -97 521 | -274 522 | -204 523 | -485 524 | -458 525 | -364 526 | -22 527 | -89 528 | -448 529 | -235 530 | -53 531 | -50 532 | -510 533 | -89 534 | -114 535 | -158 536 | -199 537 | -189 538 | -204 539 | -528 540 | -278 541 | -274 542 | -149 543 | -208 544 | -485 545 | -313 546 | -325 547 | -246 548 | -173 549 | -478 550 | -164 551 | -153 552 | -76 553 | -407 554 | -447 555 | -109 556 | -334 557 | -199 558 | -50 559 | -361 560 | -449 561 | -338 562 | -409 563 | -66 564 | -282 565 | -510 566 | -288 567 | -380 568 | -562 569 | -543 570 | -534 571 | -500 572 | -288 573 | -526 574 | -439 575 | -142 576 | -284 577 | -421 578 | -30 579 | -243 580 | -185 581 | -433 582 | -326 583 | -102 584 | -540 585 | -391 586 | -197 587 | -580 588 | -305 589 | -436 590 | -559 591 | 2 592 | -30 593 | -204 594 | -97 595 | -204 596 | -207 597 | -79 598 | -329 599 | -157 600 | -284 601 | -581 602 | -182 603 | -458 604 | -232 605 | -111 606 | -352 607 | -601 608 | 0 609 | -245 610 | -292 611 | -167 612 | -549 613 | -456 614 | -277 615 | -63 616 | -104 617 | -493 618 | -585 619 | -369 620 | -121 621 | -122 622 | -180 623 | -466 624 | -509 625 | -405 626 | -53 627 | -555 628 | -454 629 | -549 630 | -486 631 | -80 632 | -463 633 | -385 634 | -538 635 | -274 636 | -75 637 | -90 638 | -500 639 | -434 640 | -167 641 | -142 642 | -587 643 | -92 644 | -182 645 | -95 646 | -205 647 | -49 648 | -574 649 | -352 650 | -638 651 | -204 652 | -25 653 | -375 654 | -456 655 | -400 656 | -572 657 | -37 658 | -151 659 | -81 660 | 2 661 | -19 662 | -579 663 | -106 664 | -344 665 | -339 666 | -188 667 | -517 668 | -12 669 | -403 670 | -623 671 | -619 672 | -429 673 | -53 674 | -227 675 | -11 676 | -548 677 | -426 678 | -115 679 | -481 680 | -425 681 | -9 682 | -43 683 | -209 684 | -145 685 | -168 686 | -241 687 | -331 688 | -521 689 | -77 690 | -642 691 | -397 692 | -37 693 | -98 694 | -333 695 | -281 696 | -162 697 | -361 698 | -119 699 | -696 700 | -440 701 | -663 702 | -347 703 | -295 704 | -692 705 | -32 706 | -331 707 | -623 708 | -275 709 | -646 710 | -517 711 | -16 712 | -193 713 | -537 714 | -403 715 | -75 716 | -607 717 | -74 718 | -393 719 | -333 720 | -665 721 | -448 722 | -419 723 | -119 724 | -213 725 | -635 726 | -668 727 | -178 728 | -46 729 | -175 730 | -537 731 | -160 732 | -467 733 | -271 734 | -594 735 | -240 736 | -262 737 | -666 738 | -205 739 | -48 740 | -319 741 | -738 742 | -240 743 | -697 744 | -685 745 | -711 746 | -98 747 | -134 748 | -28 749 | -731 750 | -317 751 | -319 752 | -288 753 | -236 754 | -425 755 | -401 756 | -625 757 | -638 758 | -496 759 | -23 760 | -751 761 | -643 762 | -382 763 | -717 764 | -269 765 | -275 766 | -764 767 | -672 768 | -758 769 | -605 770 | -530 771 | -244 772 | -526 773 | -357 774 | -175 775 | -667 776 | -282 777 | -551 778 | -642 779 | -83 780 | -116 781 | -751 782 | -381 783 | -447 784 | -266 785 | -297 786 | -88 787 | -575 788 | -246 789 | -189 790 | -662 791 | -450 792 | -91 793 | -471 794 | -209 795 | -609 796 | -151 797 | -630 798 | -345 799 | -625 800 | -743 801 | -377 802 | -789 803 | -56 804 | -370 805 | -250 806 | -661 807 | -792 808 | -560 809 | -585 810 | -231 811 | -673 812 | -725 813 | -194 814 | -317 815 | -455 816 | -234 817 | -282 818 | -516 819 | -784 820 | -2 821 | -652 822 | -427 823 | -31 824 | -755 825 | -527 826 | -725 827 | -47 828 | -606 829 | -210 830 | -172 831 | -773 832 | -819 833 | -636 834 | -348 835 | -376 836 | -700 837 | -727 838 | -156 839 | -574 840 | -414 841 | -34 842 | -439 843 | -413 844 | -604 845 | -648 846 | -381 847 | -529 848 | -82 849 | -736 850 | -816 851 | -595 852 | -352 853 | -417 854 | -836 855 | -691 856 | -660 857 | -464 858 | -314 859 | -748 860 | -698 861 | -49 862 | -97 863 | -721 864 | -294 865 | -441 866 | -446 867 | -415 868 | -187 869 | -212 870 | -506 871 | -550 872 | -131 873 | -231 874 | -637 875 | -334 876 | -853 877 | -383 878 | -407 879 | -219 880 | -518 881 | -743 882 | -83 883 | -773 884 | -162 885 | -570 886 | -611 887 | -574 888 | -355 889 | -56 890 | -775 891 | -663 892 | -131 893 | -357 894 | -560 895 | -335 896 | -390 897 | -667 898 | -516 899 | -897 900 | -752 901 | -786 902 | -246 903 | -893 904 | -693 905 | -692 906 | -647 907 | -422 908 | -361 909 | -148 910 | -231 911 | -775 912 | -62 913 | -404 914 | -783 915 | -387 916 | -559 917 | -703 918 | -403 919 | -776 920 | -588 921 | -633 922 | -831 923 | -779 924 | -23 925 | -216 926 | -381 927 | -287 928 | -517 929 | -402 930 | -814 931 | -756 932 | -646 933 | -535 934 | -270 935 | -282 936 | -157 937 | -367 938 | -356 939 | -925 940 | -333 941 | -375 942 | -469 943 | -931 944 | -347 945 | -455 946 | -942 947 | -815 948 | -311 949 | -690 950 | -65 951 | -691 952 | -64 953 | -361 954 | -409 955 | -886 956 | -488 957 | -303 958 | -806 959 | -73 960 | -653 961 | -356 962 | -71 963 | -523 964 | -370 965 | -685 966 | -526 967 | -528 968 | -519 969 | -179 970 | -762 971 | -652 972 | -388 973 | -568 974 | -296 975 | -601 976 | -822 977 | -656 978 | -258 979 | -304 980 | -670 981 | -731 982 | -352 983 | -82 984 | 0 985 | -116 986 | -294 987 | -652 988 | -702 989 | -933 990 | -12 991 | -348 992 | -15 993 | -662 994 | -311 995 | -695 996 | -357 997 | -872 998 | -847 999 | -791 1000 | -129 1001 | -574 1002 | -281 1003 | -42 1004 | -626 1005 | -36 1006 | -60 1007 | -864 1008 | -871 1009 | -246 1010 | -943 1011 | -500 1012 | -253 1013 | -684 1014 | -545 1015 | -1011 1016 | -330 1017 | -666 1018 | -468 1019 | -780 1020 | -596 1021 | -872 1022 | -812 1023 | -924 1024 | -836 1025 | -379 1026 | -528 1027 | -464 1028 | -99 1029 | -675 1030 | -317 1031 | -58 1032 | -641 1033 | -590 1034 | -227 1035 | -296 1036 | -303 1037 | -798 1038 | -39 1039 | -824 1040 | -300 1041 | -469 1042 | -251 1043 | -182 1044 | -40 1045 | -115 1046 | -997 1047 | -572 1048 | -743 1049 | -13 1050 | -557 1051 | -542 1052 | -832 1053 | -884 1054 | -385 1055 | -224 1056 | -932 1057 | -757 1058 | -405 1059 | -690 1060 | -745 1061 | -1008 1062 | -657 1063 | -846 1064 | -565 1065 | -508 1066 | -792 1067 | -245 1068 | -298 1069 | -793 1070 | -278 -------------------------------------------------------------------------------- /resources/2017/day06: -------------------------------------------------------------------------------- 1 | 0 5 10 0 11 14 13 4 11 8 8 7 1 4 12 11 -------------------------------------------------------------------------------- /resources/2017/day09: -------------------------------------------------------------------------------- 1 | {{{{{<>},{{},!!!!!>!>},<,!!o>},{}},{},<{!!a!a!!!!,!{i!!!>>,{>}}},{{{{{<<{!>,,},,}e>}}},{{},},},,<>},{}},{{{{{<}i>,{{}}},{},},<<,!!a'}{"!!!!!>"'u!>,'>,{{!>!!!>,}'u,!{!>,<}!>},<}u>}}}},{<{!"}!>!!u!>},},},{<"{>,{{<>}}}},{{<{!,>},{,{<>}},{{},{{,i!!!>o!!!>>}}}},{{},{{{},{!>u<"'o"'!}!>,,<"ea,{!>,"ei!!}}},{eauu'>}}},{{{ou!>,u>,{!!{>}},{}}}!!!>}>,<"!!'}},{{},{}}}},{},{{{<>},}},{{,!!!!}i"!>e}!{!>},e>},{{},{}}},{}}},{{{{{}},{u>}},{{},{{},}}},{{{<{o!!!>},},!>},,{}},{{!a!!!>e"o}!!!>,>}}},{{{<'!>!"!!!>'a<}i"!>!!>}}},{'>,{{!!,<>}}}}},{{<}!>,<}u!>,<,!!!>{'!!!>!!>,!>,},<}!>,},<{ia}!!a},{<<>,<>},{{{<},<}'!!'>}},{{<'!>},<{!!i,u{!>},<}'!>!!!,}>},{"e!>,!>,i!>,<'>}},{{,<},,!>!o}}}},{{{<,!!!!!>!>,""!>!{'o!!"'!!!>'>,{<}!!!>},},,},<{!!}}}},{{,{!!,<>}},{{,,'!i!>},,<>,},},{,{}},{{{,!>,<'u!!i!}!>},<>,,!!!>i!>}"!>,},<},{,!>!!!"!>,,'!>,"!>!!!"e>}}}},{,u"<'!>!!!>,'>,{{a!!!>"!<>}}}}}},{{{<>}}},{{{{!>},},>,,{!>,<'!o>}},{{{{<},a!!u>}},{{{{},{e>,{,<}!!!!"oo>}}},{{<{!>,<'!!!>,uo!!!!}!!ia!!!!!!!>',o{>}}},{{}}},{{<,'!!!ie!!!!"ea!>},<"a!>{},<>},{>}}},{{{},},,{{}}},{{},{}},{{{},{!!i!><'"!!ia!a>}},{,{<{!!eue{>}}}},{},{{!i},'!!o!!'a>}},{{{{{}i!>,,},{{{},,<,'}e"!>!>i!a}}}},{}},{{{,},<'}!!!>e!!!!!>eo>}},}}}},{{{{,{{,,!>!>u<}!"!!!>!>>}}},{{},<,i{!!!}{!!!>},},!!!>>}},{<{"!!,,{o!{>,{,u'!!o!>},<>}},{}},{{{'!>e,!!a{'!>!>!!!>!>},<>,{{'}}},{,,<},},,},<<}>}},{{!>,},<{!>},}},{{,{<}>,<'<>}}}},{{{},},<">},{{},<"a!!!!!{e!!>}}}},{{{{}},{{{<}!iu!!!!!u,<"a!!!>ea}!>},,<}>},},,!!!>ue>},{{}}}},{{{,!>'!!e}!!!!>!>,i'"!!!>{>},!!!'!!!>>}}}},{{{<"'>}}},{{!!!>,,{<}!!!>!>,<',{>}},{{{{},},<,e}!!"!!!>!>},},!!!!,!>!>},<{!!!>},},e!!o>},!!oe!!!>!!!>,<>}},{{},{{!!uiiae'!!'!>},>},{,,},>}}}}}},{{{{{<}>}}},{}},{{{{{<{!uu',<>}},!>'}!>a<,!>},,<,a>}},{{,},,!!i!oa!!!!!>,!!!>,,>},{{{<,ee>}}}}},{{},{}}}},{{{{{{<,u!!!>!!ai'},{}},{{{},<'!!a!,!>},!!!>},},{{,<>,},}!!!!!>a!!!,!>{!!u!!e}>},!'!!!>u'{',>},{{,}}}},{{{{<'},{""!>,<}"!!!>'}>,{{<"!,!!!!!o,i!!!>>},e!!o!!!>,!!o"''>}}},{}},{{<>},<}"}!!!>e!>,}!>,<"!!!>io>},{{{},},},!ao!>,}}},{{{}}},{{},{<"o!>},"uo!o}!>i!>,<{>,">},{{},{{<"!!a!>,,{{<,{,!!!>>}}},}u"u'!>},<}!!!!!>!>,>},{{}}}}},{{{,<{{{uo"!>,e>},<>}},{{{}},{!>!i!>!!!>,<{!>!!ao>}},{{{<}}"!>,<,!u!{u'!<>},{},},<>}},{,<{"}!!!>e!!!>}ea!!!>'uia,{'o>,{}},{{{<'!!"!!i}!{!!{,>}},{{}}}}}},{{{{{{<,},{{ii!>,},<,'u!!u>},{{,},{<"!>,}!!!>!!}e!!i}}},{{{<{!>}u!!,!>},,,<>},{{!!!>>}}},}},{{},<}u}{i"!!o{,<'a>},{}},{{{<>},{{{u!e<>},i!>!>},<>},ai!>,<>}}},{{{{e!}}!>"!!!!!>!!',<>},{<}},{{{},{{},{},,<{'!!!!!!!>ioa'">}}},},},<,<}u!>},<,!>,!''>}},{{{<>}},{{<'"!!!>},!,!!a",!>!>,,},<"!a<'!>,,<"e!!!>!>o>}},{{},<},>,{}}}},{{'e>},{{},{{}},{{!!!!!>},<>},{<>}}}}},{{{{{},<}u!>,<",!!u!>,},<{{!>},,,<{!>,,!>>}},{},!>,,{}}},{{{<">,<"!o,i,!,>},{ie!>,<"uu!!!>,},i>,},{!>},!>},{!{!>},}},{{!!!>,<'!>},!>,<},},{{{}},},{{{},u>},{<,{'!!!>,>}}}},{{{<'!!',<{!>,,!>},<>,{<,{!!!>!>},<>}},{}},{{{{{,{!>,<,}!,}u{!>},,}},<>},<,{!!"o!>,},{{<{!o,},<,io!!i!!!!!>e{!!!>>},<>},{},<>,{,},''!{!a!!!}!>!!>}}}},{}}},{{{{<,!!!>"ei"'}o!>!!!>o{!!!>e>},{{}}}},{{{}},{{{{{}},<{{!>},,<,!!ii!>,},<>},<,}o"!!>},{<'!!,!!!!!>u>},{{{},<"""{!!!>'">},}},{{{{{ii>,{{u!"uu!!!>!>}!"!!!>!>>},!>,<>}}},{{{},<>},{}}},{{{{{<'!!!>"!!!!"}!>,<{!!!>>},ea"a!!!!oua},<'e!>},<>},<"u{o},!!{>}}},{{{u}}}},{{{{{<''!!!>!>},<>},ae>}},{{{{{{}}}}},{<"!!i,>,{{!>},<{!>},<"!!!>>},<,}!>,<{!eia}!>},!>!>},<"{a!!>}},{<}!!"!!!>uu'!>,<>,{,<>}}},{{},{<>},{!>,<>,!!!>},,}}},{{,"!>,,<"o!!i,,>},{{<"}"{'oi},>}}},{{{{{},{,},<{e!>},,}},{>}},{{,,!!!>>,<'e"!!a!!{!>!!,"e!!!!!!!>,<',!!!>!!!'>},{{},!!ui!!!>,<,},{<}>,{{<{!>,,},<{!!!>!!a!!!>,!!!>>}}}},{{!>{<>,{,!>,<>}},{{},{{},<},a"!!!>u>}},{},!!!>}e!>,,{{}}}}},{{{{{!>},}!!aa{!>,>},,<'i}!!!>!>,<>}}},{{{},<'},},<!!!'e!!>}},{{{{},,<'!>,!><{!uu!!a},,uu!>,<>},{}},{{},a!!ei!{!!>},{{<"!>!>},},<}>}},{{<},},<>,{{{},!!,e!>},<{!>,!!e<>,{<,{!!,i!aoi!>,!>},<,e!!!!u!!!>'e!>>}}},,e{!!!>!{!!!>}ou}},{{},e!!e!>!>,<,!!ua!!e!!!!!>},}}}}},{{{<,!>,},,,},<'!!!>u!>,<>},{{a'!>},<,>},{}},{{,!>,<,!>},,},},},}}},{{{,},!!u'!>,<,!>,}},{}},{{{{!>o{!>"!{!>,"!!}o!!i!>,>}},{{{<}{!a!>},},},}}},{{,!!!>!!!>!!u!}!o>},{,}}},{{{},{},},},>}}}}},{{!u!!!>!>},,>},{{,},<'!!!!!>ea!!!>u!>,e!!!>!oai<>}},{,<'"}!!!!!''iiu!!o'<,!!o'!!u!!!>>}}},{{{},{!}!!!>},{e,},}},{,u!!!>!>},{!ou>},{{},<>},<}ao}>}}}},{{{{"!>,<"o!>},<,}u>},{}},{<}{!>},"!'!>},},,<}{o!!e>}},{{{{<>,'!!!>},},,},,},}},{>,{",'>}},{{},}}},{{,},<"{}a!{ea,'o!>,},},{{o!>,},{!>,!>},<{!!"!!}!!},!><'}},{}}},{}},{{{{},{},!'}a>}}},{{{<"!!{>},{<'!!!>!>,!!!>!!,e!!"',o">,a,,}},{{},{<{!!!!!>!!!!!>,!>{!,!>,<>,},{{{{}},{},{{<>}}},{{}},{{{}},{{}},{{}}}}},{{{{{},oae!!!>!>,}},{{},{}}}},{},{{{{,<'{{!>,!!!!}!>,e,i,<"!!{}!>,},<}}},{{!>e!>,<{ao">},{}},{{},},{},,<"'u'!!!>u}!>,<>}}}},{{{,},},},,o}>},{},{{},'}a,!!!!!>},{u,!>>}},{{{{{!!!!!!o,},!!!>!>o!>,'!>,<>},{}},{!!!>!u,!!!>!>},<">},{<}}!!!>'u!!!!!>}!!!u{"!!o<<>,<>}},{{{},<>}},{{{"!>,,,,},{{,!!'>,,<>}},{},"!e!>!>,},<>}},{{,,!>,<>,{}},},{{ei{}!!'i!!{{{o!e!><>}}}}},{{{{!>!!!!>},{{{{},,!>!>},<,!!{eu'}>}},},<{o!>}!>,<"!!!!!>>},{<>,{},<}>}}}},{a}u!>},},<<"o!>,<}!ue!>o,!<>},{{<{,{!!{a!>},<'!!!!!>!!e!>!>},,<>},{,'{!!!>!!!>!>!>,<}>}}},{{{},}},{,!!,{!!!>!!a}!>,<'u!"{{u>},{{{{}},{{{},{<"ou!>},<'!!!>},!!!>"!>},<>}}}}}},{{},<}!!!>o!!,}}}},{{{{},{,<{>,,<{!!!"e!!!!!!},!a"!eii>},{<!>},uu!"'>}},{{{{},i'!>,}i}>,{}},{{{a!a<},{}},{'!>},!!{a{!>},>}},{}}},{{{uo!>!>'iua!!!<<>,{{},{}}},{{},<>},{!!'!!!>,,<{!o,au!!ooa>}}},{},{{{{<{ia!!''!!i,>},<,!!!>!!!>!e!!!!u!!}",e}aaa!!!>}'a>},{{}},{}},{}}},{{{!>},,>,{},<}o!>,},},},,!!},>}},{{!>},},,,{iaaa<}u!>}!!!!!!>}},<"!>},,},!!!>!>iau">},{{{}},{<,}{iaue,>,{}e!>,<"!!!!!"!>},}}}},{{{<{{}e!!!>!!!>!!>,{!!!>,<<{!{ioai!>,}},{{},<<<,!!i<>},{,<'u!>,}}},{<}eo"!!o'">,{<,'!>!!!>i!!!!>i!!!>!!!>},>}},{{eee!}i!>'"e''!!oa!!!!}!u>}}},{{!>,{!!!>},},},!o>},{{!>,!!a!!!>},<>}}}}},{{{{}}},{{},<"!!ie!>!>'!!eae{i<,i,!>},<>},,},<>}}},{},{{{{<}>},{{{u!"'au{!!e"!!!>!!!>!!!><'>}}}},{{{},},<>},{{}}},{{<{!e"!!!>{>},{{{<{!>e>}}}}},{{{{{{<,,!>},<'i!>},,},},<{e!>e!u,>},{},,<'!o,!,"}i!!!>},<>}},{},!!<},},,<{{!!!!!o>}},{{<{!!<}aiu!!e!!{}}},{{},{{o!!i},>,{{{<<{!>!>!!!!e!'o{!!!>!!'!o"e>},{},<,'a{i'!!!!>}}}}},{{,!!<,!>},,<'oi"!!!>"o,,>},{<"!,!>},<>}}},{{{{,<,u!!<>}}},{!!a!!!>},!!!!!!!!o>}},{{{{<}i}"a!!!>>},{}},{{{!>},o'ie>,<,a,!!!!!>!!!!{o!!,!!!>,{}!!!>,>}}},{{<,ue!!!>'"o!!"!>,},{},},<}!!!>!>,a!>},<>}}},{{<,o!!>},{{<'o!>},!!,}>}},{{,!!!!>,{}},{}}},{{{,},<}!!,{}e,!o!!!>},<}ea{>}},{{{},{,,!!oa{!!}'>}},{{}},{{},{{{{},{,!>},>}},<!!'u<,ie!>!!!>{<<">}}}},{{{{{},<>}},{,,<}'{e!!u'''!>{"}>,{<{o"!!!>}!>},<,!}{!>!>!!a<">}}},{}},{{<'!!}<>},{,<{">,<>}},{},},<{{e!!!>e!>!!!!!>'!>,<'>,{{{,{},,<'ei!>,<,,<,!>,<,>}},{!>!,ui}ae!>o<,i>}},,<'!!!!e!ii>}}}}},{{<'!!!>},,},},{}}},{{{{{}},{}},{{{'!!,},<{>,<,!>,,<}e!!!>!!!!o'}!>,u>}},{{!>e!>},,<}a'>},<{e",!!i!>},<'}>}}},{{{{{{,},<,ai>}}},{{<>,{}}},{{{{}},{{},},},},{}a!>!!i>}},{{<'"o'!!uo!>},<"<>,{u!!!>!'!>!!!>},e!>},<{}}i>,">}},{{<!!"!!!>},<{!!!!}u>,<>},{{{{},!!!>!!,!>"e!!!>!>!!!>i',!!!!>,,},},,!>},<{!}!!!u>},{},{<<'e!>,!!a"{>}}}},{,}}}}}},{{{}},{{{!!!>!>},<}!!{!>a,u!>,}},{{},{{}}}},{{,<>},{{<{!>u!!e!au!>!>,a!!u>,<}!>!>,}}}},{{{i!!!>!>},<>,,<}<'!>},,o'!!e!!e>},{}}},{{{<"!o!!,e"!{u!>},},<'o<>},{!!"aa>}},{{{<">,{}},{{<'}!!!>'!>},<!!"!>,,{,!!{!!u,!!!>>}},{},}},{{{!>!!!>",!!!>},<}}!!!>},},},},,!!!!"!!!>uo!>i<}>}}}}}},{{{,},<<>},{},{}},{{{},{{{},{{,,u>},{{<"}}!!!>,},!!!!!>},a!>,"a!!>},{>}}},{{},<,,<{,eo!!{,<>},{{<>},{{<''a!!!>"'"a!!!>}!>">,!"'!!!>!!ei',!!!>>},{{<{!>,<"!!'!!>}}},{,a!!!>},,,,<{!!a!!,ie,!!">}},{{!!!>},},!!!!!>!!{}a<,'!!!>!!!{>,!e>}}}},{{{},{<{u,!>"o}!>,<"ue!!a,!>!>,<>}}},{{{<"''i'''!!{u<'!!"u{!!a}>},},},},},<"!!!!!>u}o>},{},{{}}},{{{{},{}}},{'!!!>!!>,,<,'!!>},{i,">,{<{}!>,{>}}}},{}},{{},<>,"}!>},<<'a!>,<>},{},{}}},{{{}},{{}!>,},},,<'!>},<>}},{,<>,{{<,},{a{>}}}}},{{{{<">,<},,<"!>a}!!!>uo!{!!!>!!u!!o!i>},{},}},{{{},},{{<'!},!>},<<'"!>!{!i}}},{{<}}ei!!i,{u>}},{{!!!!!>oi"}'e>,<,!!{i>},{}}},{{},{{<>}},{{,<{!>au>},!!a!!}},{{{{'!>i>}},{!}!!'!<>}}}},{{{<,},{{,{<>,{}}}}}},{{{{<'{o!>!!!{u,{,<''a,!>,>}},{{}}},{{{{"!!!>,!>,}!>i!o"!!!!!!!>,<>}}}},{{{!!e!>},},<,!>,},<{e'>},{},{{u!iii!{!!}}}},{{{{>},{{},<{{,i<>}},{{,,!>,<<{!>e}>},}},{{<>,{{!!iu!!}'!>!!!!!>e!>,,<"">}}},{}},{{{<{,e!!!e!!!!!>ei!>'!>},<>,{!"!!!>i!!!>o!>},,<'>}},{{{!">,{}},{}},{},,<,"i}",>},{{{},{<'!!}!!!!!>}!!!!i<,!>,}}}},{{{<>,{}},{{},{,},},{}},{{{!>,i!!!>},>},{}},{{},}i{!>},}}}},{{<}!'}u!>},},<"",!>,,>,{{,,!>},},{<'!!a!"a}o!!!>>}}},{,{}},{}},{,{}}}},{{}},{{},o"!!!!!!!>ai!!!>,<}">},{!>},},,i>}}}},{{{<'!!!!a<,!!!>,!u!!!>},<,>,},},{<"a,'!!">},{{{!!<>},{{},{}}}},{{{<"u"!>},},{<},!!!!e<}'!!'!!""!>'>,{!!!>}}!!!!!>!!"o">}},{{<,!>,!{"!>!!!e'u!>>},{<,a<}"}{!>!!u!>},<>}}},{{{}},{{u>}}},{}},{{{{,!!u'"<<>,{},,},},<>,{a!!uaua,!>},iu>}}},{{},{{{{}},{}},{!>,<",a"!>},,,'>}},{{{!>!>!!!!!>"!>,<>},{}}}},{{},<'!!!>o!},<,eao,>},{{},!!a""!!!!!!!>,<},>},{{e!!!!!!!!!!!>>}}}},{{{{{},{{u!!!>},,},{}}},{{{}}}},{{{{},{<}!!!!i!!!>!>}!>},!}>}}},{,},<"u">,{<}eu">,{}}}}},{{},{{{},},<}!>!!>},{>}},{{<>,{,<},,},<''>}},{{{},<}!>},a!!!>},i!!!>>}},{{{{}},{i!!{au!>,<>}},{{,,,<{,}>}}},{,,{{,<"{!!!>!!a>}}}},{!'!""!>,o"e>,{<"!!>}}},{{{{<},o!!!>!>},<"!!!>>},{}}},{{{}},{{<,"!!!!!>>}}}}},{{}},{{{,,!!!!}'a!!}!>io!!!>!>!>},,<>},{{<},u>},{!!!>{,>}},{},<<>,<'!>!i!>''!!!o,>}},{{{!!!>!>!!!>>}}}},{{{},{{!>},<'i!!!>i>,{o!>},},,,,<{o!>},}},{{<<"e">},{"a!!!>!!o!>,<,u!>},,}}}}}},{{{{{!!u!!!!!!!>,},{,!>,,'!!'!>},<'u'ia>}}}},{{{{,i!>!>},!!!>e,!!!"!>>}}},{{<'!>aa',!!!>i",a>},{<},>}}},{{{<{}e}!'"a!!<'}<,!!!>!>e>,{{<>,{}}}},{<,!!!>!a!!}!>,!''!"i'{>,{o!!aeoi>}},{{{{,e!!"}}},{{,<!>}e>,{}},{}},{,}i{e>}}}},{},{{{,,<'!!{e!!!!!>,!!i{'!<>},{}},{<>,"'}}>}}},{{},{{!>,,},,},!>ae}!>,<,,!o>},{{>}}}}},{{{,<'e!!}!>,!>e!>},,{<},<'ai!!!>!>},oe!>,},<">}}},{{{'a!!!>},>},{{},{{,},,},},},!"'!>,,!>>}},{<<>,,i}>}},{{{},{{},o}>},{{}}}},{,},<'!'}!!!>>,<<",ua!!}uu{!>!!!>!!!>!>},<>},{{{{!!!>a{'!!}i<'a<>},},,,,,,},{!>,<{!>},<}>}},{{{{<}!!u>},{},!'!>},!!e!"{!!!i>}},!!!>!>},,},{{},<"i!!,!!!>a'!!a!!a<"{>},{,'}u>}},{}}}},{{{}},{}}}},{{{{a!!!>!}>}}}},{}},{},{{{{{{<{'>},{<"{}!>},{,!>,},>}},{,},<}i!>,,<>}},{{{,<!>,},{}},{,{>,>}},{,<"e!>!!!>},}},{},ii>,<',},<,o}!"!>!>,<<{!>,<}!!!>>},{}},{{{<,!'!>">,},!!!>!"!!!!!>}u,!{!!!>}>}},{<<'!>},,{{!}ui!!!ee!>},i!!!>}!!!>!!!>'{>},{}}}},{{{{{{}},{}},{{<'{{<,!a!>>,{}},{{}}},{{}}},{{{},!>,},{{},<},},},<>},{{},}ou!!!>,<,"a'!>},"!>,}>}}}},{{{{<>},{{,,<"!!!>!!{!e!>},<"e!!{!>,},!!!>}>},{{},{<}>}}}},{{},{{},{}},{{!!!>!!!>!'i,},<>,{<}ua,i"ai>}},{{},,!!!>,<,>},{{},<,<>},{,<>}}}}},{{{i!>,},!>{!>!!!>o!>}}e!>i>,{<>}},{!>>},{},}},{{{!"u!!}u,}i>,"!!!>},},{!!!>o"!>o!!"!!e{}<}!>},<>,},<,{!>},{{"o!>,,,{}},{{>,{e!'}e!!!>},},}},{a!>!a}!<,{}}}}},{}},{{{{{i!>},},>}},{{''!!!>!>},<{,!"e,!!,>,{<"i,!!!>},},'!!!>,!!}!!!>,>}},{{!>'"{!!!>,,<}}"u!!!!!>!!>,<"!!e'!>o!>{e!!!>,},<{>}}},{},{}},{{{{<'!!,{!!!>},},{}},{<{,oi!!!>o}}!>>}},{{!>,<>}},{{{{!>},e!!!!!!!!"u!e>,{{,,,},}}}}}},{{},{{,,<>},{}}},{{{{},,,>}},{{>},{<"!e!>},,i!!!"'!,!>},}}}},{{{!!ui!!''!>},!{!!!>o{>},{{},!!!>e!>!!,{>}}},{},},{!!!!e'{>,"!>u"},!!}u!>,}}},{{{<{a"u!>!"io!!!>e!>},<}u!>},<}!>},},{<'!!"}!oo!{!!!>!!!>!!{!o!>},}},{{{},<"u!>!!>},{{!!!>e!>},},<{!!u{!!!>!o!>},<>,<>}}}},{{{{}}},{{<{!!!>!>},!>ii!>!>,<{"}"!!>,{,},<""u{!>!>},},<{!>,<,}},,!!e,>}}},{{{{},{}}},{{{{{,eu!!o"}o!,u!>,<{!,{'o'e!!{>}}}},{{{>},<{<}e!>>},{{,<,}}!!{{>},<}!!i'!>},<''i!!!>},!!!!ui!!!>,<,!!!>!>,<>},{{},{u!>},>}}},{{},{{},{e!>,!>,<{oi!!>}},{,<{!!!>!>,!>!>},<>}}},{{{<"!!!>o!i!>!u!!<},!e>}},{{!>,},,<,>,{<,"!!,!!,}{o}eo!>,<>}}}}}},{{{,,!!!>'u!ie!>!>},,<"!!>,{<}!!eu<},<,}>}},{{},,,<'e'iei>}},{{>},{<"!!!>,{!!'!!!!!>e!>,,!!{,>,<,}{i!>},},{>},{{<}!!!>!!'i!>,},}}}},{{<''!>,},{,<"!>,<}!>,<<"!>,!!!!!!'oo!!!!!>a>,{}},{{{!>,}}}},{{}},{{{{{{},!>},},<},<}<>},{<">,{iu,e"u!!ao'>}}},{,<}!!u!!}>,<>}},{{{{>}},{<!>},,"!!!!!>},<!!>}}}},{{{{{},},{{},!!!>},<{,!>},}},{{},},},!!!>,!>!>>}}},{{},,e}},{,},{!>,},{{{},<>},{{<{"}!!}{,>,<>},{i!>,,,ae!>},e'>,!>>},{,{ai!!!>!"!>},,}}},{{<"!>o'u!>},!!!!!>!>,},<">,{}},{<{,!!!>!!!!a!!!>!!!>i!>},<>}}}},{{{<>}},{{>},},},,<>}},{{},},<"<{,!!!>,}>,},},!!!>!"!"!>,<>},{{}}}}}},{{{{{},<'u<'{!>i>}},{{!!!>,<>},},{{},<'<<'!!!>"}!!!!o}},{{},,},,a>},!!aa!!,!!!>!>!!'!,,'!>},},<{ea>}}},{{{{!}}!>!!!!!>a"o!>,},!>!!,o>},{{<'{',"{!!!>e!>,!>},<>},{!>a!!'!o>}}},{}},{{,<{>},{{{{,<'a}!!'!!!e'ue!>!>},<,!!!>{>}},},{},<}},{{<>},!!}e<'!!!>!!!>u,!}!>},<>}}},{{{!!!>a<}<>},{<'{>}},{},{{{!!e!>'>}}}}},{{{{!!!>!!!>'>,'i!!}a"},{{,{}},{}}}}}} -------------------------------------------------------------------------------- /resources/2017/day13: -------------------------------------------------------------------------------- 1 | 0: 3 2 | 1: 2 3 | 2: 4 4 | 4: 6 5 | 6: 5 6 | 8: 6 7 | 10: 6 8 | 12: 4 9 | 14: 8 10 | 16: 8 11 | 18: 9 12 | 20: 8 13 | 22: 6 14 | 24: 14 15 | 26: 12 16 | 28: 10 17 | 30: 12 18 | 32: 8 19 | 34: 10 20 | 36: 8 21 | 38: 8 22 | 40: 12 23 | 42: 12 24 | 44: 12 25 | 46: 12 26 | 48: 14 27 | 52: 14 28 | 54: 12 29 | 56: 12 30 | 58: 12 31 | 60: 12 32 | 62: 14 33 | 64: 14 34 | 66: 14 35 | 68: 14 36 | 70: 14 37 | 72: 14 38 | 80: 18 39 | 82: 14 40 | 84: 20 41 | 86: 14 42 | 90: 17 43 | 96: 20 44 | 98: 24 -------------------------------------------------------------------------------- /resources/2017/day18: -------------------------------------------------------------------------------- 1 | set i 31 2 | set a 1 3 | mul p 17 4 | jgz p p 5 | mul a 2 6 | add i -1 7 | jgz i -2 8 | add a -1 9 | set i 127 10 | set p 735 11 | mul p 8505 12 | mod p a 13 | mul p 129749 14 | add p 12345 15 | mod p a 16 | set b p 17 | mod b 10000 18 | snd b 19 | add i -1 20 | jgz i -9 21 | jgz a 3 22 | rcv b 23 | jgz b -1 24 | set f 0 25 | set i 126 26 | rcv a 27 | rcv b 28 | set p a 29 | mul p -1 30 | add p b 31 | jgz p 4 32 | snd a 33 | set a b 34 | jgz 1 3 35 | snd b 36 | set f 1 37 | add i -1 38 | jgz i -11 39 | snd a 40 | jgz f -16 41 | jgz a -19 -------------------------------------------------------------------------------- /resources/2017/day21: -------------------------------------------------------------------------------- 1 | ../.. => ###/#../.#. 2 | #./.. => ##./.#./... 3 | ##/.. => ..#/.#./#.# 4 | .#/#. => ..#/.#./..# 5 | ##/#. => .../.##/##. 6 | ##/## => ###/#../#.. 7 | .../.../... => .#../.#../#..#/##.. 8 | #../.../... => ####/####/.###/#### 9 | .#./.../... => ####/..../#.#./.#.# 10 | ##./.../... => ..##/###./...#/##.# 11 | #.#/.../... => .#../#..#/.#../#.#. 12 | ###/.../... => #.##/..##/##.#/..## 13 | .#./#../... => .##./#..#/..../.... 14 | ##./#../... => ##../.#../...#/#### 15 | ..#/#../... => ##../###./...#/.#.# 16 | #.#/#../... => ####/#.../..../##.. 17 | .##/#../... => #..#/..##/#..#/.... 18 | ###/#../... => #.##/####/..#./#.#. 19 | .../.#./... => #.##/.#.#/#.../...# 20 | #../.#./... => .###/##.#/..../###. 21 | .#./.#./... => ..#./.#../..../##.. 22 | ##./.#./... => ##../...#/..../.... 23 | #.#/.#./... => ####/.#../..#./.### 24 | ###/.#./... => ..#./.###/##../.##. 25 | .#./##./... => ###./#.#./.###/.##. 26 | ##./##./... => ...#/.#../.#../#### 27 | ..#/##./... => ..#./#.../##../###. 28 | #.#/##./... => #.../..../.#.#/.### 29 | .##/##./... => #.#./.#../####/.### 30 | ###/##./... => .#.#/#.#./##../#... 31 | .../#.#/... => #.##/##.#/..../#.#. 32 | #../#.#/... => ##../#.##/###./###. 33 | .#./#.#/... => ##../.#../#.##/###. 34 | ##./#.#/... => ##../##../..#./..#. 35 | #.#/#.#/... => #.../.##./.###/###. 36 | ###/#.#/... => ##.#/##../.##./#... 37 | .../###/... => ...#/####/..../#..# 38 | #../###/... => ##.#/##.#/.##./#.#. 39 | .#./###/... => .#../#.../.#.#/##.# 40 | ##./###/... => ##.#/#.#./#.../.#.. 41 | #.#/###/... => ..../#.../####/.#.. 42 | ###/###/... => .#../#..#/.#../.#.. 43 | ..#/.../#.. => .#.#/#.../..##/...# 44 | #.#/.../#.. => ####/####/###./...# 45 | .##/.../#.. => ####/.###/##.#/##.. 46 | ###/.../#.. => ..##/..../...#/#.#. 47 | .##/#../#.. => ###./..#./##.#/##.# 48 | ###/#../#.. => ##.#/...#/.##./.### 49 | ..#/.#./#.. => #.#./#.#./...#/#.#. 50 | #.#/.#./#.. => ###./.#.#/#.#./.#.. 51 | .##/.#./#.. => #.#./.##./.###/#.#. 52 | ###/.#./#.. => #.../#.../#.#./.### 53 | .##/##./#.. => .#.#/.##./..#./##.. 54 | ###/##./#.. => .###/.##./#.##/..## 55 | #../..#/#.. => #.#./#..#/###./.##. 56 | .#./..#/#.. => ###./.###/...#/..## 57 | ##./..#/#.. => ###./##../####/.#.# 58 | #.#/..#/#.. => ..#./.#../.##./.#.. 59 | .##/..#/#.. => ##.#/###./.##./#... 60 | ###/..#/#.. => ...#/..##/##.#/##.# 61 | #../#.#/#.. => #.../.##./.#.#/.### 62 | .#./#.#/#.. => #.##/...#/####/###. 63 | ##./#.#/#.. => .#../#.../.###/.... 64 | ..#/#.#/#.. => ####/###./.#.#/#... 65 | #.#/#.#/#.. => ###./..##/...#/#.## 66 | .##/#.#/#.. => ##.#/..#./..##/.#.# 67 | ###/#.#/#.. => #.#./..../##../.### 68 | #../.##/#.. => #..#/###./.#.#/##.# 69 | .#./.##/#.. => #.../.###/.##./.### 70 | ##./.##/#.. => .#../###./.#../##.# 71 | #.#/.##/#.. => .#../#.#./.#../#.## 72 | .##/.##/#.. => ##../###./.#.#/.### 73 | ###/.##/#.. => ..##/...#/#.../.#.. 74 | #../###/#.. => #.##/#..#/####/###. 75 | .#./###/#.. => .###/.#.#/#.#./..#. 76 | ##./###/#.. => ####/#.#./..##/#.## 77 | ..#/###/#.. => .###/##.#/.##./#.#. 78 | #.#/###/#.. => #.##/###./.###/.... 79 | .##/###/#.. => #.##/..../.#../#### 80 | ###/###/#.. => ##.#/###./.#../...# 81 | .#./#.#/.#. => ..#./##.#/.#../###. 82 | ##./#.#/.#. => ..##/###./..#./.#.# 83 | #.#/#.#/.#. => .#../..##/.#.#/.#.# 84 | ###/#.#/.#. => ##../#..#/.#../..#. 85 | .#./###/.#. => #.../#..#/.#.#/.... 86 | ##./###/.#. => ..../..##/..#./#### 87 | #.#/###/.#. => ..##/##.#/.###/...# 88 | ###/###/.#. => ##.#/#.##/..#./#.#. 89 | #.#/..#/##. => #.../####/#.##/.### 90 | ###/..#/##. => ###./...#/.#.#/#..# 91 | .##/#.#/##. => ..../.#.#/##.#/..## 92 | ###/#.#/##. => ###./.#../.#.#/###. 93 | #.#/.##/##. => ###./.#../.#../.#.# 94 | ###/.##/##. => .##./..../..../#.## 95 | .##/###/##. => ####/##../.###/##.# 96 | ###/###/##. => #..#/#.##/#.##/.#.. 97 | #.#/.../#.# => ####/#.#./#..#/.##. 98 | ###/.../#.# => .#../.#.#/.#../.#.# 99 | ###/#../#.# => ..#./..#./.###/#... 100 | #.#/.#./#.# => #.#./..../.##./#### 101 | ###/.#./#.# => #.../..##/.##./..#. 102 | ###/##./#.# => .#.#/##../#.#./..#. 103 | #.#/#.#/#.# => #.##/#.##/#.##/..## 104 | ###/#.#/#.# => .###/#.#./.##./..## 105 | #.#/###/#.# => ...#/#.#./..#./#..# 106 | ###/###/#.# => #.../#..#/#..#/.##. 107 | ###/#.#/### => .#.#/..##/##.#/#... 108 | ###/###/### => .###/#.#./#.../#... -------------------------------------------------------------------------------- /resources/2017/day22: -------------------------------------------------------------------------------- 1 | ....#.#...##..######.#... 2 | .#####.#.#..#..#.##.#.##. 3 | .#...#####.##....#.###.## 4 | .##.##.#.####.####.##.### 5 | #.#.##.#....###.#..####.# 6 | ..###...##..##...#.##.##. 7 | .......##.###.###.###.### 8 | #.#.#.#.....#.#..####.#.. 9 | ##...#..#.#..##..#.#.#### 10 | #..#.....##.###.....#.### 11 | .#.##..##.#####..##.###.. 12 | ##....###....#.#.#.####.# 13 | ###.#.#..#.#.#.###....##. 14 | ##.##...#.##.#.##...#.... 15 | ##....#.#.#.###...###.### 16 | ..##.###.#.####...###..#. 17 | ..##...##...#..##.#.##### 18 | .##...##..#.#.#..##...#.. 19 | #.#.#.#..#####..####..### 20 | ..###.#.#....#.####..#..# 21 | ....#.#.###...#..#..#.#.# 22 | ###.##..###..##...##..#.# 23 | ...#.##..#.##.###......#. 24 | .#..##.#####.#.##.....#.# 25 | #.....##..####.##.###..#. -------------------------------------------------------------------------------- /resources/2017/day23: -------------------------------------------------------------------------------- 1 | set b 67 2 | set c b 3 | jnz a 2 4 | jnz 1 5 5 | mul b 100 6 | sub b -100000 7 | set c b 8 | sub c -17000 9 | set f 1 10 | set d 2 11 | set e 2 12 | set g d 13 | mul g e 14 | sub g b 15 | jnz g 2 16 | set f 0 17 | sub e -1 18 | set g e 19 | sub g b 20 | jnz g -8 21 | sub d -1 22 | set g d 23 | sub g b 24 | jnz g -13 25 | jnz f 2 26 | sub h -1 27 | set g b 28 | sub g c 29 | jnz g 2 30 | jnz 1 3 31 | sub b -17 32 | jnz 1 -23 -------------------------------------------------------------------------------- /resources/2017/day24: -------------------------------------------------------------------------------- 1 | 31/13 2 | 34/4 3 | 49/49 4 | 23/37 5 | 47/45 6 | 32/4 7 | 12/35 8 | 37/30 9 | 41/48 10 | 0/47 11 | 32/30 12 | 12/5 13 | 37/31 14 | 7/41 15 | 10/28 16 | 35/4 17 | 28/35 18 | 20/29 19 | 32/20 20 | 31/43 21 | 48/14 22 | 10/11 23 | 27/6 24 | 9/24 25 | 8/28 26 | 45/48 27 | 8/1 28 | 16/19 29 | 45/45 30 | 0/4 31 | 29/33 32 | 2/5 33 | 33/9 34 | 11/7 35 | 32/10 36 | 44/1 37 | 40/32 38 | 2/45 39 | 16/16 40 | 1/18 41 | 38/36 42 | 34/24 43 | 39/44 44 | 32/37 45 | 26/46 46 | 25/33 47 | 9/10 48 | 0/29 49 | 38/8 50 | 33/33 51 | 49/19 52 | 18/20 53 | 49/39 54 | 18/39 55 | 26/13 56 | 19/32 -------------------------------------------------------------------------------- /resources/2017/day25: -------------------------------------------------------------------------------- 1 | Begin in state A. 2 | Perform a diagnostic checksum after 12368930 steps. 3 | 4 | In state A: 5 | If the current value is 0: 6 | - Write the value 1. 7 | - Move one slot to the right. 8 | - Continue with state B. 9 | If the current value is 1: 10 | - Write the value 0. 11 | - Move one slot to the right. 12 | - Continue with state C. 13 | 14 | In state B: 15 | If the current value is 0: 16 | - Write the value 0. 17 | - Move one slot to the left. 18 | - Continue with state A. 19 | If the current value is 1: 20 | - Write the value 0. 21 | - Move one slot to the right. 22 | - Continue with state D. 23 | 24 | In state C: 25 | If the current value is 0: 26 | - Write the value 1. 27 | - Move one slot to the right. 28 | - Continue with state D. 29 | If the current value is 1: 30 | - Write the value 1. 31 | - Move one slot to the right. 32 | - Continue with state A. 33 | 34 | In state D: 35 | If the current value is 0: 36 | - Write the value 1. 37 | - Move one slot to the left. 38 | - Continue with state E. 39 | If the current value is 1: 40 | - Write the value 0. 41 | - Move one slot to the left. 42 | - Continue with state D. 43 | 44 | In state E: 45 | If the current value is 0: 46 | - Write the value 1. 47 | - Move one slot to the right. 48 | - Continue with state F. 49 | If the current value is 1: 50 | - Write the value 1. 51 | - Move one slot to the left. 52 | - Continue with state B. 53 | 54 | In state F: 55 | If the current value is 0: 56 | - Write the value 1. 57 | - Move one slot to the right. 58 | - Continue with state A. 59 | If the current value is 1: 60 | - Write the value 1. 61 | - Move one slot to the right. 62 | - Continue with state E. -------------------------------------------------------------------------------- /resources/day1: -------------------------------------------------------------------------------- 1 | R3, L5, R2, L2, R1, L3, R1, R3, L4, R3, L1, L1, R1, L3, R2, L3, L2, R1, R1, L1, R4, L1, L4, R3, L2, L2, R1, L1, R5, R4, R2, L5, L2, R5, R5, L2, R3, R1, R1, L3, R1, L4, L4, L190, L5, L2, R4, L5, R4, R5, L4, R1, R2, L5, R50, L2, R1, R73, R1, L2, R191, R2, L4, R1, L5, L5, R5, L3, L5, L4, R4, R5, L4, R4, R4, R5, L2, L5, R3, L4, L4, L5, R2, R2, R2, R4, L3, R4, R5, L3, R5, L2, R3, L1, R2, R2, L3, L1, R5, L3, L5, R2, R4, R1, L1, L5, R3, R2, L3, L4, L5, L1, R3, L5, L2, R2, L3, L4, L1, R1, R4, R2, R2, R4, R2, R2, L3, L3, L4, R4, L4, L4, R1, L4, L4, R1, L2, R5, R2, R3, R3, L2, L5, R3, L3, R5, L2, R3, R2, L4, L3, L1, R2, L2, L3, L5, R3, L1, L3, L4, L3 -------------------------------------------------------------------------------- /resources/day10: -------------------------------------------------------------------------------- 1 | bot 147 gives low to bot 67 and high to bot 71 2 | bot 142 gives low to bot 128 and high to bot 164 3 | bot 47 gives low to bot 4 and high to bot 209 4 | bot 107 gives low to bot 194 and high to bot 103 5 | bot 102 gives low to bot 82 and high to bot 3 6 | bot 101 gives low to bot 46 and high to bot 111 7 | value 23 goes to bot 76 8 | bot 16 gives low to bot 203 and high to bot 32 9 | bot 30 gives low to output 20 and high to bot 31 10 | bot 170 gives low to bot 123 and high to bot 108 11 | value 3 goes to bot 122 12 | bot 176 gives low to bot 89 and high to bot 199 13 | value 43 goes to bot 117 14 | bot 190 gives low to bot 120 and high to bot 198 15 | bot 72 gives low to bot 14 and high to bot 37 16 | bot 122 gives low to bot 26 and high to bot 101 17 | bot 62 gives low to bot 88 and high to bot 85 18 | bot 184 gives low to bot 103 and high to bot 113 19 | bot 146 gives low to bot 47 and high to bot 7 20 | bot 133 gives low to bot 32 and high to bot 92 21 | bot 188 gives low to bot 79 and high to bot 97 22 | value 2 goes to bot 26 23 | bot 68 gives low to output 18 and high to output 5 24 | bot 139 gives low to bot 147 and high to bot 195 25 | bot 36 gives low to bot 166 and high to bot 116 26 | bot 99 gives low to bot 36 and high to bot 28 27 | bot 55 gives low to bot 134 and high to bot 182 28 | bot 132 gives low to bot 20 and high to bot 201 29 | bot 81 gives low to bot 126 and high to bot 153 30 | bot 177 gives low to output 16 and high to bot 12 31 | bot 23 gives low to bot 90 and high to bot 42 32 | bot 191 gives low to bot 157 and high to bot 73 33 | bot 3 gives low to bot 25 and high to bot 186 34 | bot 126 gives low to bot 83 and high to bot 24 35 | bot 105 gives low to bot 176 and high to bot 60 36 | bot 204 gives low to bot 102 and high to bot 118 37 | bot 199 gives low to bot 141 and high to bot 83 38 | bot 194 gives low to bot 63 and high to bot 197 39 | bot 161 gives low to bot 170 and high to bot 173 40 | bot 152 gives low to bot 92 and high to bot 4 41 | bot 53 gives low to bot 52 and high to bot 205 42 | bot 171 gives low to bot 137 and high to bot 91 43 | bot 71 gives low to bot 161 and high to bot 58 44 | bot 128 gives low to bot 192 and high to bot 164 45 | bot 118 gives low to bot 3 and high to bot 57 46 | bot 124 gives low to bot 86 and high to bot 87 47 | bot 93 gives low to bot 85 and high to bot 96 48 | bot 198 gives low to bot 172 and high to bot 44 49 | bot 100 gives low to bot 124 and high to bot 78 50 | bot 145 gives low to bot 91 and high to bot 168 51 | value 47 goes to bot 120 52 | bot 165 gives low to bot 57 and high to bot 158 53 | bot 138 gives low to bot 64 and high to bot 54 54 | value 5 goes to bot 150 55 | bot 29 gives low to bot 23 and high to bot 42 56 | bot 110 gives low to output 14 and high to bot 68 57 | bot 73 gives low to bot 156 and high to bot 29 58 | bot 49 gives low to bot 0 and high to bot 202 59 | bot 32 gives low to bot 10 and high to bot 51 60 | value 11 goes to bot 36 61 | bot 131 gives low to bot 98 and high to bot 151 62 | value 31 goes to bot 105 63 | bot 135 gives low to output 4 and high to bot 30 64 | bot 185 gives low to bot 171 and high to bot 145 65 | bot 67 gives low to bot 179 and high to bot 161 66 | bot 187 gives low to bot 37 and high to bot 125 67 | value 59 goes to bot 190 68 | bot 1 gives low to bot 155 and high to bot 128 69 | bot 10 gives low to bot 181 and high to bot 27 70 | bot 13 gives low to bot 188 and high to bot 22 71 | bot 182 gives low to bot 95 and high to bot 15 72 | bot 31 gives low to output 11 and high to bot 0 73 | bot 116 gives low to bot 193 and high to bot 147 74 | bot 17 gives low to bot 9 and high to bot 90 75 | bot 205 gives low to bot 130 and high to bot 204 76 | bot 169 gives low to bot 101 and high to bot 179 77 | bot 206 gives low to bot 159 and high to bot 2 78 | bot 42 gives low to bot 18 and high to bot 55 79 | value 17 goes to bot 63 80 | bot 19 gives low to bot 109 and high to bot 132 81 | bot 172 gives low to bot 184 and high to bot 44 82 | bot 125 gives low to bot 200 and high to bot 11 83 | bot 119 gives low to bot 177 and high to bot 180 84 | bot 26 gives low to bot 105 and high to bot 46 85 | bot 2 gives low to bot 112 and high to bot 146 86 | bot 61 gives low to bot 77 and high to bot 16 87 | bot 123 gives low to bot 153 and high to bot 206 88 | bot 40 gives low to output 8 and high to bot 181 89 | bot 103 gives low to bot 197 and high to bot 191 90 | bot 34 gives low to bot 19 and high to bot 48 91 | bot 25 gives low to bot 31 and high to bot 49 92 | value 67 goes to bot 194 93 | value 13 goes to bot 59 94 | bot 8 gives low to bot 167 and high to bot 1 95 | bot 56 gives low to bot 16 and high to bot 133 96 | bot 14 gives low to output 15 and high to bot 43 97 | bot 70 gives low to bot 125 and high to bot 64 98 | bot 164 gives low to bot 94 and high to bot 165 99 | bot 150 gives low to bot 122 and high to bot 169 100 | bot 95 gives low to bot 145 and high to bot 15 101 | bot 90 gives low to bot 34 and high to bot 18 102 | bot 148 gives low to bot 54 and high to bot 8 103 | bot 113 gives low to bot 191 and high to bot 50 104 | value 53 goes to bot 119 105 | bot 77 gives low to bot 104 and high to bot 203 106 | bot 82 gives low to bot 30 and high to bot 25 107 | bot 179 gives low to bot 111 and high to bot 170 108 | bot 141 gives low to bot 180 and high to bot 61 109 | bot 173 gives low to bot 108 and high to bot 183 110 | bot 109 gives low to bot 58 and high to bot 20 111 | bot 94 gives low to bot 118 and high to bot 165 112 | bot 0 gives low to output 7 and high to bot 21 113 | bot 104 gives low to output 3 and high to bot 40 114 | value 61 goes to bot 166 115 | bot 163 gives low to bot 151 and high to bot 52 116 | bot 193 gives low to bot 169 and high to bot 67 117 | bot 60 gives low to bot 199 and high to bot 126 118 | bot 195 gives low to bot 71 and high to bot 109 119 | bot 80 gives low to bot 100 and high to bot 78 120 | bot 137 gives low to bot 45 and high to bot 208 121 | bot 155 gives low to bot 205 and high to bot 192 122 | bot 50 gives low to bot 73 and high to bot 29 123 | bot 83 gives low to bot 61 and high to bot 56 124 | bot 88 gives low to bot 72 and high to bot 187 125 | bot 151 gives low to bot 160 and high to bot 41 126 | bot 52 gives low to bot 41 and high to bot 130 127 | bot 27 gives low to bot 5 and high to bot 72 128 | bot 78 gives low to bot 87 and high to bot 106 129 | bot 98 gives low to output 17 and high to bot 160 130 | bot 201 gives low to bot 185 and high to bot 95 131 | bot 111 gives low to bot 81 and high to bot 123 132 | bot 189 gives low to bot 162 and high to bot 124 133 | bot 51 gives low to bot 27 and high to bot 88 134 | bot 197 gives low to bot 13 and high to bot 157 135 | bot 160 gives low to output 6 and high to bot 74 136 | value 19 goes to bot 176 137 | bot 134 gives low to bot 201 and high to bot 182 138 | bot 200 gives low to bot 6 and high to bot 131 139 | bot 24 gives low to bot 56 and high to bot 207 140 | value 29 goes to bot 99 141 | value 71 goes to bot 89 142 | bot 159 gives low to bot 207 and high to bot 112 143 | bot 35 gives low to bot 7 and high to bot 175 144 | bot 143 gives low to bot 195 and high to bot 19 145 | bot 91 gives low to bot 208 and high to bot 66 146 | bot 92 gives low to bot 51 and high to bot 62 147 | bot 183 gives low to bot 121 and high to bot 137 148 | bot 39 gives low to bot 189 and high to bot 100 149 | bot 66 gives low to bot 84 and high to bot 140 150 | bot 112 gives low to bot 152 and high to bot 47 151 | bot 181 gives low to output 12 and high to bot 5 152 | bot 208 gives low to bot 35 and high to bot 84 153 | value 41 goes to bot 190 154 | bot 57 gives low to bot 186 and high to bot 158 155 | bot 41 gives low to bot 74 and high to bot 65 156 | bot 96 gives low to bot 70 and high to bot 138 157 | bot 74 gives low to output 2 and high to bot 135 158 | bot 4 gives low to bot 62 and high to bot 93 159 | bot 156 gives low to bot 17 and high to bot 23 160 | bot 6 gives low to output 9 and high to bot 98 161 | bot 65 gives low to bot 135 and high to bot 82 162 | bot 64 gives low to bot 11 and high to bot 149 163 | bot 45 gives low to bot 146 and high to bot 35 164 | bot 28 gives low to bot 116 and high to bot 139 165 | bot 149 gives low to bot 163 and high to bot 53 166 | bot 136 gives low to bot 96 and high to bot 127 167 | bot 48 gives low to bot 132 and high to bot 134 168 | bot 192 gives low to bot 204 and high to bot 94 169 | bot 166 gives low to bot 150 and high to bot 193 170 | bot 174 gives low to bot 129 and high to bot 69 171 | bot 18 gives low to bot 48 and high to bot 55 172 | bot 76 gives low to bot 115 and high to bot 172 173 | bot 108 gives low to bot 206 and high to bot 121 174 | bot 79 gives low to bot 28 and high to bot 38 175 | bot 97 gives low to bot 38 and high to bot 9 176 | bot 15 gives low to bot 168 and high to bot 114 177 | bot 37 gives low to bot 43 and high to bot 200 178 | bot 175 gives low to bot 75 and high to bot 189 179 | bot 84 gives low to bot 175 and high to bot 39 180 | bot 162 gives low to bot 127 and high to bot 86 181 | bot 167 gives low to bot 53 and high to bot 155 182 | bot 168 gives low to bot 66 and high to bot 114 183 | bot 129 gives low to bot 144 and high to bot 69 184 | bot 89 gives low to bot 119 and high to bot 141 185 | bot 69 gives low to bot 110 and high to bot 68 186 | bot 130 gives low to bot 65 and high to bot 102 187 | bot 5 gives low to output 19 and high to bot 14 188 | bot 54 gives low to bot 149 and high to bot 167 189 | bot 127 gives low to bot 138 and high to bot 148 190 | bot 153 gives low to bot 24 and high to bot 159 191 | bot 117 gives low to bot 59 and high to bot 188 192 | bot 144 gives low to output 1 and high to bot 110 193 | bot 63 gives low to bot 117 and high to bot 13 194 | bot 44 gives low to bot 113 and high to bot 50 195 | bot 114 gives low to bot 140 and high to bot 80 196 | bot 115 gives low to bot 107 and high to bot 184 197 | bot 207 gives low to bot 133 and high to bot 152 198 | bot 33 gives low to bot 8 and high to bot 196 199 | bot 59 gives low to bot 99 and high to bot 79 200 | bot 140 gives low to bot 39 and high to bot 80 201 | bot 202 gives low to bot 21 and high to bot 129 202 | value 7 goes to bot 107 203 | bot 11 gives low to bot 131 and high to bot 163 204 | bot 21 gives low to output 0 and high to bot 144 205 | bot 106 gives low to bot 196 and high to bot 142 206 | bot 121 gives low to bot 2 and high to bot 45 207 | bot 154 gives low to bot 183 and high to bot 171 208 | bot 157 gives low to bot 22 and high to bot 156 209 | bot 203 gives low to bot 40 and high to bot 10 210 | bot 12 gives low to output 10 and high to bot 104 211 | bot 186 gives low to bot 49 and high to bot 178 212 | bot 43 gives low to output 13 and high to bot 6 213 | bot 196 gives low to bot 1 and high to bot 142 214 | bot 22 gives low to bot 97 and high to bot 17 215 | bot 38 gives low to bot 139 and high to bot 143 216 | bot 209 gives low to bot 93 and high to bot 136 217 | bot 9 gives low to bot 143 and high to bot 34 218 | bot 180 gives low to bot 12 and high to bot 77 219 | bot 7 gives low to bot 209 and high to bot 75 220 | value 37 goes to bot 115 221 | bot 120 gives low to bot 76 and high to bot 198 222 | bot 75 gives low to bot 136 and high to bot 162 223 | bot 20 gives low to bot 154 and high to bot 185 224 | bot 178 gives low to bot 202 and high to bot 174 225 | bot 86 gives low to bot 148 and high to bot 33 226 | value 73 goes to bot 177 227 | bot 85 gives low to bot 187 and high to bot 70 228 | bot 158 gives low to bot 178 and high to bot 174 229 | bot 46 gives low to bot 60 and high to bot 81 230 | bot 87 gives low to bot 33 and high to bot 106 231 | bot 58 gives low to bot 173 and high to bot 154 -------------------------------------------------------------------------------- /resources/day12: -------------------------------------------------------------------------------- 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 13 c 18 | cpy 14 d 19 | inc a 20 | dec d 21 | jnz d -2 22 | dec c 23 | jnz c -5 -------------------------------------------------------------------------------- /resources/day2: -------------------------------------------------------------------------------- 1 | UUURRRRULRDLRDRRDURDDDLLDLLLULDUDDLDLULUURULRLDLRRLLLRRDRRLDDLLULUDUDDLRDRDUURDLURUURLRULLDDURULRRURDUURLULUUUURDDDDUUDLULRULLLRLLRRRURDLLRLLRRRUURULRDRUUDDDDDLLLRURRURRUURDUURDDRDLULRRLLLDRRRLURRLLURLDRRDDLDLRRLLRDRLLLLDLULDLRRDRRLDDURLULLUDLUDRRDRRLRLULURDRLRLUUUDLRLDLLLURDUDULULDDRUUURLLLDLLDDUDDRURURUDDLUULRDRRRRLDRDDURLUDURDULLDLUDLULDRLRLLRLLLLRURDURLLDRRDRLRUUUUULLLRUDURUDLLLUDLLLLRDLDRDUDRURLUDDUDDURLUUUUDDLLUDLULLLLLDUDLLRLRRDDDULULRLDRLLULDLUDLLURULRDDUURULRDLDLDLRL 2 | URUUURDULUDLUUUUDDRRRDRRRLDUDLRDRRDRDDLRUULDLLDUDULLLRLDRDRRLDLDLUUDRUULDUDULDUDURURDDURULDLURULRLULDUDDUULDLLLDDURDDRDDURUULUUDRLDDULDRRRRDURRUDLLLURDDDLRULLRDDRDDDDLUUDRDUULRRRRURULDDDLDDRDRRUDRRURUDRDDLDRRRLLURURUULUUDRDULLDRLRDRRDDURDUDLDRLUDRURDURURULDUUURDUULRRRRRUDLLULDDDRLULDDULUDRRRDDRUDRRDLDLRUULLLLRRDRRLUDRUULRDUDRDRRRDDRLLRUUDRLLLUDUDLULUUDULDRRRRDDRURULDULLURDLLLDUUDLLUDRLDURRRLDDDURUDUDURRULDD 3 | LRUDDULLLULRLUDUDUDRLLUUUULLUDLUUUUDULLUURDLLRDUDLRUDRUDDURURRURUDLLLRLDLUDRRRRRRDLUURLRDDDULRRUDRULRDRDDUULRDDLDULDRRRDDLURRURLLLRURDULLRUUUDDUDUURLRLDDUURLRDRRLURLDRLLUUURDRUUDUUUDRLURUUUDLDRRLRLLRRUURULLLRLLDLLLDULDDLDULDLDDRUDURDDURDUDURDLLLRRDDLULLLUDURLUDDLDLUUDRDRUDUUDLLDDLLLLDRDULRDLDULLRUDDUULDUDLDDDRUURLDRRLURRDDRUUDRUDLLDLULLULUDUDURDDRLRDLRLDRLDDRULLLRUDULDRLRLRULLRLLRRRLLRRRDDRULRUURRLLLRULDLUDRRDDLLLUDDUDDDLURLUDRDLURUUDLLDLULURRLLDURUDDDDRLULRDDLRLDDLRLLDDRRLRDUDUUULRRLRULUDURDUDRLRLRUDUDLLRRRRLRRUDUL 4 | RULLLLUUUDLLDLLRULLRURRULDDRDLUULDRLLRUDLLRRLRDURLLDUUUUURUUURDLUURRLDDDLRRRRLRULDUDDLURDRRUUDLRRRDLDDUDUDDRUDURURLDULLDLULDLLUDLULRDRLLURRLLDURLDLRDLULUDDULDLDDDDDUURRDRURLDLDULLURDLLDDLLUDLDLDRLRLDLRDRLDLRRUUDRURLUUUDLURUULDUDRDULLDURUDLUUURRRLLDUDUDDUUULLLRUULDLURUDDRLUDRDDLDLLUDUDRRRDDUUULUULLLRLLUURDUUDRUUULULLDLDRUUDURLLUULRLDLUURLLUUDRURDDRLURULDUDUUDRRUUURDULRLDUUDDRURURDRRULDDDRLUDLLUUDURRRLDLRLRDRURLURLLLRLDDLRRLDLDDURDUUDRDRRLDRLULDRLURUUUDDRLLLDDLDURLLLLDRDLDRRUDULURRLULRDRLLUULLRLRDRLLULUURRUDRUDDDLLDURURLURRRDLLDRDLUDRULULULRLDLRRRUUDLULDURLRDRLULRUUURRDDLRUURUDRURUDURURDD 5 | DURRDLLLDDLLDLLRLULULLRDLDRRDDRDLRULURRDUUDDRLLDDLDRRLRDUDRULDLRURDUUDRDDLLDRRDRUDUDULLDDDDLDRRRLRLRDRDLURRDDLDDDUUDRDRLLLDLUDDDLUULRDRLLLRLLUULUDDDRLDUUUURULRDDURRDRLUURLUDRLRLLLDDLRDDUULRRRRURDLDDDRLDLDRRLLDRDDUDDUURDLDUUDRDLDLDDULULUDDLRDDRLRLDDLUDLLDRLUDUDDRULLRLDLLRULRUURDDRDRDRURDRRLRDLLUDDRRDRRLDDULLLDLUDRRUDLDULDRURRDURLURRLDLRDLRUDLULUDDRULRLLDUURULURULURRLURRUULRULRRRLRDLULRLRLUDURDDRUUURDRLLRRRDDLDRRRULLDLRDRULDRRLRRDLUDDRDDDUUURRLULLDRRUULULLRRRRLDDRDDLUURLLUDLLDUDLULUULUDLLUUURRRUDDDRLLLRDRUUDUUURDRULURRLRDLLUURLRDURULDRRUDURRDDLDRLDRUUDRLLUDLRRU -------------------------------------------------------------------------------- /resources/day21: -------------------------------------------------------------------------------- 1 | rotate left 2 steps 2 | rotate right 0 steps 3 | rotate based on position of letter a 4 | rotate based on position of letter f 5 | swap letter g with letter b 6 | rotate left 4 steps 7 | swap letter e with letter f 8 | reverse positions 1 through 6 9 | swap letter b with letter d 10 | swap letter b with letter c 11 | move position 7 to position 5 12 | rotate based on position of letter h 13 | swap position 6 with position 5 14 | reverse positions 2 through 7 15 | move position 5 to position 0 16 | rotate based on position of letter e 17 | rotate based on position of letter c 18 | rotate right 4 steps 19 | reverse positions 3 through 7 20 | rotate left 4 steps 21 | rotate based on position of letter f 22 | rotate left 3 steps 23 | swap letter d with letter a 24 | swap position 0 with position 1 25 | rotate based on position of letter a 26 | move position 3 to position 6 27 | swap letter e with letter g 28 | move position 6 to position 2 29 | reverse positions 1 through 2 30 | rotate right 1 step 31 | reverse positions 0 through 6 32 | swap letter e with letter h 33 | swap letter f with letter a 34 | rotate based on position of letter a 35 | swap position 7 with position 4 36 | reverse positions 2 through 5 37 | swap position 1 with position 2 38 | rotate right 0 steps 39 | reverse positions 5 through 7 40 | rotate based on position of letter a 41 | swap letter f with letter h 42 | swap letter a with letter f 43 | rotate right 4 steps 44 | move position 7 to position 5 45 | rotate based on position of letter a 46 | reverse positions 0 through 6 47 | swap letter g with letter c 48 | reverse positions 5 through 6 49 | reverse positions 3 through 5 50 | reverse positions 4 through 6 51 | swap position 3 with position 4 52 | move position 4 to position 2 53 | reverse positions 3 through 4 54 | rotate left 0 steps 55 | reverse positions 3 through 6 56 | swap position 6 with position 7 57 | reverse positions 2 through 5 58 | swap position 2 with position 0 59 | reverse positions 0 through 3 60 | reverse positions 3 through 5 61 | rotate based on position of letter d 62 | move position 1 to position 2 63 | rotate based on position of letter c 64 | swap letter e with letter a 65 | move position 4 to position 1 66 | reverse positions 5 through 7 67 | rotate left 1 step 68 | rotate based on position of letter h 69 | reverse positions 1 through 7 70 | rotate based on position of letter f 71 | move position 1 to position 5 72 | reverse positions 1 through 4 73 | rotate based on position of letter a 74 | swap letter b with letter c 75 | rotate based on position of letter g 76 | swap letter a with letter g 77 | swap position 1 with position 0 78 | rotate right 2 steps 79 | rotate based on position of letter f 80 | swap position 5 with position 4 81 | move position 1 to position 0 82 | swap letter f with letter b 83 | swap letter f with letter h 84 | move position 1 to position 7 85 | swap letter c with letter b 86 | reverse positions 5 through 7 87 | rotate left 6 steps 88 | swap letter d with letter b 89 | rotate left 3 steps 90 | swap position 1 with position 4 91 | rotate based on position of letter a 92 | rotate based on position of letter a 93 | swap letter b with letter c 94 | swap letter e with letter f 95 | reverse positions 4 through 7 96 | rotate right 0 steps 97 | reverse positions 2 through 3 98 | rotate based on position of letter a 99 | reverse positions 1 through 4 100 | rotate right 1 step -------------------------------------------------------------------------------- /resources/day23: -------------------------------------------------------------------------------- 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 81 c 21 | jnz 94 d 22 | inc a 23 | inc d 24 | jnz d -2 25 | inc c 26 | jnz c -5 -------------------------------------------------------------------------------- /resources/day24: -------------------------------------------------------------------------------- 1 | ##################################################################################################################################################################################### 2 | #.....#...#.#...............#...........#.......#.#...#.......#...#.......#.....#.............#.........#...#.........#.......#.#.#4....#.....#...#.......#.........#.#.....#.......# 3 | ###.###.#.#.###.###.#.#####.#.###.#.###.#.#.#.#.#.#.#.###.###.#.#.#.###.#.#.###.#.###.#.#.#######.#.#.#.###.#.#.#.###.#.#####.#.#.###.###.#.###.#.###.#.#.#.###.###.#.#.#.#.#.#.#.### 4 | #...#.....#.....#...#.......#.#.#.#.#...#.....#.#...#.....#...#...#.#...#.#.......#.....#.#.........#...#.#.#...#...#.........#...#.......#.#...#.........#.#...#...#.#.#.#.....#...# 5 | #.###.###.#.#.#.#.#######.#.#.#.#.#.###.#.#.###.#.###.#.###.#.#.#.#########.###.#.#.#.###.###.#.###.###.#.#.#.#.#####.#.###.#.#.###.#.#.#.#.###.###.#.#####.#.#####.#.###.#.###.#.#.# 6 | #.#.....#.#.....#.....#...#.....#.#...#...#.#.......#.#.#.....#.......#...#...#.#.#.#.....#...#.#.#.....#...#.#.#...........#...#...#.#.#.....#...........#.#.#.......#.............# 7 | #.#####.#####.#.#####.#.#.#.###.#.#.#.#.#.#####.#.#.#.#.#.#.#.#.#.#.#.#.#.#.#.###.#.###.#.#.#.###.#.#.#.###.#.#.#.###.#.#.###########.#.###.#.#.#.#.#.#.#.#####.#.###.#.#####.###.#.# 8 | #...#.....#.......#.#.#.#...#...#...#.#.#.......#.....#.........#.#...........#.#.........#.#.....................#.......#.....#.............#.........#.....#.....#...#.#.#.......# 9 | #.###.#.#.#.#.#.#.#.###.#.#.#.#.#.#.#.#####.#####.#.###.#.#.###.#.#####.###.#.#.#.#######.#.#.#######.#.#.###.#.#.#.#######.###.###.###.#######.#.#####.#.#.#.#.###.###.#.#.#######.# 10 | #...............#...#.#6..#...#...#...#...#.........#...#.#.....#.....#...#.#.....#.......#...#.#.....#...#.....#.........#...........#.#...........#...#0..#.............#.#...#...# 11 | #.#.#####.#########.#.#####.#.#.#######.#.#.#.#.###.###.#.###.#.#####.#.#.#.#########.#.#######.#.#.#.#.#.#.#.#.#.###.###.#.#.#######.###.#########.#.#.###.#.#.#.#.#.###.#.#.###.#.# 12 | #.#.....#.#.#...#.....#.....#...#.............#...#.......#...#...#...#.#.#.....#.#...#.......#.#...#.......#.#...#...#.......#.....#...#...#...#.#...#.....#.#...#...#.#...#.#...#.# 13 | #.###.#.###.#.#.#.###.###.#.###.#.#.###.#####.#####.#.#####.###.#.#######.###.#.#.#########.###.#.#.#.###.#.#.###.###.#.###.###.###.#.#.#####.###.#.#.###.#.#.###.#.###.#####.#.###.# 14 | #.#.........#.#.........#.......#...#.........#.................#.....#.#.......#.#.....#.#.....#.#.........#.....#.#.......#.#.............#.....#...#.....#.....#.......#.......#.# 15 | ###.#####.#.#.#.#.#.###.#.#.#.#.#.#.#.#.#.###.#.#.#.#.###.###.#.#.#.###.#.#.###.#.#.#.###.#.#.#####.###.###.#.###.#.###.###.#.###.#.###.#####.#.#.#.#####.#.#.#.#####.###.#.#.###.#.# 16 | #...#...#.#...#.....#...#...#...#...#.#.......#.#.#.....#...#.#.....#.........#.#...#.......#.......#.#...#.....#...#.............#...............#.....#.#.....#...#.#...#.........# 17 | #.###.#.#.#.#.#.#.#.#.#####.#####.#.#####.#######.#####.#.#########.###.#.###.#.#.###.#.#.#.#.#.#.#.#.#.#.###.#.###.#.#.#.#.###.#.#.#.###.#####.###.#.#.#.#.#.#.#.#.#.#.#.#.#####.### 18 | #.#.....#...#.......#...#.#.#.#.#...#...#...#...#...................#...........#.....#.#...#.........#.#.......#.#...#.#.#.#...................#...#...#.#...#.....#.#1#.....#.....# 19 | ###.#.#####.#.#.#.#.###.#.###.#.#.#.#.#.###.#.#.#.#.#.#.#####.###.###.#.#.#.#.#.#.###.#.#.#.###.#######.#.###.#.#.#.#.###.#.#########.#.#.#.#.#.###.#.#.#####.###.#.#########.#.#.#.# 20 | #.#...#.....#.....#...#.#.#...#.......#...#.....#.#...#.....#...#.....#...#.#.....#.......#...#...#.......#...#...#...#...#...........#.#.....#...#.........#.#.....#.#.#.......#...# 21 | #.#.#.#.#####.#.#.###.#.#.#.#.#.###.#.###.#.#.###.#.#.###.#.###.#.###.#####.#.#.#.#.#.#.###.#.#.#.#.#.###.#####.#.#.###.#.#.###.#.#.#.#.#.#.#.#####.#.#.###.#.#.###.#.#.###.#.#.###.# 22 | #.....#7#.#...#.#.................#...............#.#.#...#.#...#.#...#.....#...#.....#...#.#.#.......#...#...........#...........#.#.....#...#.........#.#.......#.#.#.....#.......# 23 | #.#.#.###.#.#.###.#.#.#.#.#.#.###.#.#.#.###.#.###.#.#.#.#.#.#.#.###.#.#.#.#####.#.#.#.###.#.#.#####.#.#.###########.#.#####.#.#.#.###.#.#.#.#.#####.#.###.###.#.###.#.#.###.#.####### 24 | #.#.....#.#.#.#...........#.#.#.......#...........#...#.......#...#.#...#.....#.#.....#...#.....#.#.......#.#.#.......#.#.......#.............#.#...#.#.#.#...........#.......#.....# 25 | #.#####.#####.#.#.###.#.#.#.#.#####.#.#.#.###.###.#.#.#.#.#######.#.#.#.#.###.#.#.#.#.#.#.#######.#.###.###.#.#.#.#.#.#.#.#.#####.#.#.#######.#.#.###.#.#.#####.###.###.#.#.#.#.#.#.# 26 | #.......#.#...#.....#...#.......#...#...#.....#...#.#...#...#.....#.#.#.#.....#.#.....#.....#...#...#...#.....#.#...#.#...#...#.............#.#...#.....#...#.....#.....#.#.....#.#.# 27 | #.#.#####.#.###.#########.###.#.#.#.###.#.#.###.#.#.#.#.#.#.#.###.#.###.###.###.#####.#.###.#.#.#.#.#.#.#.###.#####.#.#.#.#.#.###.#.#.#.###.#.###.###.#.#.#.#.###.#.###.###.###.#.### 28 | #...#.....#.#.#.#.........#...#.....#.........#...#.....#.....#.....#...................#.......#...#...#.....#.......#...#...#.......#.....#.#...#.#...#.#.........#.#.#...#.#.#...# 29 | ###.#.#.#.#.#.#.#.###.#.#.#######.###.#######.#####.#.#.#.###.#.#.###.#######.###.#.###.###########.#.#####.###.#####.#.#######.#########.###.###.#.#.#.#.#.#.#.#.#.#.###.#.#.#.#.#.# 30 | #.....#...............#.............#...#.#.#.........#.#.....#...#.....#...#.....#.#.....#...#.#...#.#.....#.........#.#...............#.#.#...#.......#.#.....#.#...............#.# 31 | #.#.###.#.###.###.#.#.#.#.###.#.#.#.#.#.#.#.#####.#.###.#.#.#.#.#.#.#.###.#.###.#.#.#.#.#.###.#.#.#.###.###.#.#####.#.#.#.#.#.#.#######.#.#.###.###.#.#.#.#.#.#.#.#.#####.#####.#.### 32 | #...#...#...............#.......#...#.....#.....#.#...#.........#.#...#...#.....#...#.#...#...#...#...#.....#.#.....#.....#.#...#.....#.........#.........#.......#.......#3........# 33 | #####.#.###.#.#.###.#####.#.#.#.###.#.#.#####.#.#.###.#.#.###.#.###.#.#.#.#.#.#.#.#.#.#.#.###.#.#####.#.#.#.#.#######.###.#.#####.#.#.#.#####.#.#.#######.#.###.###.#.#####.#.#.#.#.# 34 | #.#...#...#...#.......#.....#...#.#...............#.#...#...#.#.....#.#.....#.#.#...#...#.........#.....#...#...........#.#.#.........#...........#...................#.....#.#.....# 35 | #.#.###.#.#.#.#.#.###.#.#.#.#.#.#.#.#####.#.#######.#.###.###############.#.###.#.#.#.#.#####.###.#.#####.#.#.#.#.#.###.#.#.#.#.###.#.#.###.#.#####.#.#.#####.#########.#####.###.### 36 | #.#.#.....#.....#...#...#...#.....#.........#.#...#...#.........#...#...#.......#.............#.............#.#.....#.#...#.#.......#...#.#.#...#.....#.#.......#...#...#.....#...#.# 37 | #.#.#.#.#.#######.#.#.###.###.###.###.#.###.#.#.#.#.#.#.#.#.###.#.#.#########.#.#.###.###.#.#.#.#.#.#.#######.#.#####.#.#.#######.#.#.#.#.###.#.#.###.#.#####.#.#.#.#.#.#.#######.#.# 38 | #.#.#.#...#...........#.#.....#.#...#.#.#.#.......#.#.....#...#.#...#.#.#...#...#.#.#.......#...#.#.....#.........#.....#.....#.#.....#...#.#.....#...#...#.......#.....#.....#.....# 39 | #.#.#.###.#.#.###.###.#.#.#.#.#.#######.#.###.#####.###.#.#.#.###.#.#.#.###.#.###.#.###.#.###.#.#.#.###.#.#.#####.###.###.#.###.###.#.#.###.#####.#.#.###.###.###.#.###.###.#.#.#.#.# 40 | #...#.................#.............#...#...#.......#.....#.#.#.........#...#...#.......#.#...#.....#...#.#.......#.#.......#.#...#.#.#.............#.....#...#.#...#.....#.#.#.....# 41 | #.#.#####.#.#.#.###.#.###.#########.#.#.###.#.#.###.#.###.#.###.#####.#.#.#.#.#.#.#####.#.#.#.#####.#.#.#######.#.#.#.#####.#.#.#.#####.#.#.#.###.#####.#.#.###.#.#.#.###.#.###.#.#.# 42 | #5....#...#.#...........#...#...#.#.#.#...#.#.#.....#...........#...#.#.......#.....#...#.........#.#.#.#.......#.#...#...#...#.#.#........2#...#.#...#...#.#...#.#...#.......#...#.# 43 | ##################################################################################################################################################################################### -------------------------------------------------------------------------------- /resources/day25: -------------------------------------------------------------------------------- 1 | cpy a d 2 | cpy 4 c 3 | cpy 633 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 -------------------------------------------------------------------------------- /resources/day6: -------------------------------------------------------------------------------- 1 | eqvmfqnf 2 | jvkezmqt 3 | zcssqwlw 4 | cuacncgg 5 | ikmpzpoh 6 | dzpzobdl 7 | qlsnuhuq 8 | fwqnoklz 9 | cibgplfq 10 | ktsqfcrv 11 | vcknjnnx 12 | upaiaprz 13 | bpqmolbq 14 | dflhnpnk 15 | heqjflch 16 | cmewgodc 17 | aaorgxkn 18 | plekphpw 19 | fcofrbnm 20 | bmnrygtb 21 | rqsqsqio 22 | rnlntwxa 23 | cxjqqfyl 24 | jxjnxchb 25 | kfgutxmi 26 | cbciszxd 27 | irakoonu 28 | pcgfnycg 29 | fgeivexo 30 | ujxdaehw 31 | ejkvrych 32 | nhlklbgr 33 | etjuhgry 34 | mkgkmykm 35 | teuhrfto 36 | juqfslbn 37 | tbwxabzi 38 | ngdnwsey 39 | amcibkyo 40 | xlvxwqpj 41 | vdbzuvkh 42 | gkagbzep 43 | kqxzkeip 44 | bxccztho 45 | vqrywqlc 46 | jbzhecjc 47 | ozkulgxo 48 | uiwbofuk 49 | vfwhdnao 50 | tycxucwd 51 | jvhuljfs 52 | xxhqhruc 53 | upnndiiz 54 | andxywil 55 | lowofbqv 56 | iroqzrry 57 | nmkkqqjb 58 | daijrfna 59 | jmcstxlq 60 | jdefvuaa 61 | nkbmowfi 62 | agotazda 63 | kufoymrn 64 | yijwfjyi 65 | hyqvaouj 66 | soueuhln 67 | oomsbkmh 68 | buadtssf 69 | rvgpeeza 70 | hjiymcmd 71 | ebgivdap 72 | xzieipbg 73 | ttpudwqt 74 | hndwuncw 75 | wqypfkvf 76 | jqxuaipm 77 | fzwlgxxq 78 | ddshbtya 79 | ardlcgyi 80 | soznvuyw 81 | vyizuolp 82 | ckfaxyvs 83 | nbsjkibi 84 | lsrkrdzp 85 | oqoffwxa 86 | bdugjlsm 87 | rtcsylfd 88 | fezoiliq 89 | zwpaphcb 90 | sdlouhyf 91 | cfejwvls 92 | xehddxku 93 | edhrtdcv 94 | ehouagvy 95 | hoyxjfsj 96 | quggpnpx 97 | muqbijbe 98 | rcnniddd 99 | kzfeiaui 100 | sywienef 101 | xpxftuvq 102 | dtbhnslt 103 | mpcpkmfa 104 | wysutlci 105 | fmqomicz 106 | mhshprxr 107 | uxwfcftt 108 | ehbonsrl 109 | pjobilxx 110 | chiebfox 111 | lqfxgyqg 112 | vupcjatm 113 | wfljafhc 114 | iygojeny 115 | gqxmgneu 116 | nhlwllak 117 | xnkqpulv 118 | awijbvef 119 | pbcrrwqo 120 | dobsejtb 121 | dqdoapkc 122 | hngrxdtx 123 | dodsxysb 124 | bmtyelak 125 | cctuwwvt 126 | rytlmoyr 127 | fqnbuxdi 128 | irrqladc 129 | wnvtsneg 130 | ugqqdmlj 131 | nljnjiod 132 | knidxxzh 133 | dfymoqgt 134 | fwgtjafh 135 | fpdioivz 136 | tqbewmti 137 | mcqtbbee 138 | pivfrpou 139 | tdyguuos 140 | eldmvvmi 141 | oaiqnizz 142 | fyqpxgwa 143 | lzcxsazq 144 | zhsoljwz 145 | qnzafmjl 146 | oopnnndl 147 | cozehoor 148 | bspuwzxm 149 | ubtunnep 150 | smdhpvxr 151 | nsvxiwje 152 | mmqcklsm 153 | hhxaciaq 154 | zzgoxhws 155 | fvntouun 156 | skxzmzyg 157 | znptwuqu 158 | aknwvojo 159 | wftmjrsf 160 | gahrordj 161 | oegnykag 162 | lvlqswph 163 | qsowvoem 164 | sjspasfp 165 | ygjohzfd 166 | jeuxigsi 167 | lgxdtudx 168 | qadlkrel 169 | lpfxosdq 170 | sgaoqkzr 171 | rtlvuhfv 172 | ftbbsgbn 173 | kjxttiqu 174 | gylikswu 175 | lquhgmrs 176 | hxrjagjm 177 | epxxekgx 178 | uwwlcbrx 179 | feincdjp 180 | uyxhfhsc 181 | nojuykoh 182 | psjuuqwu 183 | gtlohqkz 184 | sbzsbgrw 185 | nbhwuxfb 186 | phmtunrh 187 | zmfbkvgv 188 | mjumfpia 189 | gkubcshe 190 | jmavrhyd 191 | cgffkftg 192 | msurhdct 193 | bvchukal 194 | psxaluvg 195 | tvgwjhhp 196 | chyizcxv 197 | dumebzkd 198 | cjpzbkzk 199 | ngrgseyn 200 | xmwcmaaz 201 | puyrbiup 202 | xxkpznis 203 | rguwrpua 204 | jmolhvnn 205 | kpeqtlan 206 | zzgvoxlp 207 | erbintcn 208 | kcykvysv 209 | ixildajc 210 | tnvgihwe 211 | iqwgozpj 212 | txkgyflb 213 | vsyzebrw 214 | ehnbcjef 215 | hfevkbhf 216 | wihlqtmp 217 | vmrmnygo 218 | ulvsuvsn 219 | wgxnwihd 220 | lexgbpsv 221 | kxqcjoeb 222 | daodpsbb 223 | azyqmyhv 224 | mvzcatwb 225 | jtvqkjrv 226 | rtdsaqqd 227 | xrhzmnzl 228 | wgfiwjrh 229 | hgrgqqxm 230 | nwwcxoyq 231 | qlqyhpzs 232 | ovujfily 233 | pzvyeryk 234 | strswprn 235 | nrxclypc 236 | sfusjxzi 237 | pclbdadw 238 | sjhggndb 239 | xjcutuyt 240 | qjjjeytj 241 | qqjrkdlb 242 | pyzodjdh 243 | brnmlkmi 244 | lgipidfp 245 | ttrfbjry 246 | iidwekro 247 | vnwlnyma 248 | ylxatduo 249 | eiokdbqr 250 | laezjjte 251 | kkjhfsvp 252 | buaegtpg 253 | vzgqletc 254 | pkdseade 255 | nvpyxokq 256 | yiysgxpe 257 | xqhtubam 258 | lcstpvke 259 | nnskqssg 260 | mkrbdovg 261 | camkeppm 262 | iqjvotay 263 | bodlfgkj 264 | jiigwvzc 265 | ixpghywy 266 | qlzyjgue 267 | ugyjqtzn 268 | odeuuiir 269 | yfhianfx 270 | seewayqj 271 | lstpeuja 272 | paqqnxsr 273 | guwkidny 274 | susussgu 275 | ezcayehr 276 | tdzgvcqf 277 | vckcnsio 278 | obawbapm 279 | ipebazzk 280 | tmcpmiou 281 | hpdlfwor 282 | ygxlfzzr 283 | ltyxhtbx 284 | olzqonbx 285 | grsxreqs 286 | bvkjcoux 287 | fxtuxuub 288 | fcbxdenm 289 | smilcfvz 290 | ewbndkiz 291 | httsnfqu 292 | ghorvefw 293 | anevvqir 294 | sajdzwho 295 | becdemdn 296 | vxktmxsj 297 | xyawkeuw 298 | pdefbxmh 299 | yejymgfr 300 | mipvhnsc 301 | tjdyqpzd 302 | rbvqirmd 303 | mscuflvd 304 | draqqcda 305 | xfegqcjg 306 | auypywpb 307 | gitgzstq 308 | zveqbzgt 309 | wxrpedre 310 | haptyecu 311 | tkeexmhe 312 | ujijprbd 313 | xjiyczwq 314 | ehpygnrr 315 | guvejwyt 316 | zmtsftky 317 | wqtklwiz 318 | lwlessio 319 | lrknmhzd 320 | pkdkwevt 321 | ncryoeth 322 | hjsqtpxu 323 | ivmqrwok 324 | qozgijgu 325 | ueujvbbe 326 | nfxgrmsd 327 | zeetrgdl 328 | drfbcgxo 329 | rjjeraeb 330 | hshozlgv 331 | sfgvrnez 332 | zaoctlsa 333 | hebtzqvy 334 | qckvuyif 335 | wxyszmev 336 | ddxfwklt 337 | jqlzpfvu 338 | wimoefwx 339 | kabvtrno 340 | pbebkvkm 341 | govfwjof 342 | xfjkvoup 343 | fuzxcese 344 | zbavvmyy 345 | mwvkrnjg 346 | gtkyelff 347 | bffyzhnt 348 | vlffqryw 349 | ofncqcqw 350 | cnzzrjjj 351 | txpzvykz 352 | ukkgeavq 353 | wdnieioq 354 | avosnedk 355 | ipaavrqp 356 | eeuurfat 357 | sfhhwqzw 358 | vjzopzad 359 | kdbjonqz 360 | uaksjfuc 361 | lumpaomf 362 | ysebmwel 363 | dobryhxj 364 | oaymjqwh 365 | qjfflojj 366 | zqmfgwre 367 | uimjngfs 368 | ihwelccg 369 | yetrodjy 370 | aifvwtws 371 | xiyruzqr 372 | anuvhykm 373 | lelbjsno 374 | csjwqotd 375 | pptsysey 376 | joptcdmq 377 | tghbxpmq 378 | jduwbxiy 379 | obcdlahg 380 | dxwrzytc 381 | axfrxlgz 382 | gepnmvel 383 | ztmcynch 384 | otnicgga 385 | bdzobaoe 386 | vkljxwnm 387 | qvhmitgh 388 | yflyxbjn 389 | qshihqki 390 | debaxqpw 391 | fhfcjogj 392 | huwpnaxx 393 | jpwnrjbc 394 | waylsrcm 395 | aurdpcqc 396 | yanpouht 397 | ybwbpcak 398 | uzvvspnj 399 | tftluckv 400 | uwmditoa 401 | wsndxybi 402 | dotcxasi 403 | lxgmptwn 404 | bpdmcbgt 405 | dpjqvvck 406 | jmgwudli 407 | rimvxcoa 408 | vdlacqbl 409 | qtzwuqny 410 | olzuzuuq 411 | grlyyegi 412 | mhgtadti 413 | yrfdffzj 414 | wbxadryy 415 | bhaniozq 416 | jdishqcx 417 | kmiatkjj 418 | asmxdrmv 419 | riqdknna 420 | fsuetmeg 421 | iikajhgb 422 | ioswsaws 423 | yygpvtfb 424 | egjoltik 425 | bypcbzpk 426 | zaumpggx 427 | sdizezlv 428 | xoyallwy 429 | gicvajdl 430 | qzowhuxa 431 | iyftbzns 432 | srzjxhve 433 | xwasqzay 434 | qznuxpqj 435 | mlnjztxf 436 | rxkcymao 437 | huvxpllx 438 | fmnrqasq 439 | mwwigmka 440 | yovjkmou 441 | kvdrltte 442 | nymvepew 443 | vnrjykzc 444 | unoegpvv 445 | trrejbob 446 | zwsdnqnb 447 | ljsztmgl 448 | tiznomfv 449 | zxtxholt 450 | csufzpiw 451 | jgbjpucz 452 | mpakkeil 453 | ixmbvvbi 454 | ejkhcxjj 455 | zaokljpl 456 | oeocaxdv 457 | ytlpsbcx 458 | hpfserxf 459 | nzregysc 460 | etevckof 461 | bcqkqdvb 462 | xzdhhick 463 | gystpgoo 464 | ciiyzxxr 465 | kwstdxnn 466 | ztregxhx 467 | qhvkjoqe 468 | ugirgwax 469 | nhukpdut 470 | yfiibmmd 471 | cwkayjcp 472 | ebmlabrp 473 | kvjhyrag 474 | wbphpfkc 475 | ucqvhibs 476 | dwuavsyy 477 | jwrdsobl 478 | hytijctt 479 | plcumjhv 480 | hwexsihm 481 | ppmfzgqt 482 | moumyuiw 483 | zvgbsabj 484 | yraygmws 485 | vopzuhor 486 | hafhljwp 487 | gmqpchdg 488 | yyahpihs 489 | xvqakyyp 490 | deamarun 491 | yunihcvw 492 | gcdjqqmu 493 | kctibuxy 494 | gcvlcfhc 495 | ydwoxfvg 496 | epszfvuh 497 | xjjvwpbz 498 | gzpdnthj 499 | mnkrjgwz 500 | ldfwvvfq 501 | tydqesvl 502 | envwzaqv 503 | xvwyzkpe 504 | rmpgcjeo 505 | pkupgxup 506 | ekqizsjl 507 | agvenhgu 508 | vscaqtri 509 | rwfjrjpg 510 | imthkcta 511 | sjpmwqmg 512 | fptfgekn 513 | ohbwdbjm 514 | ccfrphaj 515 | gyeaqkog 516 | onybscve 517 | qztmoant 518 | abjnbrpd 519 | zompdzuf 520 | bamomvbw 521 | kzmmgexu 522 | wzoxohtn 523 | wvgmvwdt 524 | nlgkxmbu 525 | vyoddxyf 526 | phmrizhk 527 | zhksysjf 528 | atcfvzlx 529 | iyabqkly 530 | rnwidjpm 531 | cgwddumw 532 | fcoylnzw 533 | lsxosfra 534 | vbcdgfiw 535 | aenlmdgh 536 | fvtmormn 537 | rllxkznc 538 | asocydmo 539 | zcltimlr 540 | hrqmccpt 541 | dfmlsvtz 542 | ntuhkbws 543 | oziqleds 544 | wkzbguis 545 | coapfihl 546 | irzpsuql 547 | uxaowrls 548 | tdbefhcf 549 | wsyusuph 550 | lpbdrmyn 551 | slrzkkms 552 | wqvzwiyq 553 | vinahrsd 554 | thsnmqjr 555 | kwrzmakz 556 | ifhclifl 557 | wkqahikb 558 | rwnchlkr 559 | rkhpdbbk 560 | vqnzigbf 561 | olzziafs 562 | qcylpbtk 563 | fzhtmgji 564 | qvnyctmb 565 | ouolgwup 566 | xkbrykjx 567 | apbamszk 568 | mlrlmpoh 569 | kdneakuk 570 | rrhhrtfk 571 | cbgzlbgz 572 | mfxencal 573 | bkctqwpe 574 | rjdxhqof 575 | ogcbntmp 576 | bbftqdfk 577 | kikdidvm 578 | mnjgwven 579 | yurxwsge 580 | qlrdtzad 581 | jalffvnu 582 | tayfycwr 583 | jhivnvaw 584 | yuvffepz 585 | mwhczdkv 586 | xltzklis 587 | iellkyqk 588 | krpktxhh 589 | rkawdywu 590 | pqqitomj 591 | nrhhtvtv 592 | gwerzhwc 593 | qlsgifir 594 | ssvyspem 595 | udnnmvxk 596 | albkdbsh 597 | obxcrucu 598 | dnyytrcx -------------------------------------------------------------------------------- /resources/day8: -------------------------------------------------------------------------------- 1 | rect 1x1 2 | rotate row y=0 by 10 3 | rect 1x1 4 | rotate row y=0 by 10 5 | rect 1x1 6 | rotate row y=0 by 5 7 | rect 1x1 8 | rotate row y=0 by 3 9 | rect 2x1 10 | rotate row y=0 by 4 11 | rect 1x1 12 | rotate row y=0 by 3 13 | rect 1x1 14 | rotate row y=0 by 2 15 | rect 1x1 16 | rotate row y=0 by 3 17 | rect 2x1 18 | rotate row y=0 by 2 19 | rect 1x1 20 | rotate row y=0 by 3 21 | rect 2x1 22 | rotate row y=0 by 5 23 | rotate column x=0 by 1 24 | rect 4x1 25 | rotate row y=1 by 12 26 | rotate row y=0 by 10 27 | rotate column x=0 by 1 28 | rect 9x1 29 | rotate column x=7 by 1 30 | rotate row y=1 by 3 31 | rotate row y=0 by 2 32 | rect 1x2 33 | rotate row y=1 by 3 34 | rotate row y=0 by 1 35 | rect 1x3 36 | rotate column x=35 by 1 37 | rotate column x=5 by 2 38 | rotate row y=2 by 5 39 | rotate row y=1 by 5 40 | rotate row y=0 by 2 41 | rect 1x3 42 | rotate row y=2 by 8 43 | rotate row y=1 by 10 44 | rotate row y=0 by 5 45 | rotate column x=5 by 1 46 | rotate column x=0 by 1 47 | rect 6x1 48 | rotate row y=2 by 7 49 | rotate row y=0 by 5 50 | rotate column x=0 by 1 51 | rect 4x1 52 | rotate column x=40 by 2 53 | rotate row y=2 by 10 54 | rotate row y=0 by 12 55 | rotate column x=5 by 1 56 | rotate column x=0 by 1 57 | rect 9x1 58 | rotate column x=43 by 1 59 | rotate column x=40 by 2 60 | rotate column x=38 by 1 61 | rotate column x=15 by 1 62 | rotate row y=3 by 35 63 | rotate row y=2 by 35 64 | rotate row y=1 by 32 65 | rotate row y=0 by 40 66 | rotate column x=32 by 1 67 | rotate column x=29 by 1 68 | rotate column x=27 by 1 69 | rotate column x=25 by 1 70 | rotate column x=23 by 2 71 | rotate column x=22 by 1 72 | rotate column x=21 by 3 73 | rotate column x=20 by 1 74 | rotate column x=18 by 3 75 | rotate column x=17 by 1 76 | rotate column x=15 by 1 77 | rotate column x=14 by 1 78 | rotate column x=12 by 1 79 | rotate column x=11 by 3 80 | rotate column x=10 by 1 81 | rotate column x=9 by 1 82 | rotate column x=8 by 2 83 | rotate column x=7 by 1 84 | rotate column x=4 by 1 85 | rotate column x=3 by 1 86 | rotate column x=2 by 1 87 | rotate column x=0 by 1 88 | rect 34x1 89 | rotate column x=44 by 1 90 | rotate column x=24 by 1 91 | rotate column x=19 by 1 92 | rotate row y=1 by 8 93 | rotate row y=0 by 10 94 | rotate column x=8 by 1 95 | rotate column x=7 by 1 96 | rotate column x=6 by 1 97 | rotate column x=5 by 2 98 | rotate column x=3 by 1 99 | rotate column x=2 by 1 100 | rotate column x=1 by 1 101 | rotate column x=0 by 1 102 | rect 9x1 103 | rotate row y=0 by 40 104 | rotate column x=43 by 1 105 | rotate row y=4 by 10 106 | rotate row y=3 by 10 107 | rotate row y=2 by 5 108 | rotate row y=1 by 10 109 | rotate row y=0 by 15 110 | rotate column x=7 by 2 111 | rotate column x=6 by 3 112 | rotate column x=5 by 2 113 | rotate column x=3 by 2 114 | rotate column x=2 by 4 115 | rotate column x=0 by 2 116 | rect 9x2 117 | rotate row y=3 by 47 118 | rotate row y=0 by 10 119 | rotate column x=42 by 3 120 | rotate column x=39 by 4 121 | rotate column x=34 by 3 122 | rotate column x=32 by 3 123 | rotate column x=29 by 3 124 | rotate column x=22 by 3 125 | rotate column x=19 by 3 126 | rotate column x=14 by 4 127 | rotate column x=4 by 3 128 | rotate row y=4 by 3 129 | rotate row y=3 by 8 130 | rotate row y=1 by 5 131 | rotate column x=2 by 3 132 | rotate column x=1 by 3 133 | rotate column x=0 by 2 134 | rect 3x2 135 | rotate row y=4 by 8 136 | rotate column x=45 by 1 137 | rotate column x=40 by 5 138 | rotate column x=26 by 3 139 | rotate column x=25 by 5 140 | rotate column x=15 by 5 141 | rotate column x=10 by 5 142 | rotate column x=7 by 5 143 | rotate row y=5 by 35 144 | rotate row y=4 by 42 145 | rotate row y=2 by 5 146 | rotate row y=1 by 20 147 | rotate row y=0 by 45 148 | rotate column x=48 by 5 149 | rotate column x=47 by 5 150 | rotate column x=46 by 5 151 | rotate column x=43 by 5 152 | rotate column x=41 by 5 153 | rotate column x=38 by 5 154 | rotate column x=37 by 5 155 | rotate column x=36 by 5 156 | rotate column x=33 by 1 157 | rotate column x=32 by 5 158 | rotate column x=31 by 5 159 | rotate column x=30 by 1 160 | rotate column x=28 by 5 161 | rotate column x=27 by 5 162 | rotate column x=26 by 5 163 | rotate column x=23 by 1 164 | rotate column x=22 by 5 165 | rotate column x=21 by 5 166 | rotate column x=20 by 1 167 | rotate column x=17 by 5 168 | rotate column x=16 by 5 169 | rotate column x=13 by 1 170 | rotate column x=12 by 3 171 | rotate column x=7 by 5 172 | rotate column x=6 by 5 173 | rotate column x=3 by 1 174 | rotate column x=2 by 3 -------------------------------------------------------------------------------- /resources/day9: -------------------------------------------------------------------------------- 1 | (190x9)(44x13)ZAVXETEBULPKEEYPUUMBWUPDHPXFDPIEWHXPNVMSKMMN(55x14)(6x12)VZQPAA(18x4)ITWIARZWEBBNFBLOGV(13x7)QYTKGAIZHUZAX(4x10)ITDZ(61x3)(1x7)Y(6x2)ZPMQZV(8x15)OIHTQPNI(23x12)CAXCRVLMLAKHPBUUODXQQNT(3x9)WJP(5x12)PJAMH(43x13)(30x13)RWAWRZCDEMSPYFDZVVUKZUWSEVFJWH(1x9)N(17x13)(11x4)YHEKAEQQQFW(3x13)SQF(195x4)(56x5)(4x8)PBWL(6x8)HWRMIA(2x5)QQ(8x9)JOISJLQL(10x3)JBKQBBPQGK(125x11)(24x13)ELKCLOFLJRFIJCIIRMCOZEPC(7x6)LWRTOXG(14x3)WPNDOOJCSZHKJA(23x10)VUBKGHFYHCEKZMNKIDYWIDY(25x15)FOFQQVCWHFRSRVRSYMYRCZRIF(141x14)(45x2)(12x1)UWTFPNJDKWSG(10x11)DHIUEFRJAQ(4x10)WSOX(53x15)(15x3)UHDWGLSDIHUYSMD(6x10)GALIPI(13x13)UBIUGFWYWMHCR(24x1)(18x3)SAGTVYELUTWSXQVWNI(10x7)GENZOXBYOG(4x2)RMGS(4177x12)(1752x3)(1513x4)(297x4)(10x5)(4x15)PBBT(160x14)(11x6)JCKLDJGYMGO(60x1)(5x4)SOMMG(5x1)MJENB(3x11)IIR(24x12)FQAMKJSXTZCAVAEDEQFQMWIR(70x12)(25x2)FWNHIGOHOUYCQSCUKSSCZXRJI(2x11)XF(17x3)VGTLRDJNDBERXWRAY(3x8)AJT(94x8)(68x10)(21x14)DUGIEEMZURLSHXEPSDMDH(5x11)LISKT(13x14)UMVAIVVRDTOSG(4x9)PGOV(13x4)(8x9)KWQGNJIV(8x2)RLEKKJWG(383x11)(75x1)(21x3)SBABSNIPBMLCXQECMVDGB(42x2)(11x2)ESWFOYEVFIJ(2x7)EL(5x13)OCVGF(1x14)J(189x1)(25x2)(8x13)SUFVDTKX(6x1)EOKRWU(28x4)(6x3)SRAGHT(1x15)H(5x8)VNPVG(24x6)(6x4)LOUBGC(8x9)EFISAKFG(9x13)XXKXSZNFD(73x1)(16x12)HOCOHBXNQRXTLLTJ(13x2)LGGHDLJZCIJOG(24x11)PHJDXXBUJTPSKMLGCALDLLGU(2x15)YU(91x11)(3x4)LMM(16x8)DYOHACMPKIHRDUVJ(44x9)(3x2)MDC(5x10)FNPGJ(11x1)OHPDVNRKRSI(2x10)YS(5x13)RURCD(134x15)(121x7)(7x13)XTFRZSM(70x9)(8x15)SNLOWPVP(12x9)MYKDYCTXIAZA(13x9)XMZEHDZTPTAES(13x9)TQLYGXTECVDBG(5x10)EXPSZ(15x7)GVFTLYYYBLGGUJO(1x7)N(14x15)WNZDWNHWJQOQNH(648x6)(83x14)(55x11)(2x13)RP(9x10)MJPOSAGCX(26x7)NXVQZQAQDWHABJFPRVMGSBACWU(14x15)ECVUEOUGLOEJUY(232x13)(30x6)(2x11)NZ(1x13)S(2x8)AR(3x9)DDI(45x3)(4x10)FFJD(7x7)ZRGGRXE(6x10)WJKSTC(5x13)NEQXI(85x9)(4x9)JCLI(14x4)HCVHVWLAFIUSIZ(4x1)BISN(26x2)HRPEKOHFGEJLJDGIWVLQOWJJKU(9x14)YXKJROSLO(17x12)(11x8)HFLFUQNVNMK(23x11)(1x1)N(10x13)TMNKWOOVPB(192x11)(26x1)(4x10)TCAP(3x5)LHN(2x15)DK(36x8)(13x13)UIDKJYPXBFPFO(10x8)BGWMNGEBRF(18x7)SIXYKHPJJONMMHQCRB(5x15)JGIRA(77x3)(5x4)MHAXO(3x8)WSI(15x14)AVHDFYABFZSAOJP(30x15)XNZULOJGEPQDRSHDYHHTBLEMRMPYSB(111x9)(75x13)(10x4)EBCINBYRMS(10x6)XNEZNHZJCE(7x13)HQOEZCA(14x4)OAIKFNURYAWDQK(5x5)VCRLS(22x14)ZROMOTQACGRYTSVCXIEEBP(16x13)(10x5)RKGNREWXGD(200x10)(77x1)(70x15)(25x5)(11x5)OEDHHSUIKNC(3x5)XKD(15x6)EIDHHIZMJRRAGSP(12x9)QNZKKKFEGAMM(110x1)(103x1)(74x12)(32x9)XABWGIVXFJVAMTILWOQXFNMJZSMAVHFY(30x8)TPBSRMCDOQNNAVZQPPZADGDWQAYWCV(16x2)WSDGMBKDJSOACIFW(2x9)XS(2401x11)(808x3)(1x5)F(99x6)(11x15)(5x12)BNHZF(75x9)(68x14)(12x13)UBFYCZHLDIRJ(2x2)EM(18x13)KNOLWZIARZVDYPKPPL(1x11)D(4x10)QFDT(136x10)(47x3)(28x12)(2x10)SO(8x8)TUBVOBJB(1x12)V(7x4)(1x12)R(2x3)TW(47x15)(40x10)(9x3)IPNMPMMCD(1x1)O(3x6)BKR(6x15)DOOFGK(5x15)KNCGF(6x3)(1x3)E(148x4)(9x13)(3x12)UZC(4x12)VKWP(38x8)(12x9)(7x8)IKLDJWW(1x8)I(9x5)FIBXVUYFN(72x13)(32x11)(19x7)SLSTSSNZPVSNIBPYQRS(2x8)UA(6x11)KXTTMX(4x10)MJMA(5x15)EKHFC(391x7)(3x1)DMD(64x4)(50x4)(8x9)IRDFCBWT(8x13)TKRVFJUL(5x4)DRSZI(8x5)YFTAAAZW(3x3)SYD(165x15)(72x7)(13x8)YXWPIFDIWTEBO(14x5)URQPORMHJUTGAY(3x9)HJB(18x14)VMTFPEBGKWWRLBODQH(81x4)(36x1)VPRXKSMKMDBXIPXGJMAGSEHEQLWAWRQWRIQT(7x13)RCFJLYM(13x7)FLKGGTMPZLEMG(2x3)JU(133x9)(15x1)YQJSGFRQQOLXAPM(15x2)NZUELUVNJDEECSB(56x9)(18x8)NMABOFTJAYZTEMSNTB(2x3)CO(6x1)ARWFWX(9x7)AWQFAIJNL(23x1)(1x7)U(11x2)HETPXKPHZAF(462x1)(171x9)(135x10)(74x14)(16x14)XNDDMDFQCZDHJZZZ(7x11)QBQIIIW(10x5)QNBFCGEEGG(16x3)QNDBYXJONNPSPHUE(25x8)(1x3)T(13x9)OJKYMWIWLTOKH(17x4)(11x3)FHYJYDFLLIP(22x1)(4x1)CLZN(7x10)RJFTIIO(2x12)MC(233x3)(3x7)AIT(40x5)(10x9)(5x1)LLWPV(17x11)WJGWFPRRSEIQAJYMM(36x2)(21x9)(15x2)OCWZSWWKTBYNHHS(3x14)KPF(105x3)(6x11)UCHAIT(25x8)(18x15)PAEPDOQFZFCOWXNKPM(43x1)(11x12)JFQAUNYHERQ(9x11)DRQITRCYP(5x3)WTJHQ(8x8)OHJBAFIB(19x2)DAFUAZEEDQNGIZRECDJ(1x1)P(24x8)MZPCRRIKUHWFOHDVOMNLOBMO(217x9)(209x10)(25x14)ZTSIKFJVMLJUQETBKJPPRTQTS(6x2)VAFWIN(89x5)(6x5)(1x7)X(71x14)(2x5)OS(16x1)VIBKGDVQXIBHAKNI(3x5)ZGR(19x14)MLKEFZKKQSYHAELTBGB(2x10)CD(65x4)(58x12)(3x1)ZIU(3x12)SZC(10x2)OQPHJZCGVW(9x2)BDWHFXWZX(6x2)PTHTDS(885x10)(613x1)(38x15)(11x10)DUOYNEGCCAP(14x6)(2x11)ZT(1x5)R(232x7)(25x2)(18x14)QVUIOCQAEZLOTZVXIX(77x7)(22x15)HVHLSATCKEFKLWYRPJXKSI(3x2)PNW(33x12)UTZCGONSVMLAPWTAZILLBRNDOABBZBLRQ(11x6)VCKFJVKSNFC(3x5)COU(86x11)(8x12)YLWMFUKC(16x12)HKQZWQXAQEZELTKJ(6x4)DKEVJB(16x14)WKKMITBLHTJDDIBV(9x11)XPSECVOAO(165x4)(62x1)(11x3)LBEETPNBLEO(5x14)RYYQP(5x5)UHLVY(18x2)OONYEICVPEDLQHIUSJ(36x4)(30x4)KQGSBKSAIDHYDRXEBMNLIHLYXVPEZH(8x13)SYVNWDUT(34x12)XLWWYVKPHEMTJBEQYGKHOQDSHVAGNVMFJK(139x13)(27x7)(1x5)C(4x15)JBBW(5x13)AJJKR(56x11)(18x7)MIPUIIWUHSWCQMEGYN(6x1)MEHVUR(14x11)LOIATKARYOHUJU(37x6)UVKYKHPRZUJFSTUUKFTQIIKKNZOLCQLLBJXVV(5x7)NTEYE(258x7)(33x2)(4x12)EAPG(5x6)SFYVB(8x8)BPGFSFVY(57x7)(1x9)S(44x11)(2x1)RO(1x11)S(24x1)GDRUIEUMOHITSMXDIDGJARJQ(15x6)(9x13)VJZKHBRCR(127x10)(23x12)(1x9)V(3x4)HEI(4x9)OFWY(10x2)BBSZRMWOHR(7x15)(1x15)M(31x5)CKEZCRPSEGEZDYRPWQUKNPMCBTNSPAI(25x5)(1x9)J(12x15)BSSMRDPRNPDY(3785x8)(8x3)GHOEWPFD(1806x14)(124x10)(105x8)(10x9)CDDMAEIXOO(37x3)(10x4)(5x5)VPMMI(3x5)GBP(7x14)VJHBABZ(18x14)XNTKDFTRBCZEACZALZ(14x12)TYBGBOIYRCVRZU(7x2)IORHKKB(590x10)(54x8)(17x6)UTOVYCYKDKKEIUCAI(25x9)(19x6)HIWIXDNGZZJGIACNPPQ(523x7)(41x4)(1x1)I(7x4)(2x6)GU(17x1)DZVZPWJUHXFIHHPFP(196x13)(5x7)OSDSW(15x3)SRTTJWWSYUJGBFF(27x2)(4x13)MSYH(4x1)SXNR(3x2)DPR(70x2)(16x13)QCNXMJXCKTMHZPBM(2x10)FO(25x6)AEVXNJGKTBCPMCUASWXOWHAQS(3x8)GOG(50x2)(14x9)AAGJSTOOBANCTR(14x5)MDCWUWOSELBMGX(4x10)YYLT(10x15)SQZZGFJLDT(133x13)(57x11)(7x11)DDNXMAC(2x12)DV(5x11)UBANO(19x6)NLORMPBFFBOYBQIBZWV(6x8)ASEPWF(21x12)(14x12)FHGWBAXHALMVQI(17x7)(10x13)CCDGPEISBV(2x2)OX(107x3)(7x1)QNMWYFE(18x3)LMFXMYUQKABGXVOUVV(7x9)(2x1)BF(37x15)(12x8)KTBAPXKZLKWT(1x9)W(8x1)GSDNJDSU(9x15)KYVQMDMQW(593x4)(255x7)(146x11)(40x9)(33x12)YLECKKJDQVAMUFFXPWGHUSOECCHZXBLWM(93x10)(3x10)BXC(1x9)U(2x10)BF(18x10)SGORQZUALUTFAVYLPW(39x9)WQGBTEVNTRHTIWQAWVJKIXJVCVMKRGQMPPMIFSF(94x13)(88x1)(5x11)EEUOH(31x13)FSLFXZCUXOXHREPXRPFAWSEABNPADCE(5x7)KEMTG(4x13)GDAZ(13x1)JCRZXVSFBDJZK(4x12)SITF(269x14)(24x3)(7x13)YXQHGKY(5x14)ROOVW(205x14)(10x12)ZZBVWTQWEV(56x11)(1x6)R(10x6)NFOTUTICTJ(8x12)JZWVIHBE(13x13)UBIZNBBEZOIID(28x2)(14x14)HLADLLCONGEPXC(2x2)NH(9x14)(3x15)YCB(69x11)(14x13)QXFXOJBHONIVVJ(5x15)YJMER(6x12)ITSZWH(18x12)IGLEYGQAABOWKMXFGE(20x3)(14x5)(9x7)MSOAXHAID(38x3)IZFZRYYEJVCORBDLTYOHLZHKVDKQVADYQISGTW(469x1)(18x3)TWUUVIXHGSCVVDOFDJ(437x12)(86x8)(40x6)(19x9)OSYGQMGNNLPBKXEPHQG(1x12)M(3x2)PQT(17x15)TQQBGULRUKIXBPYZW(10x7)(5x9)TZMKP(75x3)(68x14)(13x7)QTDRLDGGUIORW(9x10)JTAZPINDH(17x12)KEVECGSLNRMIRBAZO(5x5)DVTUL(199x6)(60x4)(13x11)NWEDTFZTDQWFY(3x3)JBP(4x4)PYBQ(16x11)XZRNQJPUOMZZMYYR(77x2)(2x15)ZK(1x11)V(3x5)BRV(30x13)NLHYJDBXRMCZOQRFXABZUZILEHZMZX(11x9)QONGFLBHCQU(26x3)(5x4)WWVVY(2x15)ZH(3x7)MDR(6x3)PCMRSD(2x1)AA(2x14)PG(44x3)(6x1)CVWMIH(7x13)HSQHXKD(13x14)(7x11)WGEPOEK(1507x5)(39x1)OMGCAFYYXDFVRVNEYPBATJCKBHTRSMGIWTDNIFP(21x9)BDIJRNXYMIRXXILMGIFQK(404x11)(23x15)(9x3)MWBTTYJCT(4x4)UEQO(15x10)GUYNAWLCLNHJPXD(5x5)CECRY(334x14)(67x10)(60x14)(4x13)ZBQU(3x7)SJI(3x14)GKR(2x2)YJ(20x5)DJQTDUIFRGDDOOAMZSFM(99x13)(47x10)(14x2)THIPTHUFVLLGXK(11x15)SQGQIYAKKOC(4x4)TNIC(38x10)(6x6)KCQRSL(3x8)JZT(1x11)B(7x1)XFDBCCU(147x3)(8x13)SWNXWSCS(18x5)VDRJWFBVUTWDFZDCLM(62x3)(19x13)NFZAMEONWPPNGFFODDP(14x13)XTOZXOYZJQBPQC(9x12)AOSMZPGZV(8x13)UZOKBJJQ(21x9)(3x11)PFH(7x4)JDSYTAF(1014x11)(386x14)(119x5)(31x6)ORPIVAGZSMEQRAAOQRSMOAFFWVVFBDT(53x1)(5x8)PRHTO(7x15)HXUNQUA(15x5)AJAJOJCLVYZBICO(4x4)DHZH(3x15)BWJ(9x6)TCXBOMXXL(190x13)(54x15)(3x7)OKI(8x11)TPHKZGWA(6x15)RMAXEB(2x11)QZ(7x7)BXCDHWF(14x11)KYUHEMBXSEADVP(49x4)NLMONTYNOIDPEALJJBKPLWHCKBVVBHHUZNGUSULFWUAEBQQCQ(47x8)(2x11)WJ(8x11)ZYDVAWLX(1x6)W(6x5)CJIWBA(2x15)LS(12x7)PEYJTBKWCUPT(38x2)(31x14)(2x2)CL(17x12)ABAKPQWMMGJTORRBB(4x12)GHGK(496x13)(231x7)(60x2)(11x10)PHJQCJOXFHA(6x7)BKEVJY(25x5)MIZCFGZJRGZDMKHUEGZMACELH(27x12)(3x9)SMI(12x15)CCJWNFNOUQGC(101x8)(27x15)PPDYHKWCWZYEEJJPUFXRRYIASUT(17x10)GGFQFHRYKJMXKBBAR(8x3)FTPTBVXE(23x10)CLAVUXEHWTEYZQNRYOGIQME(16x15)(10x8)LAZDAYDVLM(193x3)(9x15)OHPJACNZL(40x14)(1x9)O(17x7)UOFNZKLKAAMBPOHNS(6x6)SZIJWV(54x5)(2x7)FV(7x9)GEWYULA(1x13)U(22x2)ZVSVOAJXMDEMUPOQLTINZF(24x15)TWQIDBTWEPQBMHYKPLYZSVZI(33x15)(20x1)LZUNQTUVMDOOXEDUZFAR(1x13)K(52x3)(46x9)(7x8)WQWZCBB(27x14)HAZIUDWNIFUKQCAWYFJIGEWSLJO(85x12)(55x7)(48x14)(3x4)TBU(22x6)YFSPWGIYYVLXKMNBKZRFMH(7x1)LGZSHDG(2x10)HY(10x2)SLXHMEWSGF(9x8)(4x2)RWUE(434x11)(426x14)(52x8)(21x14)BCBITAXHZMXHHYRZDNOJA(18x1)FKEHYEEXRRMXDUPPLZ(361x9)(127x14)(29x4)(1x11)G(3x5)TXQ(9x2)KKWGNXDII(11x11)RVLXVHDTCUP(68x9)(11x8)YQKPSJFRDFP(16x10)UUEHIVBUTUFRUVDE(2x14)RX(14x8)GVHHPSBTEJUNKN(219x7)(105x11)(21x10)EFKAZUOPPUTTNFYUNJSZO(71x8)HDPQUFFZUXYPEKOWXNNZVQJFIZEYEODJSNYUOAZOIRQETXCRZBGJWWMMPPIIHJEGFYREGNR(38x11)NKGEVBBLDDLGOYUHLBWXSEAQHFNGABJENZQMVU(3x14)TTC(34x1)(6x10)NXQLWI(15x10)EQVLORVBUBZDUMB(7x8)(2x7)VA(5917x1)(2328x4)(814x14)(37x14)(1x10)J(24x6)(17x10)TRMNJJCWQUYENUBXU(445x15)(177x1)(37x14)PUCBAZGPSDOVSUSSZSCCWDCWYILTSEMJVIVZX(17x7)IMEOLAHQLTARXBTDR(65x8)(2x5)YN(14x12)QXEQUHYTHIHLPM(5x5)MTCMS(9x6)FGQLYLJNL(8x8)KHHJLUDZ(32x10)FXSLPGRBINYRWGIWKRRYSEWARGDQDPSW(10x10)WLADYFJIUQ(2x4)XX(209x8)(94x11)(36x15)UKGUJGLESXQIOASTZHMRHEWIEMXOYYIJUKAG(6x6)NCIDZV(7x10)JHACUVQ(21x1)KAGYAGPGGDOGOBXMSNJEQ(91x2)(30x15)UUMCWGDYGHNOBMJTPPZVSZEHNKZCAA(27x9)VXBDEFDWMTIRGHCQSYDYWCSBJPY(8x7)GKMVKFZJ(2x15)NS(5x14)BPRCM(15x3)OPXQHISSCCOQIEA(287x9)(280x8)(21x3)PKYXLJXGOKXSXBZTGDEGK(59x1)(12x13)VGTKVMCQIXTS(2x11)BF(1x14)W(18x14)JDKAOKYPNNXQMDKKGX(7x2)IHUZYBL(73x4)(9x5)FOVTPBVAV(13x9)EARZLZXSPEGWQ(3x3)QAR(11x12)TWJVZZSODUV(9x5)CGFVAEEEH(90x15)(11x9)YWKHVDSVGUO(12x10)GENMNJXISQVW(12x10)KBTDARSOPYAQ(14x3)NHGNNHWJAAESBB(9x10)CJIVXCNIZ(17x5)(2x10)VL(4x1)SSQH(430x7)(202x4)(1x10)O(187x11)(4x3)LYVC(94x5)(2x11)YL(37x5)PKLWZVRFRDJNMQUYXZZOGBUCFEGKARHPZRWLH(12x4)GJTFJWUZZGDJ(11x12)PQYMGSOEGFN(1x11)E(13x6)SMCPDDOIVMUJG(43x7)(19x1)ARSZUFFVAWVUVVAJYZG(11x10)DBEQVCPRXFZ(4x13)CILW(19x14)SOMYRGMAZBGXXSSVQQT(188x1)(2x7)OJ(19x1)(4x14)NIUS(4x5)MZXK(149x5)(5x15)XJJFF(9x3)WTNULIFAC(3x4)IEG(6x14)BUUOSC(97x15)(3x7)JDE(21x14)DRSIEZJSCSARMYNLHBXMA(6x6)KLXKVG(23x10)GWFKMOJCXJAZQRPYSIOJJMX(14x8)UVPDUFZQCLWMRY(1041x14)(487x4)(147x5)(18x5)(3x3)IEG(5x3)ORYNF(39x10)(2x9)ST(7x3)CNEFQLW(5x1)DWNFO(4x10)MENC(71x7)(10x4)WPXANNVOAW(9x14)HMVITPUDJ(2x12)ED(19x12)QFRXEDUDYNRCRGIQACU(1x4)G(153x2)(2x6)YX(35x7)(3x14)UFH(6x6)JKPPKO(2x14)NJ(2x7)UD(80x15)(1x12)W(5x13)TLUOY(12x13)OGETDQFVRFHB(30x10)VXWLNWQFZIBHSHJFUVXGMWQKRTPUNW(1x5)B(2x10)XJ(5x2)FLSQR(86x15)(64x9)(12x13)FWBFVBRJLSFO(9x10)ZPRGOCGIY(1x4)B(17x10)GLFZZASOWKMWKPDTX(10x8)CAFLEOCKCZ(54x2)(10x8)GGUJBSQXKH(1x13)K(11x2)XMEFKFUWGKB(9x4)AUZEFUEAN(13x14)VXYFVIJSRAVZZ(223x1)(104x2)(81x14)(29x6)IKMHIQWEIAZRBLNRYIQEOGFYMUCEE(3x12)NEU(20x15)RSUTWKPGWJJVIUDYXASE(5x1)YWRMT(10x3)VQUXAKOZAF(105x4)(2x3)AW(7x13)DJVQXBD(20x13)(9x4)DXROACCWK(1x4)O(26x13)(1x5)H(13x14)SBMKWBSXIQTUZ(19x5)GSHERQSGPSGZSAAODTO(309x10)(15x14)DNIEMCZLWCGEGSR(109x4)(1x14)G(45x5)(7x5)JTGEPNX(7x13)CNJHWWK(13x12)KJWMEKGRJRMQY(44x11)(9x15)OGVNXLNGE(16x11)NHPXBCXLHBHZSAQB(1x4)L(93x4)(7x12)(2x3)OB(7x4)SZLFMBQ(62x2)(2x4)OG(1x14)U(5x4)ZNTON(32x3)OEIHONIOMNLTJSVTNHGCSLRJXXPQURCA(66x1)(54x5)(15x9)LYQASFYTPBJCCTQ(5x13)GXJHJ(9x2)GPSBRVISD(2x14)RH(1x7)K(12x12)(6x13)(1x5)J(864x10)(216x7)(178x10)(1x11)G(154x11)(90x13)(12x12)UFQPSXIWWDUQ(13x6)FYWZJVJNQSKEQ(15x12)GSSWXSFQVZTXGOG(4x15)MOQA(14x3)YHCUXXWSJYCNQI(50x13)(16x7)UPECXWSSIGLSAZOP(2x12)RI(6x15)WWABBQ(3x8)BPI(3x11)NFV(12x9)ZYSZENNMCSPP(6x12)(1x1)P(315x3)(62x11)(55x13)SCWUEOTJUJEMXZCCKXLCTEJVIRXGIUJYKUXGWLAOPECYNRGQPDCOSQV(210x2)(7x15)(2x9)XX(153x6)(47x2)(4x2)UBGL(1x4)L(2x12)DX(6x14)MXHGZC(7x9)LWFVNCK(70x5)(7x5)UFXBNXP(7x5)PKQATYS(11x8)LHGQTJWLAZJ(13x14)OFBRVKMVTVBZZ(4x6)XWEG(9x7)GSTAYQFTU(5x6)TDRMT(5x3)HJYCR(12x5)IWDWYJNQWREP(4x9)YUJV(11x6)KMYUKTMGGXM(7x3)SURQLZX(311x14)(74x3)(8x15)WQZPCBEW(33x12)(27x3)(11x3)YUVMRYKBTVB(5x6)NGWOQ(13x10)(8x5)SBGOAMLC(223x14)(216x8)(132x3)(21x2)PDWWLLVUIJDBVMBAPPJZM(3x13)IYX(8x2)GIANHKIZ(69x11)BAKSUXGMPAGTWYBQTTGVDJUIRLJAFSLFOKSDYHKRDXLZUYFAYSRWLVQQVEZXXWLOVXQUM(1x11)X(6x2)ABRRNH(15x9)GMKKGQJJGUTMWNC(6x15)(1x4)I(27x3)(21x3)OOAVOEXIZFFOLRTUKQNPH(19x3)(13x1)YLFXGZKVYIPCZ(2656x13)(857x8)(30x10)(6x3)VEIEFD(13x7)(8x2)OFNGTNFE(214x14)(5x6)ICUDF(48x12)(31x7)(2x10)TP(7x10)WZVHLAL(5x7)KSICH(5x15)FVQMZ(7x6)AXHHPXQ(130x8)(11x14)PVOXSOISUKL(62x11)(10x14)HGAHGPYOTZ(9x14)XATSJXSGN(3x13)UHW(7x5)BDFILVO(3x15)GMG(37x8)(3x12)AMM(6x6)LOPLLX(10x10)YFQHLBVIMU(228x4)(196x6)(72x8)(2x8)UY(12x5)SBLKPHOBOVFN(11x15)WLTYGTOAQWA(11x15)RMCCQHSJLXA(6x9)YMIKNU(50x5)(3x1)UTD(15x1)ZQIGJQRVLIHWAXA(9x2)DEJZUYIAL(1x10)N(55x13)(2x5)JX(9x11)HIBOQBDTQ(3x15)DZW(18x4)EWTFFMXDRUKNAPRHRA(8x1)YWZNRIBZ(6x14)IYSFIN(355x14)(194x12)(69x8)(3x3)JWI(11x1)MWECPWERVLX(25x15)YETRDSRTQWJVQLUJMBAPEDYJS(7x3)ITRTVHQ(10x10)LCXBZSSHTD(2x15)YF(53x1)(7x5)NOKQXWK(9x14)KZWHIQACE(5x1)YYBBF(10x2)TIVHXKIADG(29x5)(2x11)WH(1x12)O(1x3)J(3x3)DMD(146x1)(103x14)(3x3)ERJ(38x9)GNCTOAYQMPVNQRIVMPVHFSSSGJJSSKSIDALFXX(4x1)NCQT(3x14)LET(26x14)TFTZFNESHNZTQJXXYBMSRWGAGO(28x15)(21x13)GRQXOPFOMEVVQLSLETKMP(868x8)(2x2)LQ(413x10)(16x4)BJDCAOAWPRKTUFRC(31x15)LHSNRKFAVXIRZAKFIYGXZPTCIRUNZHG(193x3)(121x4)(2x6)WL(18x5)MXOBIDOXCQZZZQZXYC(5x10)RNAJG(38x3)QVEWABIGEWSUMFJYHZQLBTEDHDFIYFVMXHCRRE(28x11)VQEPBWKREZPTIZFUUNGEMZMXHFZS(59x9)(4x12)NCCS(19x9)JYSMUMHFWZFPABRIEEA(9x8)UFKXIDPNI(5x6)SGDUG(146x4)(28x5)GQKNGDPHQEJTRWPEVQJYFFIQYYPF(28x4)(15x10)AWEFQWTZFCCLXKE(1x7)M(13x8)QBKRCQRRBJDAE(53x1)WANGCZVVKGDRBZQRAVCUZMMCGNJNSHNFXANYREMTHLBUQGGZHSHHA(17x13)(3x11)BXL(3x8)RNJ(359x12)(17x1)(10x14)VPPYMRFSRU(207x4)(90x2)(21x14)VUDTSKRNATYRMYKGYQYDL(36x9)LDLIDFVHNZNTJTSSEYXDGRVODTLKEEZNOLFF(1x7)X(9x4)MGCIKCCSN(10x6)FPZMNVWKXH(24x13)OUBLSXEEYBRLOLVGZDQWDLRS(58x1)(23x13)WINJZLMDVRARNTFALJISNQK(4x4)QSQK(12x10)UPGRXOKUXTDM(115x9)(2x2)HO(21x1)(8x6)PCXYREJW(3x1)UWY(57x15)(6x4)QYSTVV(12x13)VRHZQVQAUZZX(2x10)DE(3x8)VGE(6x9)NXXMWM(10x15)MIENAJJIIE(43x8)YVIJLFYFOEQGUPNDWTRHDCLNVFGHIAPANTFZAMFGJQC(327x7)(3x11)ALX(311x1)(231x11)(25x11)RGXIXRXCNBRIFYSSQBKJXMASC(47x6)(8x12)OIQIUAOX(4x12)IILJ(17x7)NXBRGOKPSBULLIBXL(70x2)(11x9)GARFKGTCOJL(10x2)DXLRJCFRLN(17x12)FLZSXBDSLPOPDFFEM(7x12)PHEQJMO(5x3)JDOEM(54x4)(2x1)TD(3x4)YSO(2x14)YK(17x3)SSRTVCFNRLIKNOFRP(2x12)HB(24x1)(18x4)AZJCRZPJNIDEXSAGWI(1x15)Y(15x12)SPBYIMRXHEWUTGI(8x1)TGFEVRJD(126x12)(119x4)(6x4)AQOOFZ(101x7)(59x10)(22x12)SJEEKAXVKZYKJCXXAWWNEG(8x12)WGKCHMBP(2x10)KQ(3x6)MYL(2x6)VA(7x9)(1x11)K(2x3)RV(4x2)GIJL(441x15)(408x13)(289x8)(43x2)(6x9)BQAZCP(7x13)IZBNZQI(5x13)ZGMYF(3x4)GMZ(78x1)(15x12)DNXKBBTWSCRPEML(23x10)WAYXCNEKHTIISDIQEWGDCNF(4x10)XQRB(10x3)OISRGHWVVU(65x7)(8x15)KIFIOIVA(10x12)WKMUSFSYTC(1x12)U(8x11)JSNCQHWS(8x4)HYCCNHFC(10x8)(4x13)BQCN(63x2)(3x2)QGR(9x12)TOXGGUVRN(3x7)COD(25x14)CMLKONRWTLWLVWYUUEPWSBTEZ(72x8)(19x12)ARIOAFCAISJRQDMDHOF(24x7)HGLXAYCAYXGUWPYTOXGQZWLY(10x1)(5x6)PRJUZ(8x9)(2x12)BH(9x5)(3x11)MXX(2x1)XJ(19x8)HNLSLARKZVSCFTEXCSI(13x2)JVOICRNXKBEJW(2422x8)(10x15)JYSIQCFZOH(2369x9)(17x3)BWRHXTCEWMIOWCBLZ(1509x13)(570x6)(246x14)(60x11)(1x10)P(3x11)HKJ(8x15)IWETKXOI(5x8)NEADO(14x1)IEAVMTLUXBXBDE(8x15)QBBQUNOR(51x4)(45x4)YCCREIRLYPDFFQVRVJLOXIKRTRMDMBKIRVKHITINOULDG(15x4)WIDWCKTMYZPSREB(80x10)(7x15)ZVNHHAM(3x7)BHZ(25x1)PFVLKTHEUATHNNGXYDZGIJIBK(16x3)LUTCOWZBFVHJTUBK(1x9)K(190x15)(14x4)YXOTSDWQOJIVDW(53x11)(3x13)CSD(5x12)SDBDT(27x7)YDOBGKBLGCECQIVSRGFGIIJBWGA(30x7)(3x2)JDT(16x9)SFFCTBDYOVMUKMPL(51x5)(1x8)E(4x3)BITK(15x7)FLWVPMCSZRMVWYV(9x15)EIJVRIWJA(11x8)CSGGGGATSAO(83x15)(68x11)(14x2)LLJVOPOHENDLAQ(3x7)DVN(2x3)YS(11x3)XSBUFRQPHOY(10x9)WVHAUYCVEB(2x13)OR(6x10)OSFCFB(10x6)OBBFPHGWAQ(30x4)EXARKTZXSTLIHCZZRQACWOPVJKZGSK(394x5)(86x10)(9x10)(4x4)YPKF(16x12)(10x5)AVCMULTYPH(28x5)(8x9)WRCBEQLZ(9x10)FDNRGFFOE(8x14)LANMMNWZ(47x10)(31x10)(1x6)V(2x3)RV(6x9)YUCWZK(1x11)B(4x6)EVKQ(30x6)(17x6)(6x5)QKMAXX(1x1)R(2x8)LC(204x2)(13x13)(7x11)BANBCOT(81x7)(2x10)BK(56x7)WBGFHSLVALLDLXHGVCQOAHKOFKAEVQOKSVRBIGNGGIYDVXVWOQUTUEMM(5x10)XGTUJ(58x13)(5x3)ZQYHT(14x4)ZZGNGNSJKPSGRQ(3x8)AKN(4x6)RXLZ(6x2)WEEFXH(25x11)TJFFJBAAGGOBSAZQMQUICAHYI(236x9)(194x15)(3x14)JVA(35x11)(11x2)GQGINADTCQS(11x12)RTIRLMBRRJH(61x10)(7x13)CBWDCZV(7x10)JVCBFYH(1x12)H(13x3)UGATYZUHDCEYZ(3x12)OVG(7x7)EIACOSC(56x12)(27x10)YNDHNMITCLTBYSXPTQUTOUCQIXT(15x13)MUOBITUAHZJSRFK(27x10)(14x12)LXCRVIHJNXRIBA(1x6)K(244x13)(25x5)(6x11)(1x4)T(7x10)SRNQHTE(86x10)(14x9)VWOSJAUKGACGWY(22x12)IOCFRYWTITQHRWWRGQVYDN(14x4)PFETLTSAJBRKLD(10x10)OJCWMEHWKB(50x13)(44x9)(26x1)JXVEVGQUOGOOUTKSOEJYVUBIQB(6x14)ZLEVWS(57x8)(23x4)LYXFADIWRECSPOFSVZNGBHV(21x13)CKUEOYZWLZRXIMLRNIUXP(820x13)(261x1)(144x11)(1x5)E(64x1)(18x13)FCVQICIADHEWSQXHWE(26x5)XXKJGNVZWFOVTEYUREEFCHICDM(2x5)HK(15x11)(3x10)ORP(1x8)C(39x11)(4x13)SUFP(22x10)KYQUIAWLMRKSIOWRBRDWWZ(27x6)(21x6)(5x14)GPQTG(5x2)OPMFU(1x14)X(63x3)(57x4)(6x1)IQFWVT(23x14)AVBLZTVEXGPWRROBTUNYYNI(10x4)DTKMOIKVHV(297x13)(134x14)(2x11)HZ(46x4)(16x4)VZZRZCXCXQRURHKS(11x11)VUEMWTKDREM(1x9)U(35x3)(6x11)YNEWZL(16x12)QMHAUQCYJZCYLMND(13x1)VREYZNFSUNKMO(8x13)RLWWXNXA(13x13)EGENXEUKVVSUI(31x5)(3x2)PGY(3x15)RWD(8x15)YRNZQEBO(16x6)(10x9)(4x10)VLXQ(70x3)(6x8)TNVWPK(1x2)A(46x12)(7x9)HGHIFJD(3x9)JAK(19x11)CCNIXNDAIXLLURONAJM(4x6)GFMK(231x9)(187x6)(16x12)KLYAJFBPAXQIVSLJ(4x13)KHJZ(61x5)(23x1)WMHPHZFOQDFEBWBLYWHUVYD(17x13)AGOTHNZXFDKTSOWER(3x9)OEK(37x9)(6x2)ZWBDUY(2x3)DK(12x15)JDHDZQWPZOJU(38x1)(4x6)NGKF(1x15)I(16x5)VYLULCVBLWHGFXWU(6x5)DBKVCG(11x11)JZESDFRQABC(3x9)KDK(10x1)(4x13)AABI(7x5)KLEGJFL(10x5)(4x15)ZWUS(8x2)QFDRMQGB(13x6)(8x5)(3x8)CGU(20x3)SRQEHKTTHHVEZBPBXYLJ(3x12)BUI(27x2)(21x8)(7x12)IVFOQOK(3x5)HAG(45x15)PZDPOLVYNVIARZUFYFYFSCRUBGUYFOIPJFWRQBFNPTTTU(26x13)(3x6)AGP(3x11)ROD(3x13)HAW(63x6)(2x10)TO(29x12)VCQIALMPBPWQRPGGDTYLIDVQJBVND(13x9)(8x8)UUNJYCJW -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/core.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.core 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def lines (line-seq (io/reader (io/resource "day4")))) 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day1.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day1 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def data (read-string (str "[" (slurp (io/resource "day1")) "]"))) 6 | 7 | (defn parse-data [d] 8 | (->> d 9 | (map name) 10 | (map (juxt first 11 | #(Integer/parseInt (apply str (rest %))))))) 12 | 13 | (defn positions [d] 14 | (->> (map first d) 15 | (reductions #(({\L dec \R inc} %2) %1) 0) 16 | rest 17 | (map #(mod % 4)) 18 | (map [[0 1] [1 0] [0 -1] [-1 0]]) 19 | (mapcat repeat (map second d)) 20 | (reductions (partial map +) (list 0 0)))) 21 | 22 | (defn point-to-dist [p] 23 | (->> p 24 | (map #(Math/abs %)) 25 | (reduce +))) 26 | 27 | ;; part 1 28 | #_(->> data 29 | parse-data 30 | positions 31 | last 32 | point-to-dist) 33 | ;; => 291 34 | 35 | ;; part 2 36 | #_(->> data 37 | parse-data 38 | positions 39 | (reductions conj (list)) 40 | (filter (fn [[x & xs]] ((set xs) x))) 41 | ffirst 42 | point-to-dist) 43 | ;; => 159 44 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day10.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day10 2 | (:require 3 | [advent-of-clojure-2016.utils :as u] 4 | [clojure.set :refer [difference]] 5 | [clojure.java.io :as io] 6 | [clojure.string :as string])) 7 | 8 | (def data (string/split-lines (string/trim (slurp (io/resource "day10"))))) 9 | 10 | (defn addr-names [l] 11 | (->> (re-seq #"(bot|output)\s(\d+)" l) 12 | (map (comp keyword #(apply str %) rest)))) 13 | 14 | (defn parse-line [l] 15 | (let [addrs (addr-names l)] 16 | (condp = (first l) 17 | \v (vector :to (first addrs) (u/to-int (first (re-seq #"\d+" l)))) 18 | \b (cons :from addrs)))) 19 | 20 | ;; all commands originate at a unique bot 21 | #_(let [froms (map second (filter #(= (first %) :from) input))] 22 | (= (count froms) (count (set froms)))) 23 | 24 | (defn give-to-addr [registers addr v] 25 | (update registers addr (fnil conj #{}) v)) 26 | 27 | (defn move-value [registers from to v] 28 | {:pre [((get registers from) v)]} ;; must have val to give 29 | (-> registers 30 | (update from disj v) 31 | (give-to-addr to v))) 32 | 33 | (defn make-init [commands] 34 | (let [{:keys [from to]} (group-by first commands)] 35 | {:commands from 36 | :registers (reduce #(apply give-to-addr %1 (rest %2)) {} to)})) 37 | 38 | (defn high-low-command [registers [_ from low-to high-to :as com]] 39 | (let [[lv hv] ((juxt first last) (sort (get registers from #{})))] 40 | (assert (and lv hv (not= lv hv))) 41 | (-> registers 42 | (move-value from low-to lv) 43 | (move-value from high-to hv)))) 44 | 45 | (defn active-registers [x] (->> x (filter #(>= (count (val %)) 2)) keys set)) 46 | 47 | (defn transition-state [{:keys [registers commands] :as state}] 48 | (let [active-regs (active-registers registers) 49 | [active-commands rest-commands] (u/pluck #(-> % second active-regs) commands)] 50 | (when-not (empty? active-commands) 51 | (-> state 52 | (update :registers #(reduce high-low-command % active-commands)) 53 | (assoc :commands rest-commands))))) 54 | 55 | ;; part 1 56 | #_(->> (iterate transition-state (make-init (map parse-line data))) 57 | (take-while #(not (nil? %))) 58 | (map :registers) 59 | (keep #(some (fn [[k v]] (when (empty? (difference #{61 17} v)) k)) %)) 60 | first) 61 | ;;=> :bot161 62 | 63 | ;; part 2 64 | #_(->> (iterate transition-state (make-init (map parse-line data))) 65 | (take-while #(not (nil? %))) 66 | last 67 | :registers 68 | (#(select-keys % [:output0 :output1 :output2])) 69 | vals 70 | (map first) 71 | (apply *)) 72 | ;; => 133163 73 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day11.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day11 2 | (:require 3 | [advent-of-clojure-2016.utils :as u] 4 | [clojure.math.combinatorics :as combo] 5 | [medley.core :refer [distinct-by]] 6 | [clojure.string :as string] 7 | [clojure.set :refer [difference union intersection]])) 8 | 9 | #_(remove-ns 'advent-of-clojure-2016.day11) 10 | 11 | (def start-state {:pos 0 12 | :floors {0 #{1 -1} 13 | 1 #{10 100 1000 10000} 14 | 2 #{-10 -100 -1000 -10000} 15 | 3 #{}}}) 16 | 17 | (def valid-floors? 18 | (memoize 19 | (fn [n] 20 | (let [gens (set (keep second n)) 21 | chips (set (keep first (filter #(apply not= %) n)))] 22 | (empty? (intersection gens chips)))))) 23 | 24 | (def finished-score 10000000) 25 | 26 | (defn finished? [n] (= #{[3 3]} (set n))) 27 | 28 | (def score 29 | (memoize 30 | (fn [n] 31 | (if (finished? n) 32 | finished-score 33 | (* 10 (count (filter #(= 3 %) (flatten n)))))))) 34 | 35 | (def safe-elevator? 36 | (memoize 37 | (fn [positions] 38 | (or (= 1 (count positions)) 39 | (every? odd? positions) 40 | (every? even? positions) 41 | (let [chip (some #(when (even? %) %) positions)] 42 | ((set positions) (inc chip))))))) 43 | 44 | (def next-possible-states 45 | (memoize 46 | (fn [[flr pairings]] 47 | (let [flattened (vec (flatten pairings)) 48 | lower-bound (reduce min flattened) 49 | places (u/indexes-by #(= % flr) flattened) 50 | positions' (->> (map list places) 51 | (concat (combo/combinations places 2)) 52 | (filter safe-elevator?)) 53 | moves (for [positions positions' 54 | up-or-down [1 -1] 55 | :let [next-floor (+ flr up-or-down)] 56 | :when (<= lower-bound next-floor 3)] 57 | [next-floor 58 | (->> (reduce #(assoc %1 %2 next-floor) flattened positions) 59 | (partition 2) 60 | (map vec) 61 | sort)])] 62 | (doall 63 | (sequence 64 | (comp 65 | (filter (comp valid-floors? second)) 66 | (distinct-by second) 67 | (map #(vary-meta % assoc :score (score (second %))))) 68 | moves)))))) 69 | 70 | ;; helpers to be able to look at and reason about the optimized state 71 | (defn to-normal* [n] 72 | (reduce (fn [accum [i [c g]]] 73 | (-> accum 74 | (update-in [c] conj (int (- (Math/pow 10 i)))) 75 | (update-in [g] conj (int (Math/pow 10 i))))) 76 | (into (sorted-map) (zipmap (range 4) (repeat #{}))) 77 | (map-indexed vector n))) 78 | 79 | (defn to-normal [[flr pairings]] 80 | {:pos flr 81 | :floors (to-normal* pairings)}) 82 | 83 | (defn canonical [floors] 84 | (let [kys (set (map #(java.lang.Math/abs %) (apply concat (vals floors)))) 85 | init (zipmap kys (repeat [nil nil]))] 86 | (-> (reduce (fn [accum [p items]] 87 | (reduce #(assoc-in %1 [(java.lang.Math/abs %2) 88 | (if (pos? %2) 1 0)] p) accum items)) 89 | init floors) 90 | vals 91 | sort))) 92 | 93 | (defn to-canonical [{:keys [pos floors]}] 94 | [pos (canonical floors)]) 95 | 96 | 97 | (def state-score #(-> % second meta :score)) 98 | 99 | ;; do one level at a time 100 | (defn breadth-first-level [ordered-state-set] 101 | (println "level" (count (ffirst ordered-state-set))) 102 | (println "count" (count ordered-state-set)) 103 | (->> ordered-state-set 104 | (mapcat (fn [[prev-states state]] 105 | (let [last-canonical (second (last prev-states))] 106 | (->> (next-possible-states state) 107 | (filter #(not= last-canonical (second %))) 108 | #_(filter (comp (complement (set prev-states)) second)) 109 | (map #(vector (conj prev-states state) %)))))) 110 | (distinct-by second) 111 | (sort-by state-score >) 112 | (take 500))) 113 | 114 | (defn breadth-first-search [limit start-state] 115 | (->> (iterate breadth-first-level [[[] (to-canonical start-state)]]) 116 | (take-while #(and (not-empty %) 117 | (let [scr (state-score (first %))] 118 | (println "-" scr) 119 | (not= scr finished-score)))) 120 | (take limit) 121 | count)) 122 | 123 | ;; part 1 124 | #_(time (breadth-first-search 40 start-state)) 125 | ;; => 33 126 | 127 | (def start-state2 {:pos 0 128 | :floors {0 #{1 -1 100000 -100000 1000000 -1000000} 129 | 1 #{10 100 1000 10000} 130 | 2 #{-10 -100 -1000 -10000} 131 | 3 #{}}}) 132 | 133 | ;; part 2 134 | #_(time (breadth-first-search 60 start-state2)) 135 | ;; => 57 136 | 137 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day12.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day12 2 | (:require 3 | [advent-of-clojure-2016.utils :as u] 4 | [clojure.java.io :as io] 5 | [clojure.string :as string])) 6 | 7 | #_(remove-ns 'advent-of-clojure-2016.day12) 8 | 9 | (defn parse-instructions [s] 10 | (->> s 11 | (string/split-lines) 12 | (map #(str "[" % "]")) 13 | (map read-string) 14 | vec)) 15 | 16 | (def input (parse-instructions (slurp (io/resource "day12")))) 17 | 18 | (defn reg-or-val [s reg-val] (if (symbol? reg-val) (get s reg-val) reg-val)) 19 | 20 | (defn update-reg [s reg f] 21 | (-> s (update reg f) (update :pos inc))) 22 | 23 | (defmulti trans (fn [_ b] (first b))) 24 | (defmethod trans 'inc [s [_ reg]] (update-reg s reg inc)) 25 | (defmethod trans 'dec [s [_ reg]] (update-reg s reg dec)) 26 | 27 | (defmethod trans 'cpy [s [_ reg-val reg]] 28 | (-> s (assoc reg (reg-or-val s reg-val)) (update :pos inc))) 29 | 30 | (defmethod trans 'jnz [s [_ reg-val steps]] 31 | (update s :pos + 32 | (if-not (zero? (reg-or-val s reg-val)) steps 1))) 33 | 34 | (def start-state '{a 0 b 0 c 0 d 0 :pos 0}) 35 | 36 | (defn run-prog [start-state input] 37 | (let [input (vec input)] 38 | (take-while (comp not nil?) 39 | (iterate (fn [{:keys [pos] :as s}] 40 | (when-let [inst (get input pos nil)] 41 | (trans s inst))) 42 | start-state)))) 43 | 44 | ;; part 1 45 | #_ (time (last (run-prog start-state input))) 46 | ;; => 317993 47 | 48 | ;; part 2 49 | #_ (time (last (run-prog (assoc start-state 'c 1) input))) 50 | ;; => 9227647 51 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day13.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day13 2 | (:require 3 | [clojure.string :as string] 4 | [clojure.set :refer [union]])) 5 | 6 | (def ^:dynamic *input* 1352) 7 | (def ^:dynamic *bound* 41) 8 | (def ^:dynamic *target* [31 39]) 9 | (def ^:dynamic *upper-bound* 100) 10 | 11 | (defn open? [[x y]] 12 | (->> (+ *input* (* x x) (* 3 x) (* 2 x y) y (* y y)) 13 | Integer/toBinaryString 14 | (filter #(= \1 %)) 15 | count 16 | even?)) 17 | 18 | (defn view-structure [sz] 19 | (for [y (range sz)] 20 | (for [x (range sz)] 21 | (cond 22 | (= *target* [x y]) 'O 23 | (open? [x y]) '. 24 | :else '=)))) 25 | 26 | (defn next-steps [path-set coord] 27 | (sequence 28 | (comp 29 | (map (partial mapv + coord)) 30 | (filter #(every? (fn [i] (<= 0 i *bound*)) %)) 31 | (filter (complement path-set)) 32 | (filter open?)) 33 | [[1 0] [-1 0] [0 1] [0 -1]])) 34 | 35 | (defn depth-search [path-set coord] 36 | (cond 37 | (= coord *target*) (count path-set) 38 | (> (count path-set) *upper-bound*) Integer/MAX_VALUE 39 | :else 40 | (if-let [res (->> (next-steps path-set coord) 41 | (map #(depth-search (conj path-set coord) %)) 42 | not-empty)] 43 | (reduce min res) 44 | Integer/MAX_VALUE))) 45 | 46 | #_(view-structure 41) 47 | 48 | ;; sample input 49 | #_(depth-search #{} [1 1]) 50 | ;; => 90 51 | 52 | (defn collect-positions [path-set coord] 53 | (if (>= (count path-set) *upper-bound*) 54 | #{coord} 55 | (->> (next-steps path-set coord) 56 | (map #(collect-positions (conj path-set coord) %)) 57 | (apply union #{coord})))) 58 | 59 | ;; part 2 60 | #_(binding [*upper-bound* 50] 61 | (count (collect-positions #{} [1 1]))) 62 | ;; => 135 63 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day14.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day14 2 | (:require 3 | [advent-of-clojure-2016.utils :refer [apply-times]] 4 | [digest :refer [md5]] 5 | [medley.core :refer [assoc-some]])) 6 | 7 | (def next-hash (comp md5 str)) 8 | 9 | (def stretched-hash (comp (partial apply-times 2016 md5) next-hash)) 10 | 11 | (defn triple-and-fives [h] 12 | (-> {} 13 | (assoc-some :triple (second (re-find #"(.)\1\1" h))) 14 | (assoc-some :fives (not-empty (set (map second (re-seq #"(.)\1\1\1\1" h))))) 15 | not-empty)) 16 | 17 | (defn code-key? [salted-hasher i] 18 | (when-let [{:keys [triple]} (salted-hasher i)] 19 | (->> (range (inc i) (+ 1000 i)) 20 | (keep (comp :fives salted-hasher)) 21 | (some #(contains? % triple))))) 22 | 23 | (defn find-answer [index-has-key?] 24 | (time (->> (filter index-has-key? (range)) 25 | (take 64) 26 | (map #(do (prn %) %)) 27 | last))) 28 | 29 | (defn make-index-pred [salted-hasher] 30 | (partial code-key? (memoize (comp triple-and-fives salted-hasher)))) 31 | 32 | ;; part 1 33 | #_(find-answer (make-index-pred (partial next-hash "ahsbgdzn"))) 34 | ;; => 23890 35 | 36 | ;; part 2 37 | #_(find-answer (make-index-pred (partial stretched-hash "ahsbgdzn"))) 38 | ;; => 22696 39 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day15.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day15) 2 | 3 | (def start-state [[5 17] 4 | [8 19] 5 | [1 7] 6 | [7 13] 7 | [1 5] 8 | [0 3]]) 9 | 10 | (defn disc-at-t [[pos disc-size] t] 11 | [(mod (+ t pos) disc-size) disc-size]) 12 | 13 | (defn state-of-discs-at-t [s t] 14 | (map-indexed (fn [i disc] (disc-at-t disc (+ 1 t i))) s)) 15 | 16 | (def completed #(every? zero? (map first %))) 17 | 18 | (defn times-with-aligned-discs [s start step] 19 | (->> (range start Integer/MAX_VALUE step) 20 | (filter #(completed (state-of-discs-at-t s %))))) 21 | 22 | (defn next-step [{:keys [pos step]} state] 23 | (let [[next-pos after-pos] 24 | (take 2 (times-with-aligned-discs state pos step))] 25 | {:pos next-pos :step (- after-pos next-pos)})) 26 | 27 | (defn find-answer [state] 28 | (reduce next-step {:pos 0 :step 1} (rest (reductions conj [] state)))) 29 | 30 | ;; part 1 31 | #_(find-answer start-state) 32 | ;; => 16824 33 | 34 | #_(find-answer (conj start-state [0 11])) 35 | ;; => 3543984 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day16.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day16) 2 | 3 | (def input "11110010111001001") 4 | 5 | (defn expand [a] 6 | (concat a (cons \0 (map {\1 \0 \0 \1} (reverse a))))) 7 | 8 | (defn expand-until [size initial] 9 | (first (filter #(>= (count %) size) (iterate expand initial)))) 10 | 11 | (defn check-sum* [s] 12 | (map (fn [[a b]] (if (= a b) \1 \0)) (partition 2 s))) 13 | 14 | (defn check-sum [s] 15 | (first (filter (comp odd? count) (iterate check-sum* s)))) 16 | 17 | (defn find-answer [size s] 18 | (->> (expand-until size s) 19 | (take size) 20 | check-sum 21 | (apply str))) 22 | 23 | #_(find-answer 272 input) 24 | ;; => 01110011101111011 25 | 26 | ;; not performant (222 seconds) but 35Megs isn't impossible 27 | ;; structural sharing and seqs perform their magic here 28 | #_ (def res (time (find-answer 35651584 input))) 29 | ;; => 11001111011000111 30 | 31 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day17.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day17 2 | (:require 3 | [digest :refer [md5]])) 4 | 5 | (def input "mmsxrhfx") 6 | 7 | (def dir-map 8 | {[0 -1] \U [0 1] \D [-1 0] \L [1 0] \R }) 9 | 10 | (defn directions [code [path pos]] 11 | (->> (md5 (apply str code path)) 12 | (take 4) 13 | (keep-indexed (fn [i v] (when (#{\b \c \d \e \f} v) i))) 14 | (map [[0 -1] [0 1] [-1 0] [1 0]]) 15 | (map #(vector (conj path (dir-map %)) (map + pos %))) 16 | (filter #(let [[_ [a b]] %] 17 | (and (<= 0 a 3) (<= 0 b 3)))))) 18 | 19 | (def finished? #(= [3 3] (second %))) 20 | 21 | (defn breadth-first-level [input positions] 22 | (->> positions 23 | (filter (comp not finished?)) 24 | (mapcat (partial directions input)) 25 | (sort-by #(if (finished? %) 0 1)))) 26 | 27 | (defn find-answer [s] 28 | (->> (iterate (partial breadth-first-level s) [[[] [0 0]]]) 29 | (take-while not-empty) 30 | (filter (comp finished? first)) 31 | (map #(apply str (ffirst %))))) 32 | 33 | ;; part1 34 | #_(first (find-answer input)) 35 | ;; => RLDUDRDDRR 36 | 37 | ;; part 2 38 | #_(count (last (find-answer input))) 39 | ;; => 590 40 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day18.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day18) 2 | 3 | (def input 4 | (str "...^^^^^..^...^...^^^^^^...^.^^^.^.^.^^.^^^" 5 | ".....^.^^^...^^^^^^.....^.^^...^^^^^...^.^^^.^^......^^^^")) 6 | 7 | (def t? #{"^^." ".^^" "^.." "..^"}) 8 | 9 | (defn next-trap? [x] 10 | (if (t? (apply str x)) \^ \.)) 11 | 12 | (defn next-row [r] 13 | (->> (cons \. (conj r \.)) 14 | (partition 3 1) 15 | (mapv next-trap?))) 16 | 17 | (defn find-answer [rows r] 18 | (->> (iterate next-row (vec r)) 19 | (pmap #(count (filter #{\.} %))) 20 | (take rows) 21 | (reduce +))) 22 | 23 | ;; part 1 24 | #_(find-answer 40 input) 25 | ;; => 1982 26 | 27 | ;; part 2 28 | #_ (time (find-answer 400000 input)) 29 | ;; => 20005203 30 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day19.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day19) 2 | 3 | ;; the idea here is we can represent the data structure as a range 4 | ;; with a beginning and an end and a step 5 | 6 | (defn next-level [{:keys [begin end step] :as st}] 7 | (let [nstep (* 2 step)] 8 | (if (= 1 (mod (- (inc end) begin) nstep)) 9 | (-> st 10 | (assoc :step nstep) 11 | (update-in [:begin] #(+ % nstep))) 12 | (-> st 13 | (assoc :step nstep) 14 | (update-in [:end] #(- % step)))))) 15 | 16 | ;; part 1 17 | #_(first 18 | (filter #(= (:begin %) (:end %)) 19 | (iterate next-level {:begin 1 :end 3004953 :step 1}))) 20 | ;; => 1815603 21 | 22 | ;; For part 2 23 | 24 | ;; this problem can be done in the same manner as above but it's very tricky 25 | ;; The following is a brute force approach with an optimized data structure and algorithm 26 | 27 | ;; this can be considered an alternate approach to part one as well 28 | 29 | ;; A really good challenge is to use the approach above keeping in mind 30 | ;; the fact that the second part just keeps eliminating two neighbors at a time 31 | ;; starting at the opposite index - 1 in a cycle 32 | 33 | (defn opposite-index [cnt i] 34 | (mod (+ i (int (/ cnt 2))) cnt)) 35 | 36 | (defn make-st [s i] 37 | (let [st (into (sorted-set) s) 38 | op-i (opposite-index (count st) i)] 39 | [st (drop op-i st)])) 40 | 41 | (defn handle-empty [[st prog :as x]] 42 | (if (empty? prog) [st (seq st)] x)) 43 | 44 | (defn drop-st* [[st progress :as x]] 45 | [(disj st (first progress)) (drop 1 progress)]) 46 | 47 | (defn keep-1* [[st prog]] [st (drop 1 prog)]) 48 | 49 | (defn skip-completed [f] 50 | (fn [x] (if (= 1 (count (first x))) x (f x)))) 51 | 52 | (def drop-st (skip-completed (comp drop-st* handle-empty))) 53 | 54 | (def keep-1 (comp keep-1* handle-empty)) 55 | 56 | (declare transition) 57 | 58 | (defn transition* [[st progress :as x]] 59 | (if (odd? (count st)) 60 | (transition (keep-1 (drop-st x))) 61 | (keep-1 (drop-st (drop-st x))))) 62 | 63 | (def transition (skip-completed transition*)) 64 | 65 | (defn find-answer2 [s] 66 | (->> (iterate transition (make-st s 0)) 67 | (filter #(= 1 (count (first %)))) 68 | first)) 69 | 70 | #_(time (find-answer2 (range 1 (inc 3004953)))) 71 | ;; => 1410630 72 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day2.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day2 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def lines (line-seq (io/reader (io/resource "day2")))) 6 | 7 | (def dir {\U [0 -1] 8 | \D [0 1] 9 | \R [1 0] 10 | \L [-1 0]}) 11 | 12 | (def pos-number #(+ 5 (* 3 (second %)) (first %))) 13 | 14 | (defn in-bounds? [[x y]] 15 | (and (<= -1 x 1) (<= -1 y 1))) 16 | 17 | (defn code-to-pos [bound-fn start code] 18 | (->> code 19 | (map dir) 20 | (reduce (fn [a v] 21 | (let [cp (map + a v)] 22 | (if (bound-fn cp) cp a))) 23 | start))) 24 | 25 | ;; part 1 26 | #_(->> lines 27 | (reductions (partial code-to-pos in-bounds?) 28 | [0 0]) 29 | rest 30 | (map pos-number)) 31 | ;; => (7 8 2 9 3) 32 | 33 | (defn in-part-2-bounds [[x y]] 34 | (and (<= -2 x 2) 35 | (let [bound (- 2 (Math/abs x))] 36 | (<= (- bound) y bound)))) 37 | 38 | (def keypad-map 39 | (into {} 40 | (map 41 | vector 42 | (->> (for [y (range -2 3) 43 | x (range -2 3)] 44 | [x y]) 45 | (filter in-part-2-bounds)) 46 | (map inc (range))))) 47 | 48 | ;; part 2 49 | #_(->> lines 50 | (reductions (partial code-to-pos in-part-2-bounds) [-2 0]) 51 | rest 52 | (map keypad-map) 53 | (map #(format "%X" %))) 54 | 55 | ; => ("A" "C" "8" "C" "8") 56 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day20.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day20 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def data 7 | (->> (slurp (io/resource "day20")) 8 | string/split-lines 9 | (map #(string/split % #"-")) 10 | (map #(mapv read-string %)) 11 | (mapv #(do (assert (apply < %)) %)) 12 | sort)) 13 | 14 | (defn overlap? [[l h] [l2 h2]] (>= (inc h) l2)) 15 | 16 | (defn merge-em [[l h] [l2 h2]] [(min l l2) (max h h2)]) 17 | 18 | (defn merge-all [ips] 19 | (reduce (fn [[accum & xs :as st] nxt] 20 | (if (overlap? accum nxt) 21 | (cons (merge-em accum nxt) xs) 22 | (cons nxt st))) 23 | [[0 0]] 24 | ips)) 25 | 26 | ;; part 1 27 | #_(-> (merge-all data) last last inc) 28 | ;; => 4793564 29 | 30 | (defn size [[l h]] (inc (- h l))) 31 | 32 | ;; part 2 33 | #_(->> (merge-all data) 34 | (map size) 35 | (reduce +) 36 | (- (size [0 4294967295]))) 37 | ;; => 146 38 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day21.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day21 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def instr-data 7 | (->> (slurp (io/resource "day21")) 8 | (string/split-lines) 9 | (map #(read-string (str "[" % "]"))))) 10 | 11 | ;; operations 12 | (defn swap-letter [s x y] (replace {x y y x} s)) 13 | 14 | (defn swap-position [s x y] (swap-letter s (nth s x) (nth s y))) 15 | 16 | (defn rotate-left [s n] (take (count s) (drop n (cycle s)))) 17 | 18 | (defn rotate-right [s n] (reverse (rotate-left (reverse s) n))) 19 | 20 | (defn move-position [s x y] 21 | (let [l (nth s x) 22 | res (remove #(= l %) s)] 23 | (concat (take y res) (cons l (drop y res))))) 24 | 25 | (defn reverse-positions [s x y] 26 | (let [part-size (inc (- y x))] 27 | (concat (take x s) 28 | (reverse (take part-size (drop x s))) 29 | (drop (+ x part-size) s)))) 30 | 31 | (defn rotate-based [s l] 32 | (let [i (.indexOf s l)] 33 | (rotate-right s (+ (inc i) (if (>= i 4) 1 0))))) 34 | 35 | ;; parse args 36 | (def get-numbers (partial filter integer?)) 37 | 38 | (defn get-letters [instr] 39 | (->> (map str instr) 40 | (filter #(= 1 (count %))) 41 | (map first))) 42 | 43 | ;; interpret 44 | (defn scramble-apply-instr [s instr] 45 | (let [s (vec s)] 46 | (condp = (take 2 instr) 47 | '[swap position] (apply swap-position s (get-numbers instr)) 48 | '[swap letter] (apply swap-letter s (get-letters instr)) 49 | '[move position] (apply move-position s (get-numbers instr)) 50 | '[rotate left] (apply rotate-left s (get-numbers instr)) 51 | '[rotate right] (apply rotate-right s (get-numbers instr)) 52 | '[rotate based] (apply rotate-based s (get-letters instr)) 53 | '[reverse positions] (apply reverse-positions s (get-numbers instr))))) 54 | 55 | (defn scramble [s instrs] 56 | (reduce scramble-apply-instr s instrs)) 57 | 58 | ;; part 1 59 | #_(apply str (scramble "abcdefgh" instr-data)) 60 | ;; => gbhafcde 61 | 62 | ;; not invertable so search 63 | (defn inv-rotate-based [s l] 64 | (->> (map #(rotate-left s %) (range (count s))) 65 | (filter #(= (rotate-based % l) s)) 66 | first)) 67 | 68 | (defn un-scramble-apply-instr [s instr] 69 | (let [s (vec s)] 70 | (condp = (take 2 instr) 71 | '[swap position] (apply swap-position s (reverse (get-numbers instr))) 72 | '[swap letter] (apply swap-letter s (reverse (get-letters instr))) 73 | '[move position] (apply move-position s (reverse (get-numbers instr))) 74 | '[rotate left] (apply rotate-right s (get-numbers instr)) 75 | '[rotate right] (apply rotate-left s (get-numbers instr)) 76 | '[rotate based] (apply inv-rotate-based s (get-letters instr)) 77 | '[reverse positions] (apply reverse-positions s (get-numbers instr))))) 78 | 79 | (defn un-scramble [s instrs] 80 | (reduce un-scramble-apply-instr s (reverse instrs))) 81 | 82 | ;; part 2 83 | #_(apply str (un-scramble "fbgdceah" instr-data)) 84 | ;; => "bcfaegdh" 85 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day22.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day22 2 | (:require 3 | [advent-of-clojure-2016.utils :as u] 4 | [clojure.java.io :as io] 5 | [clojure.string :as string] 6 | [medley.core :refer [distinct-by]])) 7 | 8 | (defn parse-input [s] 9 | (into (sorted-map) 10 | (comp 11 | (drop 2) 12 | (map #(re-seq #"\d+" %)) 13 | (map u/to-ints) 14 | (map #(take 4 %)) 15 | (map #(partition 2 %)) 16 | (map #(mapv vec %))) 17 | (string/split-lines s))) 18 | 19 | (def data (parse-input (slurp (io/resource "day22")))) 20 | 21 | (def available (partial apply -)) 22 | (def size first) 23 | (def used second) 24 | (def empty-node (comp zero? used)) 25 | 26 | (defn viable-pair? [a b] 27 | (and a b 28 | (not (empty-node a)) 29 | (>= (available b) (used a)))) 30 | 31 | ;; part 1 32 | #_(count 33 | (for [[pos1 data1] data 34 | [pos2 data2] data 35 | :when (not= pos1 pos2) 36 | :when (viable-pair? data1 data2)] 37 | [pos1 pos2])) 38 | ;; => 1045 39 | 40 | (defn view-grid [{:keys [data]}] 41 | (apply map vector (partition 30 (map used (vals data))))) 42 | 43 | (defn pp [d] 44 | (binding [clojure.pprint/*print-right-margin* 200] 45 | (clojure.pprint/pprint d))) 46 | 47 | (defn make-initial [data] 48 | {:data data 49 | :g [(->> data keys (map first) (reduce max)) 0] 50 | :last-move [(ffirst (filter (comp empty-node second) data))]}) 51 | 52 | ;; this is subtle: a preference for up and to the left is helpful 53 | ;; as it provides the very last disambiguation between = score moves 54 | (defn connections [a] 55 | (map #(mapv + a %) [[-1 0] [0 -1] [0 1] [1 0]])) 56 | 57 | (defn possible-moves [{:keys [last-move data]}] 58 | (let [to-pos (first last-move) 59 | to-data (get data to-pos)] 60 | (for [from-pos (connections to-pos) 61 | :let [from-data (get data from-pos)] 62 | :when (viable-pair? from-data to-data)] 63 | [from-pos to-pos]))) 64 | 65 | (defn make-move [{:keys [data g] :as st} [from to]] 66 | (let [from-data (get data from)] 67 | (-> st 68 | (update-in [:data to 1] + (used from-data)) 69 | (assoc-in [:data from 1] 0) 70 | (assoc :g (if (= g from) to g) 71 | :last-move [from to])))) 72 | 73 | (defn next-states [{:keys [last-move] :as st}] 74 | (->> (possible-moves st) 75 | (filter #(not= last-move (reverse %))) 76 | (map (partial make-move st)))) 77 | 78 | (defn distance [from to] 79 | (if (and from to) 80 | (apply + (map #(Math/abs %) (map - from to))) 81 | Integer/MAX_VALUE)) 82 | 83 | (defn score [{:keys [g last-move]}] 84 | [(apply + g) 85 | (distance g (first last-move))]) 86 | 87 | (defn next-level [state] 88 | (first (sort-by score (next-states state)))) 89 | 90 | (defn find-answer2 [limit data] 91 | (->> (iterate next-level (make-initial data)) 92 | (take-while #(not= (:g %) [0 0])) 93 | (take limit) 94 | count)) 95 | 96 | #_(time (find-answer2 500 data)) 97 | ;; => 265 98 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day23.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day23 2 | (:require 3 | [advent-of-clojure-2016.utils :as u] 4 | [clojure.java.io :as io] 5 | [clojure.string :as string])) 6 | 7 | (defn parse-instructions [s] 8 | (->> s 9 | (string/split-lines) 10 | (map #(str "[" % "]")) 11 | (map read-string) 12 | vec)) 13 | 14 | (def input (parse-instructions (slurp (io/resource "day23")))) 15 | 16 | (defn reg-or-val [s reg-val] (if (symbol? reg-val) (get s reg-val) reg-val)) 17 | 18 | (defn update-reg [s reg f] 19 | (-> s (update reg f) (update :pos inc))) 20 | 21 | (def reg? '#{a b c d}) 22 | (def reg-or-val? #(or (reg? %) (integer? %))) 23 | 24 | (defmulti trans (fn [_ b] (first b))) 25 | (defmethod trans 'inc [s [_ reg]] 26 | (assert (reg? reg)) 27 | (update-reg s reg inc)) 28 | 29 | (defmethod trans 'dec [s [_ reg]] 30 | (assert (reg? reg)) 31 | (update-reg s reg dec)) 32 | 33 | (defmethod trans 'cpy [s [_ reg-val reg]] 34 | (assert (and (reg-or-val? reg-val) (reg? reg))) 35 | (-> s (assoc reg (reg-or-val s reg-val)) (update :pos inc))) 36 | 37 | (defmethod trans 'jnz [s [_ reg-val steps]] 38 | (assert (and (reg-or-val? reg-val) (reg-or-val? steps))) 39 | (update s :pos + 40 | (if-not (zero? (reg-or-val s reg-val)) 41 | (reg-or-val s steps) 42 | 1))) 43 | 44 | (defn tgl-inst [inst] 45 | (update-in inst [0] 46 | #(if (= 1 (count (rest inst))) 47 | (if (= 'inc %) 'dec 'inc) 48 | (if (= 'jnz %) 'cpy 'jnz)))) 49 | 50 | (defmethod trans 'tgl [{:keys [pos instr] :as s} [_ reg-val]] 51 | (assert (reg-or-val? reg-val)) 52 | (let [pos-to-change (+ pos (reg-or-val s reg-val))] 53 | (if (get instr pos-to-change nil) 54 | (-> s 55 | (update-in [:instr pos-to-change] tgl-inst) 56 | (update :pos inc)) 57 | (update s :pos inc)))) 58 | 59 | (defn start-state [instructions] 60 | (assoc '{a 0 b 0 c 0 d 0 :pos 0} 61 | :instr (vec instructions))) 62 | 63 | ;; for part 2 64 | 65 | (defn multiply-instructions? [instructions] 66 | (= '[[inc a] 67 | [dec c] 68 | [jnz c -2] 69 | [dec d] 70 | [jnz d -5]] 71 | (take 5 instructions))) 72 | 73 | (defn multiply [st] 74 | (-> st 75 | (update 'a + (* (get st 'c) (get st 'd))) 76 | (assoc 'c 0) 77 | (assoc 'd 0) 78 | (update :pos + 5))) 79 | 80 | (defn run-prog [start-state] 81 | (take-while (comp not nil?) 82 | (iterate (fn [{:keys [pos instr] :as s}] 83 | (when-let [inst (get instr pos nil)] 84 | (try 85 | (if (multiply-instructions? (drop pos instr)) 86 | (multiply s) 87 | (trans s inst)) 88 | (catch Throwable e 89 | (println "Skipping " (pr-str inst)) 90 | (update s :pos inc) 91 | #_(throw (ex-info "error" {:inst inst :st s})))))) 92 | start-state))) 93 | 94 | ;; part 1 95 | #_ (time (last (run-prog (assoc (start-state input) 'a 7)))) 96 | ;; => 12654 97 | 98 | ;; part 2 99 | #_ (time (last (run-prog (assoc (start-state input) 'a 12)))) 100 | ;; => 479009214 101 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day24.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day24 2 | (:require 3 | [advent-of-clojure-2016.utils :as u] 4 | [clojure.java.io :as io] 5 | [clojure.set :refer [difference]] 6 | [medley.core :refer [distinct-by]] 7 | [clojure.string :as string])) 8 | 9 | ;; travelling salesman problem 10 | 11 | (defn make-map [s] 12 | (->> 13 | (for [[y line] (map-indexed vector (string/split-lines s)) 14 | [x chr] (map-indexed vector line)] 15 | [[x y] chr]) 16 | (into {}))) 17 | 18 | (defn number-positions [m] 19 | (->> (filter #(re-matches #"\d" (str (second %))) m) 20 | (map (comp vec reverse)) 21 | (map #(update % 0 (comp u/to-int str))) 22 | (into {}))) 23 | 24 | (defn open-closed [m] 25 | (into {} 26 | (keep (fn [[k v]] (when (not= \# v) [k v])) m))) 27 | 28 | (defn make-map-state [s] 29 | (let [m (make-map s)] 30 | {:positions (open-closed m) 31 | :number-location (number-positions m) 32 | :location-number (into {} 33 | (map (comp vec reverse) 34 | (number-positions m)))})) 35 | 36 | (def input (make-map-state (slurp (io/resource "day24")))) 37 | 38 | (defn possible-moves [{:keys [moves-so-far positions current-position]}] 39 | (let [nm (map #(mapv + current-position %) (shuffle [[0 1] [0 -1] [1 0] [-1 0]]))] 40 | (filter #(and (not (moves-so-far %)) (positions %)) nm))) 41 | 42 | (defn at-number? [{:keys [current-position location-number]}] 43 | (location-number current-position)) 44 | 45 | (defn make-move [st move] 46 | (let [r (-> st 47 | (update :moves-so-far conj (:current-position st)) 48 | (assoc :current-position move))] 49 | (assoc r :at-number (at-number? r)))) 50 | 51 | (defn next-level [sts] 52 | (->> (mapcat #(map (partial make-move %) (possible-moves %)) sts) 53 | (distinct-by :current-position) 54 | (sort-by #(if (at-number? %) 0 1)))) 55 | 56 | (defn breadth-first-search [st] 57 | (drop 1 (iterate next-level [st]))) 58 | 59 | (defn distances-from-position [st a] 60 | (->> (breadth-first-search (assoc st 61 | :current-position (get-in st [:number-location a]) 62 | :moves-so-far #{})) 63 | (mapcat #(filter :at-number %)) 64 | (distinct-by :at-number) 65 | (take (dec (count (:location-number st)))) 66 | (map #(vector #{a (:at-number %)} (count (:moves-so-far %)))) 67 | (into {}))) 68 | 69 | (defn get-all-distances [input] 70 | (->> (map (partial distances-from-position input) (range 8)) 71 | (reduce (partial merge-with min) {}))) 72 | 73 | (def all-distances (time (get-all-distances input))) 74 | 75 | (defn travelling-salesmen [so-far available distances] 76 | (if (= 8 (count so-far)) 77 | 0 78 | (let [lst (first so-far)] 79 | (reduce min 80 | (map (fn [x] 81 | (+ (get distances #{lst x}) 82 | (travelling-salesmen (cons x so-far) available distances))) 83 | (difference (set available) (set so-far))))))) 84 | 85 | ;; part 1 86 | #_(travelling-salesmen [0] (range 8) all-distances) 87 | ;; => 456 88 | 89 | (defn travelling-salesmen-part-2 [so-far available distances] 90 | (if (= 8 (count so-far)) 91 | (get distances #{(first so-far) 0}) 92 | (let [lst (first so-far)] 93 | (reduce min 94 | (map (fn [x] 95 | (+ (get distances #{lst x}) 96 | (travelling-salesmen-part-2 97 | (cons x so-far) available distances))) 98 | (difference (set available) (set so-far))))))) 99 | 100 | ;; part 2 101 | #_(travelling-salesmen-part-2 [0] (range 8) all-distances) 102 | ;; => 704 103 | 104 | 105 | 106 | 107 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day25.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day25 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (defn parse-instructions [s] 7 | (->> s 8 | (string/split-lines) 9 | (map #(str "[" % "]")) 10 | (map read-string) 11 | vec)) 12 | 13 | (def input (parse-instructions (slurp (io/resource "day25")))) 14 | 15 | (defn reg-or-val [s reg-val] (if (symbol? reg-val) (get s reg-val) reg-val)) 16 | 17 | (defn update-reg [s reg f] 18 | (-> s (update reg f) (update :pos inc))) 19 | 20 | (defmulti trans (fn [_ b] (first b))) 21 | 22 | (defmethod trans 'inc [s [_ reg]] 23 | (update-reg s reg inc)) 24 | 25 | (defmethod trans 'dec [s [_ reg]] 26 | (update-reg s reg dec)) 27 | 28 | (defmethod trans 'out [s [_ reg-val]] 29 | (-> s 30 | (update :output conj (reg-or-val s reg-val)) 31 | (update :pos inc))) 32 | 33 | (defmethod trans 'cpy [s [_ reg-val reg]] 34 | (-> s (assoc reg (reg-or-val s reg-val)) (update :pos inc))) 35 | 36 | (defmethod trans 'jnz [s [_ reg-val steps]] 37 | (update s :pos + 38 | (if-not (zero? (reg-or-val s reg-val)) 39 | (reg-or-val s steps) 40 | 1))) 41 | 42 | (defn start-state [instructions] 43 | (assoc '{a 0 b 0 c 0 d 0 :pos 0} 44 | :instr (vec instructions) 45 | :output [])) 46 | 47 | ;; for part 2 48 | 49 | ;; not general 50 | (defn multiply-instructions? [instructions] 51 | (= '[[inc d] 52 | [dec b] 53 | [jnz b -2] 54 | [dec c] 55 | [jnz c -5]] 56 | (take 5 instructions))) 57 | 58 | (defn multiply [st] 59 | (-> st 60 | (update 'd + (* (get st 'b) (get st 'c))) 61 | (assoc 'b 0) 62 | (assoc 'c 0) 63 | (update :pos + 5))) 64 | 65 | (defn run-prog [start-state] 66 | (take-while (comp not nil?) 67 | (iterate (fn [{:keys [pos instr] :as s}] 68 | (when-let [inst (get instr pos)] 69 | (if (multiply-instructions? (drop pos instr)) 70 | (multiply s) 71 | (trans s inst)))) 72 | start-state))) 73 | 74 | (defn try-start-int [n] 75 | (:output (last (take-while #(not= (count (:output %)) 9) 76 | (run-prog (assoc (start-state input) 'a n)))))) 77 | 78 | ;; part 1 79 | #_(count 80 | (take-while #(not= [0 1 0 1 0 1 0 1] %) 81 | (map try-start-int (range 0 1000)))) 82 | ;; => 198 83 | 84 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day3.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day3 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def lines (line-seq (io/reader (io/resource "day3")))) 6 | 7 | (defn parse-triangle [line] 8 | (read-string (str "[" line "]"))) 9 | 10 | (defn valid? [[a b c]] 11 | (and (> (+ a b) c) 12 | (> (+ b c) a) 13 | (> (+ c a) b))) 14 | 15 | ;; part 1 16 | #_(->> lines 17 | (map parse-triangle) 18 | (filter valid?) 19 | count) 20 | ;; => 862 21 | 22 | (def transpose (partial apply mapv vector)) 23 | 24 | ;; part 2 25 | #_(->> lines 26 | (map parse-triangle) 27 | (partition 3) 28 | (mapcat transpose) 29 | (filter valid?) 30 | count) 31 | ;; => 1577 32 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day4.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day4 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def lines (line-seq (io/reader (io/resource "day4")))) 7 | 8 | (defn parse-room [s] 9 | (let [parts (string/split s #"-") 10 | [id chk] (string/split (last parts) #"\[")] 11 | {:word (apply concat (butlast parts)) 12 | :chksum (butlast chk) 13 | :id (Integer/parseInt id)})) 14 | 15 | (defn checksum [word] 16 | (->> word 17 | frequencies 18 | (sort-by (fn [[a b]] [(- b) (int a)])) 19 | (map first) 20 | (take 5))) 21 | 22 | (defn real-room? [{:keys [word chksum] :as room}] 23 | (= (checksum word) chksum)) 24 | 25 | (comment 26 | (real-room? (parse-room "aaaaa-bbb-z-y-x-123[abxyz]")) 27 | (real-room? (parse-room "a-b-c-d-e-f-g-h-987[abcde]")) 28 | (real-room? (parse-room "not-a-real-room-404[oarel]")) 29 | (real-room? (parse-room "totally-real-room-200[decoy]")) 30 | ) 31 | 32 | ;; part 1 33 | #_(->> lines 34 | (map parse-room) 35 | (filter real-room?) 36 | (map :id) 37 | (reduce +)) 38 | ;;=> 278221 39 | 40 | (defn shift-letter [n letter] 41 | (-> letter 42 | int 43 | (- 97) 44 | (+ n) 45 | (mod 26) 46 | (+ 97) 47 | char)) 48 | 49 | (defn decrypt [{:keys [word id] :as room}] 50 | (assoc room :decrypted 51 | (apply str (map (partial shift-letter id) word)))) 52 | 53 | #_(decrypt (parse-room "qzmt-zixmtkozy-ivhz-343")) 54 | 55 | ;; part 2 56 | #_(->> lines 57 | (map parse-room) 58 | (filter real-room?) 59 | (map decrypt) 60 | (filter #(re-matches #".*north.*" (:decrypted %))) 61 | first 62 | :id) 63 | ;; => 267 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day5.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day5 2 | (:require 3 | [clojure.java.io :as io] 4 | [digest :refer [md5]] 5 | [medley.core :refer [distinct-by]])) 6 | 7 | (def input "ffykfhsq") 8 | 9 | (defn find-password [code] 10 | (transduce 11 | (comp 12 | (map #(md5 (str code %))) 13 | (filter #(= "00000" (subs % 0 5))) 14 | (map #(nth % 5)) 15 | (take 8)) 16 | conj 17 | [] 18 | (range))) 19 | 20 | #_ (def res (time (find-password input))) 21 | ;; => [\c \6 \6 \9 \7 \b \5 \5] 22 | ;; 23.4 seconds baby! 23 | 24 | (defn find-codes-2 [code] 25 | (transduce 26 | (comp 27 | (map #(md5 (str code %))) 28 | (filter #(and (= "00000" (subs % 0 5)) 29 | (> 8 (Integer/parseInt (subs % 5 6) 16)))) 30 | (map (juxt #(Integer/parseInt (str (nth % 5))) 31 | #(nth % 6))) 32 | (distinct-by first) 33 | (take 8)) 34 | conj 35 | [] 36 | (range))) 37 | 38 | (defn result-password [codes] 39 | (reduce #(assoc %1 (first %2) (second %2)) (vec (replicate 8 '_)) codes)) 40 | 41 | #_ (def res2 (time (result-password (find-codes-2 input)))) 42 | ;; => [\8 \c \3 \5 \d \1 \a \b] 43 | ;; 110 seconds 44 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day6.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day6 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def data (line-seq (io/reader (io/resource "day6")))) 6 | 7 | (def transpose (partial apply mapv vector)) 8 | 9 | (defn pull-by [sort-fn d] 10 | (->> d 11 | frequencies 12 | (sort-by sort-fn) 13 | ffirst)) 14 | 15 | ;; part 1 16 | #_(->> data 17 | transpose 18 | (map (partial pull-by (comp - second)))) 19 | ;; => (\x \h \n \q \p \q \q \l) 20 | 21 | ;; part 2 22 | #_(->> data 23 | transpose 24 | (map (partial pull-by second))) 25 | ;; => (\b \r \h \a \i \l \r \o) 26 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day7.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day7 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def data (line-seq (io/reader (io/resource "day7")))) 6 | 7 | (defn abba? [[a b c d :as x]] 8 | {:pre [(= 4 (count x))]} 9 | (and (not= a b) (= a d) (= b c))) 10 | 11 | (defn separate-parts [s] 12 | (->> s 13 | (partition-by #{\[ \]}) 14 | (reduce (fn [{:keys [k] :as st} v] 15 | (condp = v 16 | [\[] (assoc st :k :neg) 17 | [\]] (assoc st :k :pos) 18 | (update-in st [k] conj v))) 19 | {:k :pos}))) 20 | 21 | (defn contains-abba? [s] 22 | (some abba? (partition 4 1 s))) 23 | 24 | (defn supports-tls? [s] 25 | (let [{:keys [pos neg]} (separate-parts s)] 26 | (and (some contains-abba? pos) 27 | (every? (complement contains-abba?) neg)))) 28 | 29 | ;; part 1 30 | #_(count (filter identity (map supports-tls? data))) 31 | ;; => 115 32 | 33 | (defn ssl? [[a b c :as x]] 34 | {:pre [(= 3 (count x))]} 35 | (and (not= a b) (= a c))) 36 | 37 | (defn ssl-inv? [[a b c :as x] [a1 b1 c1 :as y]] 38 | {:pre [(= 3 (count x)) (= 3 (count y)) (ssl? x)]} 39 | (and (= a b1) (= b a1 c1))) 40 | 41 | (defn contains-pred? [f s] 42 | (first (filter f (partition 3 1 s)))) 43 | 44 | (defn supports-ssl? [s] 45 | (let [{:keys [pos neg]} (separate-parts s)] 46 | (some identity 47 | (for [ssl-x (mapcat #(filter ssl? (partition 3 1 %)) pos)] 48 | (some #(contains-pred? (partial ssl-inv? ssl-x) %) neg))))) 49 | 50 | ;; part 2 51 | #_(count (filter identity (map supports-ssl? data))) 52 | ;; => 231 53 | 54 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day8.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day8 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def data (line-seq (io/reader (io/resource "day8")))) 7 | 8 | (def board (vec (repeat 6 (vec (repeat 50 '_))))) 9 | 10 | (defn rect [b w h] 11 | (->> (for [x (range w) y (range h)] [y x]) 12 | (reduce #(assoc-in %1 %2 'X) b))) 13 | 14 | (def transpose #(apply mapv vector %)) 15 | 16 | (defn rotate [v a] 17 | (let [c (count v) 18 | r (- c (mod a c))] 19 | (vec (concat (drop r v) (take r v))))) 20 | 21 | (defn rotate-row [b c a] 22 | (update-in b [c] rotate a)) 23 | 24 | (defn rotate-column [b c a] 25 | (-> b transpose (rotate-row c a) transpose)) 26 | 27 | (def to-ints (partial map #(Integer/parseInt %))) 28 | 29 | (defn parse-rect-args [x] (to-ints (string/split x #"x"))) 30 | 31 | (defn parse-rotate-args [x] (to-ints [(subs (first x) 2) (last x)])) 32 | 33 | (defn line-to-command [b line] 34 | (let [[x & xs] (string/split line #"\s")] 35 | (if (= "rect" x) 36 | (apply rect b (parse-rect-args (first xs))) 37 | (let [[x & xs] xs] 38 | (if (= "column" x) 39 | (apply rotate-column b (parse-rotate-args xs)) 40 | (apply rotate-row b (parse-rotate-args xs))))))) 41 | 42 | ;; part 1 43 | #_(->> data 44 | (reduce line-to-command board) 45 | (apply concat) 46 | (filter #{'X}) 47 | count) 48 | ;; => 121 49 | 50 | ;; part 2 51 | #_(reduce line-to-command board data) 52 | ;; => RURUCEOEIL 53 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/day9.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.day9 2 | (:require 3 | [advent-of-clojure-2016.utils :as u] 4 | [clojure.java.io :as io] 5 | [clojure.string :as string])) 6 | 7 | (def data (string/trim (slurp (io/resource "day9")))) 8 | 9 | (def directive-regex #"(\((\d+)x(\d+)\)).*") 10 | 11 | (defn parse-dir [s] 12 | (when-let [[_ directive & args] (re-matches directive-regex (apply str s))] 13 | [(u/to-ints args) (drop (count directive) s)])) 14 | 15 | (defn parse-directive [s] 16 | (when-let [[[cnt rpt] s] (parse-dir s)] 17 | [(take (* cnt rpt) (cycle (take cnt s))) (drop cnt s)])) 18 | 19 | (defn starts-with-directive? [d] 20 | (re-matches directive-regex (apply str (take 20 d)))) 21 | 22 | (defn has-directive? [d] 23 | (re-find directive-regex (apply str d))) 24 | 25 | (defn part1 [d] 26 | (loop [accum [] data d] 27 | (cond 28 | (empty? data) (apply str accum) 29 | (starts-with-directive? data) 30 | (let [[ac s] (parse-directive data)] 31 | (recur (concat accum ac) s)) 32 | :else (recur (conj (vec accum) (first data)) (rest data))))) 33 | 34 | ;; part 1 35 | #_(count (part1 data)) 36 | ;; => 112830 37 | 38 | (defn part2 [d] 39 | (loop [accum 0 data d] 40 | (cond 41 | (empty? data) accum 42 | (starts-with-directive? data) 43 | (when-let [[[cnt rpt] s] (parse-dir data)] 44 | (let [[part s] (split-at cnt s)] 45 | (recur (+ accum 46 | (* rpt (if (has-directive? part) (part2 part) (count part)))) 47 | s))) 48 | :else (recur (inc accum) (rest data))))) 49 | 50 | #_(part2 "(27x12)(20x12)(13x14)(7x10)(1x12)A") 51 | #_(part2 "(25x3)(3x3)ABC(2x3)XY(5x2)PQRSTX(18x9)(3x2)TWO(5x7)SEVEN") 52 | 53 | #_(time (part2 data)) 54 | 55 | ;; => 10931789799 56 | 57 | 58 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2016/utils.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.utils) 2 | 3 | (defn log [x] (println "log: " (pr-str x)) x) 4 | 5 | (def transpose (partial apply mapv vector)) 6 | 7 | (defn rotate-left [v i] 8 | (let [c (count v)] 9 | (into [] (comp (drop (mod i c)) (take c)) (cycle v)))) 10 | 11 | (defn rotate-right [v i] 12 | (rotate-left v (- i))) 13 | 14 | (defn insert-at [x n i] 15 | (let [[a b] (split-at n x)] 16 | (into (conj (vec a) i) b))) 17 | 18 | (defn delete-at [x n] 19 | (let [[a b] (split-at n x)] 20 | (into (vec a) (rest b)))) 21 | 22 | (defn pluck [pred list] 23 | [(filter pred list) (remove pred list)]) 24 | 25 | (def to-int #(Integer/parseInt %)) 26 | (def to-ints (partial map to-int)) 27 | 28 | (defn apply-times [n f init] 29 | (loop [c 0 h init] (if (= c n) h (recur (inc c) (f h))))) 30 | 31 | (defn indexes-by [f coll] 32 | (sequence 33 | (comp 34 | (map-indexed vector) 35 | (filter (comp f second)) 36 | (map first)) 37 | coll)) 38 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day01.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day01 2 | (:require [clojure.java.io :as io])) 3 | 4 | (def data (mapv 5 | (comp read-string str) 6 | (slurp (io/resource "2017/day01")))) 7 | 8 | (defn count-em [d] 9 | (->> (partition 2 1 (conj (vec d) (first d))) 10 | (filter (partial apply =)) 11 | (map first) 12 | (apply +))) 13 | 14 | (comment 15 | (count-em [1 1 2 2]) 16 | (count-em [1 1 1 1]) 17 | (count-em [1 2 3 4]) 18 | (count-em [9 1 2 1 2 1 2 9])) 19 | 20 | ;; part 1 21 | #_(count-em data) 22 | 23 | (defn count-em2 [d] 24 | (->> (map 25 | vector 26 | d 27 | (drop (/ (clojure.core/count d) 2) (cycle d))) 28 | (filter (partial apply =)) 29 | (map first) 30 | (apply +))) 31 | 32 | (comment 33 | (count-em2 [1 2 1 2]) 34 | (count-em2 [1 2 2 1]) 35 | (count-em2 [1 2 3 4 2 5]) 36 | (count-em2 [1 2 3 1 2 3]) 37 | (count-em2 [1 2 1 3 1 4 1 5])) 38 | 39 | ;; part 2 40 | #_(count-em2 data) 41 | 42 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day02.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day02 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def data (->> 7 | (io/resource "2017/day02") 8 | io/reader 9 | line-seq 10 | (mapv (comp (partial mapv read-string) 11 | #(string/split % #"\s+"))))) 12 | 13 | (defn checksum-1 [row] 14 | (- (apply max row) (apply min row))) 15 | 16 | (and 17 | (= 8 (checksum-1 [5 1 9 5])) 18 | (= 4 (checksum-1 [7 5 3])) 19 | (= 6 (checksum-1 [2 4 6 8]))) 20 | 21 | ;; part 1 22 | #_(apply + (map checksum-1 data)) 23 | 24 | (defn checksum-2 [row] 25 | (first (for [a row 26 | b row 27 | :when (and (not= a b) 28 | (= 0 (rem a b)))] 29 | (/ a b)))) 30 | 31 | (and 32 | (= (checksum-2 [5 9 2 8]) 4) 33 | (= (checksum-2 [9 4 7 3]) 3) 34 | (= (checksum-2 [3 8 6 5]) 2)) 35 | 36 | ;; part 2 37 | #_(apply + (map checksum-2 data)) 38 | 39 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day03.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day03 2 | (:require 3 | [clojure.core.reducers :as r])) 4 | 5 | (def directions [[0 -1] [1 0] [0 1] [-1 0]]) 6 | 7 | ;; a lazy list of all the directions travelled in order 8 | ;; from the start of the spiral 9 | (def spiral-direction-list 10 | (for [step (range) 11 | stage (range (* 2 step)) 12 | :let [direction-total 13 | (- (* 2 step) 14 | (if (< stage step) 1 0))]] 15 | (mod direction-total 4))) 16 | 17 | (defn next-position [pos direction] 18 | (mapv + pos (directions direction))) 19 | 20 | (def spiral-positions-list 21 | (reductions next-position [0 0] spiral-direction-list)) 22 | 23 | (defn position-at-index [index] 24 | (nth spiral-positions-list (dec index))) 25 | 26 | ;; part 1 27 | #_(->> (position-at-index 347991) 28 | (map #(Math/abs %)) 29 | (apply +)) 30 | 31 | (def all-directions 32 | (into [[-1 -1] [-1 1] [1 -1] [1 1]] 33 | directions)) 34 | 35 | (defn all-neigbor-positions [pos] 36 | (mapv #(mapv + pos %) all-directions)) 37 | 38 | (defn neigbor-values [pos positions] 39 | (keep positions (all-neigbor-positions pos))) 40 | 41 | (defn state-transition [{:keys [positions] :as state} next-pos] 42 | (let [value (apply + (neigbor-values next-pos positions))] 43 | (-> state 44 | (assoc :value value) 45 | (assoc-in [:positions next-pos] value)))) 46 | 47 | (def neighbor-value-list 48 | (map :value 49 | (reductions 50 | state-transition 51 | {:value 1 52 | :positions {[0 0] 1}} 53 | (rest spiral-positions-list)))) 54 | 55 | ;; part 2 56 | 57 | #_(->> neighbor-value-list 58 | (filter #(> % 347991)) 59 | first) 60 | 61 | 62 | ;; After looking at some others code I especially like this 63 | ;; straightforward way of generating the spiral directions list 64 | 65 | #_(take 10 (mapcat 66 | (fn [[i [dir1 dir2]]] 67 | (vec (concat (repeat i dir1) (repeat i dir2)))) 68 | (map vector (rest (range)) (partition 2 (rest (cycle directions)))))) 69 | 70 | 71 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day04.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day04 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string] 5 | [medley.core :as m])) 6 | 7 | (def data 8 | (->> (io/resource "2017/day04") 9 | io/reader 10 | line-seq 11 | (mapv #(string/split % #"\s")))) 12 | 13 | ;; part 1 14 | #_(count (filter #(= (count (distinct %)) (count %)) 15 | data)) 16 | 17 | ;; part 2 18 | #_(count (filter #(= (count (m/distinct-by frequencies %)) (count %)) 19 | data)) 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day05.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day05 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.core.reducers :as r])) 5 | 6 | (def test-data [0 3 0 1 -3]) 7 | 8 | (def data (->> (io/resource "2017/day05") 9 | io/reader 10 | line-seq 11 | (mapv read-string) 12 | (mapv int))) 13 | 14 | (defn interpret [{:keys [position instructions] :as env}] 15 | (when-let [inst (get instructions position)] 16 | (-> env 17 | (update :position + inst) 18 | (update-in [:instructions position] inc)))) 19 | 20 | ;; part 1 21 | #_(->> (iterate interpret {:position 0 :instructions data}) 22 | (take-while identity) 23 | rest 24 | count) 25 | ;;=> 358309 26 | 27 | (defn interpret-2 [[^int position instructions]] 28 | (when-let [inst ^int (get instructions position)] 29 | [(+ position inst) 30 | (assoc! instructions position (if (>= inst 3) (dec inst) (inc inst)))])) 31 | 32 | ;; part 2 33 | #_(time 34 | (reduce 35 | (fn [x _] (inc x)) 36 | -1 37 | (eduction 38 | (take-while identity) 39 | (iterate interpret-2 [0 (transient data)])))) 40 | 41 | ;; Elapsed time: 5873.206687 msecs 42 | ;; => 28178177 43 | 44 | ;; fastest with a native array and fully type hinted loop 45 | (comment 46 | (set! *warn-on-reflection* true) 47 | (set! *unchecked-math* :warn-on-boxed) 48 | ) 49 | 50 | #_(time 51 | (let [instructions ^ints (into-array Integer/TYPE data) 52 | length ^int (count instructions)] 53 | (loop [step 0 position 0] 54 | (if (< position length) 55 | (let [inst (aget instructions position)] 56 | (aset instructions position 57 | (if (>= inst 3) (dec inst) (inc inst))) 58 | (recur (inc step) (+ position inst))) 59 | step)))) 60 | ;; "Elapsed time: 198.752469 msecs" 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day06.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day06 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def test-data [0 2 7 0]) 6 | 7 | (def data (read-string 8 | (str "[" (slurp (io/resource "2017/day06")) "]"))) 9 | 10 | (defn redistribute [block] 11 | (let [max-val (apply max block) 12 | position (.indexOf block max-val)] 13 | (reduce #(update-in %1 [(mod %2 (count %1))] inc) 14 | (assoc block position 0) 15 | (range (inc position) 16 | (+ (inc position) max-val))))) 17 | 18 | ; part 1 19 | (defn part1 [first-block] 20 | (count (reduce 21 | (fn [history-set next-block] 22 | (if (history-set next-block) 23 | (reduced history-set) 24 | (conj history-set next-block))) 25 | #{} 26 | (iterate redistribute first-block)))) 27 | 28 | #_(part1 data) 29 | ;;=> 7864 30 | 31 | ;; part 2 32 | (defn part2 [first-block] 33 | (reduce 34 | (fn [history-map next-block] 35 | (if-let [result (history-map next-block)] 36 | (reduced (- (count history-map) result)) 37 | (assoc history-map next-block (count history-map)))) 38 | {} 39 | (iterate redistribute first-block))) 40 | 41 | #_(part2 data) 42 | ;;=> 1695 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day07.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day07 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (defn parse-data [lines] 7 | (->> lines 8 | (map #(str "[" % "]")) 9 | (map read-string))) 10 | 11 | (def data (->> (io/resource "2017/day07") 12 | io/reader 13 | line-seq 14 | parse-data)) 15 | 16 | (defn index-data [graph-data] 17 | (reduce 18 | (fn [accum [name [weight] _ & children]] 19 | (-> (reduce #(assoc-in %1 [:parent %2] name) accum children) 20 | (assoc-in [:weights name] weight) 21 | (assoc-in [:children name] (set children)))) 22 | {} 23 | graph-data)) 24 | 25 | (defn tree-root [parent-graph child] 26 | (last (take-while some? (iterate parent-graph child))) ) 27 | 28 | ; part 1 29 | #_(let [{:keys [parent]} (index-data data)] 30 | (tree-root parent (rand-nth (vals parent)))) 31 | 32 | ;; the computational complexity of this problem doesn't merit 33 | ;; memoization of tree traversal 34 | (defn node-total-weight [{:keys [weights children] :as index} node] 35 | (if-let [childs (not-empty (children node))] 36 | (apply + (weights node) (map (partial node-total-weight index) childs)) 37 | (weights node))) 38 | 39 | (defn different-child [children-and-weights] 40 | (let [grouped (group-by second children-and-weights)] 41 | (when (< 1 (count grouped)) 42 | (let [[[[x _]]] (filter #(= 1 (count %)) (vals grouped))] 43 | x)))) 44 | 45 | (defn child-node-and-weight-totals [{:keys [children] :as index} node] 46 | (->> (children node) 47 | (map (juxt identity (partial node-total-weight index))) 48 | (into {}))) 49 | 50 | (defn find-deepest-unequal-child [{:keys [parent children] :as index}] 51 | (->> (tree-root parent (first (vals parent))) 52 | (iterate #(different-child (child-node-and-weight-totals index %))) 53 | (take-while some?) 54 | last)) 55 | 56 | (defn part-2 [data] 57 | (let [{:keys [parent children] :as index} (index-data data) 58 | child-node-weights (partial child-node-and-weight-totals index) 59 | deepest-unequal-node (find-deepest-unequal-child index) 60 | children-total-weight (apply + (vals (child-node-weights deepest-unequal-node))) 61 | target-weight (-> (child-node-weights (parent deepest-unequal-node)) ;; siblings 62 | (dissoc deepest-unequal-node) 63 | vals 64 | first)] 65 | (- target-weight children-total-weight))) 66 | 67 | #_ (time (part-2 data)) 68 | ;;=> 1864 69 | 70 | 71 | (comment 72 | (def test-data 73 | (-> "pbga (66) 74 | xhth (57) 75 | ebii (61) 76 | havc (66) 77 | ktlj (57) 78 | fwft (72) -> ktlj, cntj, xhth 79 | qoyq (66) 80 | padx (45) -> pbga, havc, qoyq 81 | tknk (41) -> ugml, padx, fwft 82 | jptl (61) 83 | ugml (68) -> gyxo, ebii, jptl 84 | gyxo (61) 85 | cntj (57)" 86 | string/split-lines 87 | parse-data)) 88 | ) 89 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day08.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day08 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (defn parse-data [lines] 7 | (->> lines 8 | (map #(str "[" % "]")) 9 | (map read-string))) 10 | 11 | (def data (->> (io/resource "2017/day08") 12 | io/reader 13 | line-seq 14 | parse-data)) 15 | 16 | (def fn-map 17 | (->> (map (juxt identity eval)'(> < >= <= ==)) 18 | (into {'inc (fnil + 0) 19 | 'dec (fnil - 0) 20 | '!= not=}))) 21 | 22 | (defn eval-exp [accum [reg inc-dec value _ cond-reg pred pred-val]] 23 | (if ((fn-map pred) (get accum cond-reg 0) pred-val) 24 | (update accum reg (fn-map inc-dec) value) 25 | accum)) 26 | 27 | (defn part1 [instructions] 28 | (->> (reduce eval-exp {} instructions) 29 | vals 30 | (apply max))) 31 | 32 | ;; part 1 33 | #_(part1 data) 34 | ;; => 5075 35 | 36 | (defn part2 [instructions] 37 | (->> (reductions eval-exp {} instructions) 38 | (keep vals) 39 | (map (partial apply max)) 40 | (apply max))) 41 | 42 | ;; part 2 43 | #_(part2 data) 44 | ;; => 7310 45 | 46 | 47 | (comment 48 | (def test-data 49 | (-> "b inc 5 if a > 1 50 | a inc 1 if b < 5 51 | c dec -10 if a >= 1 52 | c inc -20 if c == 10" 53 | string/split-lines 54 | parse-data)) 55 | ) 56 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day09.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day09 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def data (slurp (io/resource "2017/day09"))) 7 | 8 | (defn parse-structure [data] 9 | (-> data 10 | ;; eliminate escapes 11 | (string/replace #"(!+)(.)" #(if (odd? (count (second %))) "" (last %))) 12 | ;; replace garbage with garbage count 13 | (string/replace #"<[^>]*>" (comp str dec dec count)) 14 | (string/replace "{" "(") 15 | (string/replace "}" ")") 16 | ;; parse as clojure data!! 17 | read-string)) 18 | 19 | (defn score 20 | ([data] (score data 1)) 21 | ([data depth] 22 | (cond 23 | (number? data) 0 24 | (empty? data) depth 25 | :else (+ depth (apply + (map #(score % (inc depth)) data)))))) 26 | 27 | ;; part 1 28 | #_ (score (parse-structure data)) 29 | ;;=> 13154 30 | 31 | ;; part 2 32 | #_ (apply + (flatten (parse-structure data))) 33 | ;;=> 6369 34 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day10.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day10 2 | (:require 3 | [clojure.string :as string] 4 | [clojure.core.reducers :as r])) 5 | 6 | (def data [102,255,99,252,200,24,219,57,103,2,226,254,1,0,69,216]) 7 | 8 | ;; optimized for speed 9 | (defn inplace-reverse [x pos length] 10 | (let [idx (mapv #(mod % (count x)) 11 | (range pos (+ pos length))) 12 | vs (r/reduce #(cons (get x %2) %1) '() idx)] 13 | (persistent! 14 | (loop [[id & idx'] idx 15 | [v & vs'] vs 16 | x (transient x)] 17 | (if id 18 | (recur idx' vs' (assoc! x id v)) 19 | x))))) 20 | 21 | (defn transition [[x pos skip] length] 22 | [(inplace-reverse x pos length) 23 | (+ pos length skip) 24 | (inc skip)]) 25 | 26 | (def hash-round #(r/reduce transition %2 %1)) 27 | 28 | ;; part 1 29 | #_ (->> (hash-round data [(vec (range 256)) 0 0]) 30 | first 31 | (take 2) 32 | (apply *)) 33 | ;; => 5577 34 | 35 | (defn sparse-hash [data] 36 | (first 37 | (nth (iterate (partial hash-round (concat data [17, 31, 73, 47, 23])) 38 | [(vec (range 256)) 0 0]) 39 | 64))) 40 | 41 | (defn dense-hash [sparseh] 42 | (->> sparseh 43 | (partition 16) 44 | (map #(reduce bit-xor %)) 45 | (map #(format "%02x" %)) 46 | (apply str))) 47 | 48 | (def part-2 (comp dense-hash sparse-hash)) 49 | 50 | ;; part 2 51 | #_ (time (part-2 (map int (string/join "," data)))) 52 | ;; Elapsed time: 55.868713 msecs 53 | ;; => 44f4befb0f303c0bafd085f97741d51d 54 | 55 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day11.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day11 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def data (read-string (format "[%s]" (slurp (io/resource "2017/day11"))))) 6 | 7 | ;ne,ne,ne is 3 steps away. 8 | ;ne,ne,sw,sw is 0 steps away (back where you started). 9 | ;ne,ne,s,s is 2 steps away (se,se). 10 | ;se,sw,se,sw,sw is 3 steps away (s,s,sw). 11 | 12 | ;; this can be represented in terms of x and y coords 13 | ;; with a single diagonal path in each square 14 | ;; *-*-*-*-*-* 15 | ;; |/|/|/|/|/| 16 | ;; *-*-*-*-*-* 17 | ;; |/|/|/|/|/| 18 | ;; *-*-*-*-*-* 19 | ;; |/|/|/|/|/| 20 | ;; *-*-*-*-*-* 21 | ;; us regular x y coords and increment both when travelling 22 | ;; on the diagonal 23 | 24 | (def directions 25 | {'n [1 1] 26 | 's [-1 -1] 27 | 'nw [0 1] 28 | 'ne [1 0] 29 | 'se [0 -1] 30 | 'sw [-1 0]}) 31 | 32 | ;; the distance formula is (max x y) if the point lies in 33 | ;; the direction of the diagonals 34 | 35 | ;; the distance formula is (+ x y) if the point lies against 36 | ;; the direction of the diagonals 37 | 38 | (defn distance [coord] 39 | (if (or (every? pos? coord) (every? neg? coord)) 40 | (apply max (mapv #(Math/abs %) coord)) 41 | (apply + (mapv #(Math/abs %) coord)))) 42 | 43 | (defn path-to-coord [path] 44 | (reduce #(mapv + %1 (directions %2)) [0 0] path)) 45 | 46 | ;; tests 47 | #_(and 48 | (= 3 (distance (path-to-coord '(ne ne ne)))) 49 | (= 0 (distance (path-to-coord '(ne ne sw sw)))) 50 | (= 2 (distance (path-to-coord '(ne ne s s)))) 51 | (= 3 (distance (path-to-coord '(se,sw,se,sw,sw))))) 52 | 53 | ; part 1 54 | #_(distance (path-to-coord data)) 55 | ;; => 812 56 | 57 | (defn paths-to-coord [path] 58 | (reductions #(mapv + %1 (directions %2)) [0 0] path)) 59 | 60 | ;; part 2 61 | #_(reduce max (map distance (paths-to-coord data))) 62 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day12.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day12 2 | (:require 3 | [clojure.java.io :as io] 4 | 5 | [clojure.set :as st])) 6 | 7 | (def data (->> (io/resource "2017/day12") 8 | io/reader 9 | line-seq 10 | (map #(format "[%s]" %)) 11 | (map read-string))) 12 | 13 | (defn index [data'] 14 | (reduce (fn [accum [node _ & direct-connect]] 15 | (as-> (set direct-connect) x 16 | (disj x node) 17 | (assoc accum node x))) 18 | {} 19 | data')) 20 | 21 | ;; find group without cycles 22 | 23 | (defn group [idx root] 24 | (into #{} 25 | (tree-seq (let [seen (atom #{})] 26 | (fn [x] (when-not (@seen x) 27 | (swap! seen conj x)))) 28 | idx 29 | root))) 30 | 31 | ;; part 1 32 | #_(let [idx (index data)] 33 | (time (count (group idx 0)))) 34 | ;; => 113 35 | 36 | ;; part 2 37 | ;; not worth optimizing for problem space 38 | #_(let [idx (index data)] 39 | (->> (map #(group idx %) (keys idx)) 40 | (into #{}) 41 | count)) 42 | ;; => 202 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day13.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day13 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def data (->> (io/resource "2017/day13") 7 | io/reader 8 | line-seq 9 | (map #(string/replace % #":" "")) 10 | (map #(format "[%s]" %)) 11 | (map read-string) 12 | (into (sorted-map)))) 13 | 14 | (defn scanner-position [count level-size] 15 | (let [level-size (dec level-size) 16 | division (/ count level-size)] 17 | (if (even? (long division)) 18 | (rem count level-size) 19 | (- level-size (rem count level-size))))) 20 | 21 | ;; part 1 22 | #_(->> data 23 | (map (juxt #(scanner-position (key %) (val %)) identity)) 24 | (filter (comp zero? first)) 25 | (map (comp #(apply * %) second)) 26 | (apply +)) 27 | ;; => 1476 28 | 29 | (defn build-can-pass-at-time?-fn [data'] 30 | (let [data-size (apply max (keys data'))] 31 | (fn [time-offset] 32 | (some 33 | (fn [[level range']] 34 | (zero? 35 | (scanner-position (+ level time-offset) range'))) 36 | data')))) 37 | 38 | (defn how-many-pico-seconds-to-delay? [data'] 39 | (->> (map (build-can-pass-at-time?-fn data') (range)) 40 | (take-while identity) 41 | count)) 42 | 43 | ;; part 2 44 | #_ (time (how-many-pico-seconds-to-delay? data)) 45 | ;; Elapsed time: 6779.875129 msecs 46 | ;; => 3937334 47 | 48 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day14.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day14 2 | (:require 3 | [advent-of-clojure-2017.day10 :refer [sparse-hash dense-hash]])) 4 | 5 | (def test-input "flqrgnkx") 6 | 7 | (def puzzle-input "oundnydw") 8 | 9 | (defn binary-dense-hash [sparseh] 10 | (->> sparseh 11 | (partition 16) 12 | (map #(reduce bit-xor %)) 13 | (map #(Integer/toBinaryString %)) 14 | (map #(format "%8s" %)) 15 | (apply str))) 16 | 17 | (def knot-hash (comp binary-dense-hash sparse-hash (partial map int))) 18 | 19 | (defn disk-sector-map [input] 20 | (->> (map #(str %1 "-" %2) (repeat input) (range 128)) 21 | (mapv knot-hash))) 22 | 23 | ;; part 1 24 | #_(->> (disk-sector-map puzzle-input) 25 | (map (comp count (partial filter #{\1}))) 26 | (reduce +) 27 | time) 28 | ;; Elapsed time: 3068.830745 msec 29 | ;; => 8106 30 | 31 | (def data (disk-sector-map puzzle-input)) 32 | 33 | (def directions [[0 1] [0 -1] [1 0] [-1 0]]) 34 | 35 | (defn bit-on-at? [data [y x]] 36 | (= \1 (.charAt ^String (get data y) x))) 37 | 38 | (defn children [data pos] 39 | (->> directions 40 | (map #(mapv + pos %)) 41 | (filter (fn [[y x :as pos']] 42 | (and (< -1 y 128) 43 | (< -1 x 128) 44 | (bit-on-at? data pos')))))) 45 | 46 | (defn group [children-fn pos] 47 | (set (tree-seq 48 | (let [seen (atom #{})] 49 | (fn [pos] (when-not (@seen pos) 50 | (swap! seen conj pos) 51 | (not-empty (children-fn pos))))) 52 | children-fn 53 | pos))) 54 | 55 | (defn all-groups [data] 56 | (let [children-fn (memoize (partial children data))] 57 | (into #{} 58 | (for [x (range 128) 59 | y (range 128) 60 | :let [pos [y x]] 61 | :when (bit-on-at? data pos)] 62 | (group children-fn pos))))) 63 | 64 | ;; part 2 65 | #_(time (count (all-groups data))) 66 | ;; Elapsed time: 3772.082083 msecs 67 | ;; => 1164 68 | 69 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day15.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day15) 2 | 3 | (defn transition [f v] 4 | (rem (* ^long f ^long v) 2147483647)) 5 | 6 | (def a-transition (partial transition 16807)) 7 | (def b-transition (partial transition 48271)) 8 | 9 | (defn generate [a-start b-start] 10 | (rest 11 | (map = 12 | (map #(bit-and 2r1111111111111111 ^long %) 13 | (iterate a-transition a-start)) 14 | (map #(bit-and 2r1111111111111111 ^long %) 15 | (iterate b-transition b-start))))) 16 | 17 | ;; part 1 18 | #_(time 19 | (count (filter identity 20 | (take 40000000 (generate 783 325))))) 21 | ;; Elapsed time: 34519.967381 msecs 22 | ;; => 650 23 | 24 | (defn generate-2 [a-start b-start] 25 | (rest 26 | (map = 27 | (map #(bit-and 2r1111111111111111 ^long %) 28 | (filter #(zero? ^long (mod ^long % 4)) 29 | (iterate a-transition a-start))) 30 | (map #(bit-and 2r1111111111111111 ^long %) 31 | (filter #(zero? ^long (mod ^long % 8)) 32 | (iterate b-transition b-start)))))) 33 | 34 | #_(set! *unchecked-math* :warn-on-boxed) 35 | 36 | ;; part 2 37 | #_(time 38 | (count (filter identity 39 | (take 5000000 (generate-2 783 325))))) 40 | ;; => 336 41 | ;; Elapsed time: 17035.632906 msecs 42 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day16.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day16 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def dance-calls 7 | (mapv 8 | (fn [[cmd & args]] 9 | (cons cmd (map read-string (string/split (apply str args) #"\/")))) 10 | (string/split 11 | (slurp (io/resource "2017/day16")) 12 | #","))) 13 | 14 | (def start-state '[a b c d e f g h i j k l m n o p]) 15 | 16 | (defmulti dance-mover (fn [_ [cmd]] cmd)) 17 | 18 | (defmethod dance-mover \s [state [_ n] ] 19 | (let [length (count state)] 20 | (vec (take length (drop (mod (- n) length) (cycle state)))))) 21 | 22 | (defmethod dance-mover \x [state [_ a b]] 23 | (assoc state 24 | a (get state b) 25 | b (get state a))) 26 | 27 | (defmethod dance-mover \p [state [_ pa pb]] 28 | (let [a (.indexOf state pa) 29 | b (.indexOf state pb)] 30 | (dance-mover state [\x a b]))) 31 | 32 | (defn whole-dance [dance-calls state] 33 | (reduce dance-mover state dance-calls)) 34 | 35 | ;; test data 36 | #_(whole-dance '[[\s 1] [\x 3 4] [\p e b]] '[a b c d e] ) 37 | 38 | ;; ANSWER part 1 39 | #_(->> (whole-dance dance-calls start-state) 40 | (string/join "")) 41 | ;; => lbdiomkhgcjanefp 42 | 43 | 44 | (def complete-dances (iterate (partial whole-dance dance-calls) start-state)) 45 | 46 | ;; strategy find a period for which the pattern repeats itself 47 | (defn find-cycle-period [whole-dance-seq] 48 | (->> (rest whole-dance-seq) 49 | (take-while #(not= (first whole-dance-seq) %)) 50 | count 51 | inc)) 52 | 53 | #_ (find-cycle-period complete-dances) 54 | ;; => 56 55 | 56 | ;; the dance will cycle every 56 57 | #_ (= (nth complete-dances 56) start-state) 58 | #_ (= (nth complete-dances 112) start-state) 59 | 60 | ;; part 2 answer 61 | #_ (->> (find-cycle-period complete-dances) 62 | (mod 1000000000) 63 | (nth complete-dances) 64 | (string/join "")) 65 | ;; => ejkflpgnamhdcboi 66 | 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day17.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day17) 2 | 3 | (def input-steps 335) 4 | 5 | ;; Use a circular linked list that takes the form 6 | ;; {a -> b, b -> c, c -> a} 7 | ;; this allows a fast insertion of DD at b like so 8 | ;; {a -> b, b -> DD, DD -> c, c -> a} 9 | 10 | ;; using an Array of Long for the underlying associative structure 11 | ;; for speed 12 | (defn splice-in-fast [^long step ^longs state ^long current-number] 13 | (loop [previous-number (dec current-number) 14 | step-count (mod step current-number)] 15 | (if (zero? ^long step-count) 16 | (let [next' (aget state previous-number)] 17 | (doto state 18 | (aset previous-number current-number) 19 | (aset current-number next'))) 20 | (recur (aget state previous-number) (dec ^long step-count))))) 21 | 22 | (def start-state (comp long-array inc)) 23 | 24 | #_(set! *warn-on-reflection* true) 25 | #_(set! *unchecked-math* :warn-on-boxed) 26 | 27 | ;; part 1 28 | #_ (-> (reduce (partial splice-in-fast input-steps) (start-state 2017) 29 | (range 1 2018)) 30 | (get 2017) 31 | time) 32 | ;; Elapsed time: 6.914165 msecs 33 | ;; = 1282 34 | 35 | ;; part 2 36 | #_ (-> (reduce (partial splice-in-fast input-steps) (start-state 50000000) 37 | (range 1 50000001)) 38 | (get 0) 39 | time) 40 | ;; => 27650600 41 | ;; around 5 minutes to complete 42 | 43 | 44 | ;; idea from @val_waeselynck 45 | 46 | ;; better solution for part 2 is to just find the last change to the 1 position 47 | ;; this only works for the 1 position in the puzzle, this is a bit subtle 48 | 49 | (defn transition [^long position ^long v] 50 | (inc ^long (mod (+ position ^long input-steps) v))) 51 | 52 | (defn find-last-after-zero [cycles] 53 | (loop [n 1 54 | pos 0 55 | after-zero nil] 56 | (let [next-pos (transition pos n)] 57 | (if (= n cycles) 58 | after-zero 59 | (recur (inc n) 60 | ^long next-pos 61 | (if (= 1 ^long next-pos) n after-zero)))))) 62 | 63 | ;; better part 2 64 | #_(time (find-last-after-zero (inc 50000000))) 65 | ;; => 27650600 66 | ;; Elapsed time: 4738.406857 msecs 67 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day18.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day18 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def program 6 | (->> (io/resource "2017/day18") 7 | io/reader 8 | line-seq 9 | (map #(format "[%s]" %)) 10 | (mapv read-string))) 11 | 12 | (defmulti instruct (fn [_ [cmd]] cmd)) 13 | 14 | (defn inc-program-counter [state] 15 | (update state :program-counter inc)) 16 | 17 | (defn reg-or-val [state Y] 18 | (if (number? Y) Y (get state Y 0))) 19 | 20 | (defmethod instruct 'snd [state [_ X]] 21 | (inc-program-counter 22 | (assoc state :snd (reg-or-val state X)))) 23 | 24 | (defmethod instruct 'set [state [_ X Y]] 25 | (inc-program-counter 26 | (assoc state X (reg-or-val state Y)))) 27 | 28 | (defmethod instruct 'add [state [_ X Y]] 29 | (inc-program-counter 30 | (update state X (fnil + 0) (reg-or-val state Y)))) 31 | 32 | (defmethod instruct 'mul [state [_ X Y]] 33 | (inc-program-counter 34 | (update state X (fnil * 0) (reg-or-val state Y)))) 35 | 36 | (defmethod instruct 'mod [state [_ X Y]] 37 | (inc-program-counter 38 | (update state X (fnil rem 0) (reg-or-val state Y)))) 39 | 40 | (defmethod instruct 'rcv [state [_ X]] 41 | (inc-program-counter 42 | (if (zero? ^long (reg-or-val state X)) 43 | state 44 | (let [last-sound (get state :snd)] 45 | (assoc state 46 | X last-sound 47 | :rcv last-sound))))) 48 | 49 | (defmethod instruct 'jgz [state [_ X Y]] 50 | (if (> ^long (reg-or-val state X) 0) 51 | (update state :program-counter + (reg-or-val state Y)) 52 | (inc-program-counter state))) 53 | 54 | (defn transition [{:keys [program-counter program] :as state}] 55 | (when-let [instruction (get program program-counter)] 56 | (instruct state instruction))) 57 | 58 | ;; part 1 59 | #_(->> (iterate transition {:program-counter 0 60 | :program program}) 61 | (drop-while (complement :rcv)) 62 | first 63 | :snd 64 | time) 65 | ;; => 8600 66 | ;; Elapsed time: 1.847176 msecs 67 | 68 | ;; override send and recieve 69 | (defn instruct-part2 [state [cmd X :as inst]] 70 | (let [state (dissoc state :blocking)] 71 | (condp = cmd 72 | ;; send to output queue 73 | 'snd (inc-program-counter 74 | (-> state 75 | (assoc :output-val (reg-or-val state X)) 76 | ;; count the messages sent 77 | (update :output-count (fnil inc 0)))) 78 | ;; recieve from input queue 79 | 'rcv (let [{:keys [input-queue]} state] 80 | (if (empty? input-queue) 81 | (assoc state :blocking true) 82 | (inc-program-counter 83 | (assoc state 84 | X (peek input-queue) 85 | :input-queue (pop input-queue))))) 86 | ;; forward to part 1 interpreter 87 | (instruct state inst)))) 88 | 89 | (defn swap-communication-step [[state-a {:keys [output-val] :as state-b} :as states]] 90 | (if output-val 91 | [(update state-a :input-queue (fnil conj clojure.lang.PersistentQueue/EMPTY) output-val) 92 | (dissoc state-b :output-val)] 93 | states)) 94 | 95 | (def swap-communication 96 | (comp reverse swap-communication-step 97 | reverse swap-communication-step)) 98 | 99 | (defn exec-instruction [{:keys [program-counter program] :as state}] 100 | (if-let [instruction (get program program-counter)] 101 | (instruct-part2 state instruction) 102 | (assoc state :blocking true))) 103 | 104 | (defn transition-2 [states] 105 | (mapv exec-instruction (swap-communication states))) 106 | 107 | ;; part 2 108 | #_(->> (iterate transition-2 109 | [{:name 'A 110 | 'p 0 111 | :program-counter 0 112 | :program program} 113 | {:name 'B 114 | 'p 1 115 | :program-counter 0 116 | :program program}]) 117 | (drop-while #(not (every? :blocking %))) 118 | first 119 | second 120 | :output-count 121 | time) 122 | 123 | ;; not publishing until later as the inputs are similar 124 | ;; Elapsed time: 439.798548 msecs 125 | 126 | #_(set! *unchecked-math* :warn-on-boxed) 127 | 128 | 129 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day19.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day19 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def data 6 | (->> (io/resource "2017/day19") 7 | io/reader 8 | line-seq 9 | (mapv vec))) 10 | 11 | (def directions [[1 0] [-1 0] [0 1] [0 -1]]) 12 | 13 | (defn letter? [char'] 14 | (<= (int \A) (int char') (int \Z))) 15 | 16 | (defn starting-x [char-map] 17 | (.indexOf (first char-map) \|)) 18 | 19 | (defn next-directions [char-map [pos prev-pos]] 20 | (if (not= \+ (get-in char-map pos)) 21 | [(mapv - pos prev-pos)] 22 | directions)) 23 | 24 | (defn next-position [char-map [pos prev-pos :as state]] 25 | (->> (next-directions char-map state) 26 | (mapv (partial mapv + pos)) 27 | (filter #(not= prev-pos %)) 28 | (filter #(not= \space (get-in char-map %))) 29 | first)) 30 | 31 | (defn move [char-map [pos :as state]] 32 | [(next-position char-map state) pos]) 33 | 34 | #_(->> (iterate (partial move data) 35 | (let [start-x (starting-x data)] 36 | [[0 start-x] [-1 start-x]])) 37 | (map first) 38 | (take-while identity) 39 | (map (partial get-in data)) 40 | (filter letter?) 41 | (apply str) 42 | time) 43 | ;; part 1 44 | ;; => EOCZQMURF 45 | ;; Elapsed time: 80.573515 msecs 46 | 47 | ;; part 2 48 | #_(->> (iterate (partial move data) 49 | (let [start-x (starting-x data)] 50 | [[0 start-x] [-1 start-x]])) 51 | (map first) 52 | (take-while identity) 53 | count 54 | time) 55 | ;; => 16312 56 | ;; Elapsed time: 72.912626 msecs 57 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day20.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day20 2 | (:require 3 | [clojure.java.io :as io])) 4 | 5 | (def data 6 | (->> (io/resource "2017/day20") 7 | io/reader 8 | line-seq 9 | (map #(re-seq #"[-]*\d+" %)) 10 | (map #(map read-string %)) 11 | (map (comp vec (partial partition 3))))) 12 | 13 | (defn val-vec [n] 14 | (if (number? n) [n n n] n)) 15 | 16 | (def vec* (partial mapv *)) 17 | (def vec+ (partial mapv +)) 18 | 19 | (defn position-at-time [[start-position start-velocity acceleration] t] 20 | ;; 1/2 a t^2 + v t + c 21 | (vec+ (vec* 22 | acceleration 23 | (val-vec (* 0.5 t t))) 24 | (vec* start-velocity (val-vec t)) 25 | start-position)) 26 | 27 | (defn distance-at-time [t particle] 28 | (apply + (map #(Math/abs %) (position-at-time particle t)))) 29 | 30 | ;; part 1 31 | #_ (->> data 32 | (map (juxt identity (partial distance-at-time 1000))) 33 | (sort-by second) 34 | ffirst 35 | (.indexOf data) 36 | time) 37 | ;; => 150 38 | ;; Elapsed time: 32.838903 msecs 39 | 40 | (defn particle-step [[position velocity acceleration :as particle]] 41 | (let [v (vec+ velocity acceleration)] 42 | [(vec+ position v) v acceleration])) 43 | 44 | (defn step [state] 45 | (->> state 46 | (mapv particle-step) 47 | (group-by first) 48 | (filter #(= 1 (count (second %)))) 49 | (mapv (comp first second)))) 50 | 51 | ;; part 2 52 | (->> data 53 | (iterate step) 54 | (drop 100) 55 | first 56 | count 57 | time) 58 | ;; => 657 59 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day21.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day21 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def transpose (partial apply map vector)) 7 | (def flip (partial map reverse)) 8 | (def rotate-right (comp flip transpose)) 9 | 10 | (defn all-rotations [rule-key] 11 | (let [rotations (take 4 (iterate rotate-right (map seq rule-key)))] 12 | (concat rotations (map flip rotations)))) 13 | 14 | (defn expand-rule [rules [rule-key rule-val]] 15 | (->> (repeat (map seq rule-val)) 16 | (map vector (all-rotations rule-key)) 17 | (into {}) 18 | (merge rules))) 19 | 20 | (defn parse-rules [lines] 21 | (->> lines 22 | (map #(string/split % #" => ")) 23 | (map (partial map #(string/split % #"/"))) 24 | (reduce expand-rule {}))) 25 | 26 | (def rules 27 | (->> (io/resource "2017/day21") 28 | io/reader 29 | line-seq 30 | parse-rules)) 31 | 32 | (def start-pixels '((\. \# \.) 33 | (\. \. \#) 34 | (\# \# \#))) 35 | 36 | (defn break-into [grid n] 37 | (map #(map transpose (partition n (transpose %))) 38 | (partition n grid))) 39 | 40 | (defn normalize [broken-out] 41 | (mapcat #(map flatten (transpose %)) broken-out)) 42 | 43 | ;; memoized recursive solution 44 | (defn count-at-depth [depth grid] 45 | (if (zero? depth) 46 | (count (filter #{\#} (flatten grid))) 47 | (condp = (count grid) 48 | 2 (count-at-depth (dec depth) (rules grid)) 49 | 3 (count-at-depth (dec depth) (rules grid)) 50 | 4 (count-at-depth (dec depth) (->> (break-into grid 2) 51 | (map (partial map rules)) 52 | normalize)) 53 | 6 (->> (break-into grid 2) 54 | (mapcat (partial map rules)) 55 | (map #(count-at-depth (dec depth) %)) 56 | (reduce +))))) 57 | 58 | ;; part 1 59 | #_(with-redefs [count-at-depth (memoize count-at-depth)] 60 | (time (count-at-depth 5 start-pixels))) 61 | ;; => 139 62 | ;; Elapsed time: 1.537593 msecs 63 | 64 | ;; part 2 65 | #_(with-redefs [count-at-depth (memoize count-at-depth)] 66 | (time (count-at-depth 18 start-pixels))) 67 | ;; => 1857134 68 | ;; Elapsed time: 15.000658 msec 69 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day22.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day22 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def data 7 | (->> (io/resource "2017/day22") 8 | io/reader 9 | line-seq 10 | vec)) 11 | 12 | (def test-data ["..#" "#.." "..."]) 13 | 14 | (defn start-board [data'] 15 | (assert (= (count data') (count (first data')))) 16 | {:board 17 | (into {} 18 | (for [y (range (count data')) 19 | x (range (count data'))] 20 | [[y x] (str (get-in data' [y x]))])) 21 | ;; initial position center 22 | :position 23 | (let [x (int (/ (count data') 2))] 24 | [x x]) 25 | ;; initial direction up 26 | :direction 0}) 27 | 28 | (def directions [[-1 0] [0 1] [1 0] [0 -1]]) 29 | 30 | (def turn-right (comp #(mod % 4) inc)) 31 | (def turn-left (comp #(mod % 4) dec)) 32 | 33 | (defn turn [{:keys [board position] :as state}] 34 | (->> (if (= "#" (get board position)) turn-right turn-left) 35 | (update state :direction))) 36 | 37 | (defn infect-node [{:keys [board position] :as state}] 38 | (if (= "#" (get board position)) 39 | (update state :board assoc position ".") 40 | (-> state 41 | (update :board assoc position "#") 42 | (update :infect-count (fnil inc 0))))) 43 | 44 | (defn move-forward [{:keys [direction] :as state}] 45 | (update state :position #(mapv + % (get directions direction)))) 46 | 47 | ;; we really have to render the board to verify that the state machine is working 48 | (defn render-board [{:keys [board position]}] 49 | (let [min-coord (apply min (flatten (cons position (keys board)))) 50 | max-coord (apply max (flatten (cons position (keys board))))] 51 | (->> (for [y (range min-coord (inc max-coord)) 52 | x (range min-coord (inc max-coord))] 53 | [y x]) 54 | (map #(if (= % position) 55 | (str "[" (board % ".") "]") 56 | (str " " (board % ".") " "))) 57 | (partition (- (inc max-coord) min-coord)) 58 | (map #(apply str %)) 59 | (mapv println)) 60 | nil)) 61 | 62 | ;; verify that everything looks right 63 | #_(render-board (nth (iterate (comp move-forward infect-node turn) (start-board test-data)) 7)) 64 | 65 | ;; part 1 66 | #_ (time (-> (iterate (comp move-forward infect-node turn) (start-board data)) 67 | (nth 10000) 68 | :infect-count)) 69 | ;; 5240 70 | ;; Elapsed time: 41.665846 msecs 71 | 72 | ;; well ... we have a whole new state machine for part 2 woohoo! 73 | 74 | (def state-transition 75 | {nil "W" 76 | "." "W" 77 | "W" "#" 78 | "#" "F" 79 | "F" "."}) 80 | 81 | (defn turn-2 [{:keys [board position] :as state}] 82 | (condp = (get board position ".") 83 | "." (update state :direction turn-left) 84 | "#" (update state :direction turn-right) 85 | "W" state 86 | "F" (update state :direction (comp turn-right turn-right)))) 87 | 88 | (defn update-node [{:keys [board position] :as state}] 89 | (cond-> state 90 | (= "W" (board position)) (update :infect-count (fnil inc 0)) 91 | :else (update-in [:board position] state-transition))) 92 | 93 | ;; render the board 94 | #_(render-board (nth (iterate (comp move-forward update-node turn-2) (start-board test-data)) 5)) 95 | 96 | ;; part 2 97 | #_(time (-> (iterate (comp move-forward update-node turn-2) (start-board start-data)) 98 | (nth n) 99 | :infect-count)) 100 | ;; => 2512144 101 | ;; Elapsed time: 45868.547871 msecs 102 | 103 | 104 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day23.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day23 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def program 7 | (->> (io/resource "2017/day23") 8 | io/reader 9 | line-seq 10 | (map #(format "[%s]" %)) 11 | (mapv read-string))) 12 | 13 | ;; make sure that there are no errant registers 14 | (assert (= (set (filter symbol? (flatten (map rest program)))) 15 | '#{a b c d e f g h})) 16 | 17 | (defmulti instruct (fn [_ [cmd]] cmd)) 18 | 19 | (defn inc-program-counter [state] 20 | (update state :program-counter inc)) 21 | 22 | (defn reg-or-val [state Y] 23 | (if (number? Y) Y (get state Y 0))) 24 | 25 | (defmethod instruct 'set [state [_ X Y]] 26 | (inc-program-counter 27 | (assoc state X (reg-or-val state Y)))) 28 | 29 | (defmethod instruct 'sub [state [_ X Y]] 30 | (inc-program-counter 31 | (update state X (fnil - 0) (reg-or-val state Y)))) 32 | 33 | (defmethod instruct 'mul [state [_ X Y]] 34 | (-> state 35 | (update X (fnil * 0) (reg-or-val state Y)) 36 | (update :mul-counter (fnil inc 0)) 37 | inc-program-counter)) 38 | 39 | (defmethod instruct 'jnz [state [_ X Y]] 40 | (if (not= ^long (reg-or-val state X) 0) 41 | (update state :program-counter + (reg-or-val state Y)) 42 | (inc-program-counter state))) 43 | 44 | (defn transition [{:keys [program-counter program] :as state}] 45 | (when-let [instruction (get program program-counter)] 46 | (assoc (instruct state instruction) 47 | :inst instruction))) 48 | 49 | ;; part 1 50 | #_(->> (iterate transition {:program-counter 0 51 | :program program}) 52 | (take-while identity) 53 | (map :inst) 54 | (filter #(= 'mul (first %))) 55 | count 56 | time) 57 | ;; => 4225 58 | ;; Elapsed time: 74.587177 msecs 59 | 60 | 61 | ;; program analysis 62 | 63 | (def program-2 64 | '[[set b 67] 65 | [set c b] 66 | [jnz a 2] 67 | [jnz 1 5] 68 | [mul b 100] 69 | [sub b -100000] 70 | [set c b] 71 | [sub c -17000] 72 | ;; outer loop 73 | [set f 1] 74 | [set d 2] 75 | ;; second loop over values for d from 2 => b 76 | [set e 2] 77 | ;; inner loop over values for e from 2 => b 78 | [set g d] 79 | [mul g e] 80 | [sub g b] ;; g = (- (* d e) b) 81 | [jnz g 2] 82 | [set f 0] ;; f = 0 when b is divisible by e 83 | [sub e -1] ;; inc e 84 | [set g e] 85 | [sub g b] ;; g = (- e b) 86 | [jnz g -8] ;; jmp inner loop (exit when e == b) 87 | [sub d -1] ;; inc d 88 | [set g d] 89 | [sub g b] ;; g = (- d b) 90 | [jnz g -13] ;; jmp second loop (exit when d == b) 91 | ;; constants 92 | ;; g = 0, 93 | ;; d = 2, 94 | ;; c = 123700 95 | ;; at end of second loop these are our values 96 | 97 | ;; variables 98 | ;; b = 106700 increases by 17 every outer loop 99 | ;; so outer loop has to run 1000 times 100 | 101 | ;; f is only 0 when b has an integer divisor 102 | ;; h increments when f is 0 103 | [jnz f 2] 104 | [sub h -1] ;; inc h 105 | [set g b] 106 | [sub g c] ;; (- b c) 107 | [jnz g 2] ;; true until (= b c) or until this runs 1000 times 108 | [jnz 1 3] 109 | [sub b -17] ;; b changes by + 17 110 | [jnz 1 -23]]) ;; jmp outer loop 111 | 112 | ;; Analysis Conclusion 113 | 114 | ;; this program counts numbers that are not prime over the range 115 | ;; from b to c stepping by 17 116 | 117 | (defn not-prime? [n] 118 | (some #(= 0 (mod n %)) (range 2 n))) 119 | 120 | ;; part 2 121 | (->> (filter not-prime? (range 106700 (inc 123700) 17)) 122 | count 123 | time) 124 | ;; => 905 125 | ;; Elapsed time: 1752.15433 msecs 126 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day24.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day24 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (def data 7 | (->> (io/resource "2017/day24") 8 | slurp)) 9 | 10 | (defn make-index [raw-data] 11 | (->> (string/split-lines raw-data) 12 | (map #(string/replace % "/" " ")) 13 | (map #(format "[%s]" %)) 14 | (mapv read-string) 15 | (reduce (fn [accum [h t :as part]] 16 | (-> accum 17 | (update h (fnil conj #{}) part) 18 | (update t (fnil conj #{}) part))) 19 | {}))) 20 | 21 | ;; an indexed version of the data for constant time look ups 22 | (def index (make-index data)) 23 | 24 | (defn remove-part [parts-index [h t :as part]] 25 | (-> parts-index 26 | (update h disj part) 27 | (update t disj part))) 28 | 29 | (defn strength [parts] 30 | (reduce + 0 (flatten parts))) 31 | 32 | (defn other-member [h? [h t]] 33 | (if (= h? h) t h)) 34 | 35 | ;; ignores partial briges as they don't matter for solution 36 | (defn all-bridges [parts-index main-part tail-part] 37 | (if (empty? (parts-index tail-part)) 38 | [[main-part]] 39 | (->> (parts-index tail-part) 40 | (mapcat #(all-bridges (remove-part parts-index %) % (other-member tail-part %))) 41 | (mapv #(cons main-part %))))) 42 | 43 | ;; part 1 44 | #_(with-redefs [all-bridges (memoize all-bridges)] 45 | (time (->> (all-bridges index [0 0] 0) 46 | (map strength) 47 | (reduce max)))) 48 | ;; => 1906 49 | ;; Elapsed time: 21145.979859 msecs 50 | 51 | ;; part 2 52 | #_(with-redefs [all-bridges (memoize all-bridges)] 53 | (time 54 | (let [bridges (all-bridges index [0 0] 0) 55 | max-length (reduce max (map count bridges))] 56 | (->> bridges 57 | (filter #(= (count %) max-length)) 58 | (map strength) 59 | (reduce max))))) 60 | ;; => 1824 61 | ;; Elapsed time: 3697.887612 msec 62 | 63 | 64 | 65 | ;; A tree-seq based solution 66 | ;; it collects the needed totals as it travels 67 | 68 | (defn branch? [[parts-index available-pin strength-total length]] 69 | (parts-index available-pin)) 70 | 71 | (defn children [[parts-index available-pin strength-total length]] 72 | (when-let [childs (parts-index available-pin)] 73 | (map 74 | (fn [next-part] 75 | [(remove-part parts-index next-part) 76 | (other-member available-pin next-part) 77 | (+ strength-total (apply + next-part)) 78 | (inc length)]) 79 | childs))) 80 | 81 | ;; part 1 82 | #_(->> (tree-seq branch? children [index 0 0 0]) 83 | (map #(nth % 2)) 84 | (reduce max) 85 | time) 86 | ;; => 1906 87 | ;; Elapsed time: 4472.040553 msecs 88 | 89 | ;; part 2 90 | #_(time 91 | (let [bridges (tree-seq branch? children [index 0 0 0]) 92 | max-length (reduce max (map last bridges))] 93 | (->> bridges 94 | (filter #(= (last %) max-length)) 95 | (map #(nth % 3)) 96 | (reduce max)))) 97 | ;; => 1824 98 | ;; Elapsed time: 6435.686022 msecs 99 | 100 | -------------------------------------------------------------------------------- /src/advent_of_clojure_2017/day25.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2017.day25 2 | (:require 3 | [clojure.java.io :as io] 4 | [clojure.string :as string])) 5 | 6 | (defn parse-state-program [state-program] 7 | (mapv (comp 8 | read-string 9 | #(subs % 0 (dec (count %))) 10 | last 11 | #(string/split % #"\s")) 12 | state-program)) 13 | 14 | (def tape-program 15 | (->> (io/resource "2017/day25") 16 | io/reader 17 | line-seq 18 | (drop 2) 19 | (partition 10) 20 | (map rest) 21 | (map parse-state-program))) 22 | 23 | (defn options->machine [machine [state current write direction next-state]] 24 | (assoc-in machine [state current] [write direction next-state])) 25 | 26 | (defn program->state-machine [machine [state & args]] 27 | (reduce options->machine machine (map #(cons state %) (partition 4 args)))) 28 | 29 | (def state-machine (reduce program->state-machine {} tape-program)) 30 | 31 | (defn transition [state-machine [state ^long position tape]] 32 | (let [[write direction next-state] (get-in state-machine [state (get tape position 0)])] 33 | [next-state 34 | ((if (= 'right direction) inc dec) position) 35 | (assoc tape position write)])) 36 | 37 | #_(->> (nth (iterate (partial transition state-machine) ['A 0 {}]) 38 | 12368930) 39 | last 40 | vals 41 | (reduce +) 42 | time) 43 | ;; => 2725 44 | ;; Elapsed time: 14319.600632 msecs 45 | -------------------------------------------------------------------------------- /test/advent_of_clojure_2016/core_test.clj: -------------------------------------------------------------------------------- 1 | (ns advent-of-clojure-2016.core-test 2 | (:require [clojure.test :refer :all] 3 | [advent-of-clojure-2016.core :refer :all])) 4 | 5 | (deftest a-test 6 | (testing "FIXME, I fail." 7 | (is (= 0 1)))) 8 | --------------------------------------------------------------------------------