diff --git a/.aocf/cache/aoc2023_18.json b/.aocf/cache/aoc2023_18.json index f5d88d9..60af63e 100644 --- a/.aocf/cache/aoc2023_18.json +++ b/.aocf/cache/aoc2023_18.json @@ -3,12 +3,14 @@ "day": 18, "level": "second", "title": "Lavaduct Lagoon", - "stars": 1, + "stars": 2, "solution": { - "first": "48652" + "first": "48652", + "second": "45757884535661" }, "input": "L 4 (#248a72)\nU 3 (#295c13)\nL 4 (#49e802)\nU 5 (#5ff8b3)\nR 3 (#0df642)\nU 2 (#15b973)\nR 5 (#6cfb92)\nU 11 (#4e3cd3)\nL 4 (#422dd0)\nD 5 (#303fe3)\nL 7 (#6225e0)\nD 2 (#58bd63)\nL 9 (#6225e2)\nD 8 (#2b1703)\nL 6 (#422dd2)\nD 9 (#2eb9b3)\nL 2 (#10f270)\nD 10 (#0677b3)\nL 4 (#190450)\nU 11 (#55b4e3)\nL 4 (#361732)\nU 3 (#034663)\nL 4 (#37f902)\nU 6 (#19bb73)\nR 8 (#6e1030)\nU 8 (#4cad93)\nL 4 (#2509d0)\nU 6 (#1e1e61)\nL 5 (#3d3b90)\nU 8 (#28ec81)\nL 2 (#3f9200)\nU 5 (#437871)\nL 6 (#174bc0)\nD 5 (#3b58a1)\nL 11 (#064a60)\nU 5 (#539da3)\nL 4 (#1ea0d0)\nD 7 (#1909b3)\nL 2 (#296a52)\nD 9 (#6780c3)\nL 3 (#296a50)\nU 11 (#356893)\nL 2 (#0eb430)\nU 5 (#019203)\nL 5 (#4eea10)\nU 4 (#436533)\nL 4 (#20aeb0)\nU 4 (#2fb883)\nL 6 (#5046c0)\nU 11 (#392293)\nR 8 (#2567a0)\nU 3 (#57ee03)\nR 12 (#270540)\nU 2 (#358173)\nR 6 (#289e40)\nU 2 (#77b991)\nR 4 (#016c10)\nU 11 (#351091)\nR 2 (#714f90)\nU 6 (#4add71)\nL 11 (#00eab0)\nD 5 (#2f8361)\nL 8 (#192200)\nU 5 (#1416c1)\nL 13 (#775d30)\nU 3 (#3d3d63)\nL 8 (#6e4710)\nU 3 (#28cfd3)\nL 8 (#389880)\nU 5 (#28cfd1)\nL 7 (#4cd750)\nD 5 (#1d56e3)\nL 3 (#2789e2)\nD 5 (#5d7573)\nR 9 (#1b1372)\nD 5 (#1965a3)\nR 4 (#111052)\nD 2 (#5a2861)\nR 10 (#37f1c2)\nD 3 (#0b7ad1)\nR 5 (#012162)\nU 5 (#226f43)\nR 4 (#583cd2)\nD 5 (#4333f3)\nR 5 (#0eb952)\nD 3 (#22a273)\nL 2 (#34c5d0)\nD 3 (#355f11)\nL 5 (#13a460)\nD 4 (#355f13)\nL 6 (#3e2900)\nU 4 (#28d423)\nL 8 (#042432)\nD 3 (#4378f3)\nL 6 (#18a200)\nD 5 (#16a843)\nL 5 (#18a202)\nD 7 (#46fdd3)\nL 5 (#2a4802)\nD 5 (#2a4d23)\nL 5 (#6049d2)\nD 4 (#0a4023)\nL 4 (#09afb2)\nU 4 (#687713)\nL 5 (#4b85f2)\nD 4 (#0e1a53)\nL 8 (#331b60)\nU 6 (#270d83)\nL 6 (#331b62)\nU 6 (#25dba3)\nL 6 (#412e82)\nD 6 (#5e2e73)\nL 8 (#1de802)\nU 6 (#1e7143)\nL 4 (#4e7e82)\nU 3 (#160d63)\nL 5 (#19d230)\nU 3 (#36a4a3)\nR 3 (#19d232)\nU 6 (#4c63b3)\nR 10 (#0d2862)\nU 5 (#0ec351)\nR 11 (#593c62)\nU 6 (#12de21)\nR 2 (#08d482)\nU 4 (#277081)\nR 3 (#10eee0)\nU 4 (#382b91)\nL 4 (#512200)\nU 7 (#1279f1)\nL 3 (#229312)\nU 6 (#422721)\nR 6 (#71ddd2)\nU 6 (#093871)\nR 13 (#0d5622)\nD 5 (#093873)\nR 7 (#4c34e2)\nU 6 (#5b1743)\nR 2 (#4779a2)\nD 6 (#1cc6e3)\nR 7 (#3c13a0)\nU 5 (#3b60f3)\nR 4 (#3c13a2)\nU 9 (#229f83)\nR 3 (#0a6ff2)\nD 2 (#06d231)\nR 8 (#0298b2)\nD 11 (#4eb6a1)\nR 7 (#0298b0)\nU 8 (#438ce1)\nR 7 (#0e69e2)\nU 5 (#2d3e73)\nR 8 (#40b2c2)\nU 6 (#64cb53)\nL 2 (#40b2c0)\nU 3 (#0215c3)\nL 3 (#2cbf42)\nU 4 (#00c523)\nL 7 (#1fc3d2)\nD 4 (#68a633)\nL 5 (#1fc3d0)\nU 5 (#149853)\nL 5 (#2cbf40)\nU 9 (#0b9613)\nL 3 (#1e7f00)\nU 8 (#2fc533)\nL 7 (#3d7180)\nU 3 (#33f3a3)\nR 9 (#66d340)\nU 2 (#0fa1f1)\nR 4 (#0546c0)\nD 6 (#4c00b3)\nR 8 (#483b50)\nU 6 (#4c00b1)\nR 4 (#2fc7c0)\nU 2 (#0fa1f3)\nR 7 (#377280)\nU 6 (#200c43)\nR 5 (#429ef0)\nU 3 (#3a90f1)\nR 5 (#226142)\nU 4 (#2740c1)\nR 5 (#41ac62)\nU 3 (#275423)\nR 2 (#3ba072)\nU 11 (#275421)\nR 4 (#27ea92)\nD 8 (#402001)\nR 2 (#3456c0)\nD 6 (#5a4541)\nR 3 (#4d1400)\nU 4 (#5a4543)\nR 6 (#462de0)\nU 8 (#3fcdb1)\nR 6 (#1f2d90)\nU 6 (#4e7851)\nR 3 (#41eb30)\nD 6 (#4e7853)\nR 4 (#1aa1c0)\nD 10 (#0a4073)\nR 6 (#2134b2)\nD 7 (#164e43)\nR 4 (#200c72)\nD 5 (#3beca3)\nR 6 (#7445e0)\nU 3 (#2cda83)\nR 4 (#7445e2)\nU 3 (#475553)\nL 5 (#200c70)\nU 10 (#23fb33)\nR 5 (#2134b0)\nU 7 (#3c98d3)\nL 4 (#4cfc80)\nU 5 (#0f0e71)\nR 8 (#3c1d22)\nU 10 (#23a311)\nR 6 (#05da32)\nD 5 (#6229c1)\nR 5 (#41f750)\nD 8 (#1f4191)\nR 3 (#3530f0)\nD 13 (#4d3941)\nR 3 (#6215e0)\nD 9 (#2fe911)\nR 6 (#05cf90)\nU 4 (#25c901)\nR 2 (#335232)\nU 12 (#271371)\nR 2 (#335230)\nU 5 (#2bd1d1)\nL 9 (#1ffad0)\nU 6 (#6f6bc1)\nR 9 (#099600)\nU 5 (#13bee1)\nR 3 (#5aa820)\nU 3 (#3546c1)\nR 6 (#4dd5f0)\nD 11 (#495be1)\nR 6 (#60c8e0)\nU 11 (#4bd201)\nR 4 (#367f30)\nD 4 (#43dbc1)\nR 6 (#4bb740)\nU 12 (#07ce11)\nR 6 (#4b4d70)\nD 12 (#3e29e1)\nR 5 (#313fc0)\nU 4 (#293d51)\nR 4 (#1b4860)\nU 11 (#514571)\nR 4 (#5c11a2)\nU 4 (#444841)\nR 8 (#5c11a0)\nU 2 (#3e6c51)\nR 11 (#16dab0)\nU 7 (#26baf1)\nR 2 (#32e240)\nU 5 (#26baf3)\nR 6 (#2f0a70)\nU 6 (#11a821)\nR 3 (#527fc0)\nU 7 (#468b31)\nR 6 (#0641a0)\nU 10 (#20f351)\nR 7 (#547a90)\nU 12 (#1dbf11)\nR 2 (#17d0d2)\nU 10 (#159981)\nR 6 (#634e12)\nU 5 (#4ff021)\nR 10 (#006122)\nD 6 (#6589a3)\nR 3 (#1a74f2)\nD 2 (#19b911)\nR 12 (#3ed5f2)\nD 5 (#28ab31)\nR 3 (#09dd82)\nD 5 (#614c01)\nR 6 (#284d32)\nD 9 (#06b521)\nR 8 (#4dfad2)\nD 7 (#5b0f61)\nR 2 (#0fff22)\nD 5 (#1e6ff1)\nR 2 (#47b352)\nD 9 (#29c291)\nR 5 (#352ef2)\nD 3 (#042d11)\nR 4 (#262542)\nD 7 (#042d13)\nR 4 (#21e8f2)\nD 3 (#18cc21)\nR 3 (#16ed70)\nU 9 (#270ea1)\nR 7 (#4391e0)\nU 9 (#270ea3)\nR 4 (#22bdd0)\nD 3 (#3b72b1)\nR 7 (#1fd4b2)\nD 8 (#01bfe1)\nL 7 (#3d18a2)\nD 7 (#20dac1)\nR 4 (#67d990)\nD 4 (#1acd93)\nL 7 (#017410)\nD 2 (#6e4923)\nL 7 (#10bdd0)\nD 13 (#0650b3)\nL 2 (#072660)\nU 13 (#221151)\nL 6 (#41d720)\nD 3 (#5bc831)\nL 4 (#252450)\nD 9 (#118de1)\nR 6 (#05b1d0)\nD 4 (#247721)\nR 9 (#2b6b10)\nU 4 (#60da41)\nR 10 (#470c42)\nD 3 (#4fdc91)\nR 2 (#470c40)\nD 8 (#189db1)\nL 5 (#4a1f70)\nD 7 (#07e141)\nL 3 (#2524b0)\nD 5 (#2a6ce1)\nL 11 (#1a2e50)\nD 2 (#4f08c1)\nL 3 (#3b7ec0)\nD 9 (#65e011)\nL 8 (#24b9a0)\nD 6 (#196c61)\nL 5 (#540b20)\nD 6 (#243801)\nL 2 (#397ce0)\nD 3 (#411a41)\nL 12 (#397ce2)\nD 2 (#526d51)\nL 2 (#5b5810)\nD 5 (#2e96d3)\nL 8 (#6c4f80)\nU 6 (#274453)\nL 3 (#077010)\nU 5 (#37f603)\nR 5 (#73bf92)\nU 4 (#29ee73)\nR 11 (#5ffd40)\nU 5 (#3e12d3)\nL 4 (#4b4e32)\nU 12 (#114e01)\nL 2 (#45d0b2)\nU 4 (#114e03)\nL 6 (#4b8b02)\nU 9 (#3eff03)\nL 4 (#6968d0)\nU 4 (#3d4d33)\nL 6 (#1dd0e0)\nD 2 (#436023)\nL 9 (#58b812)\nD 6 (#423003)\nL 7 (#2e81a2)\nD 3 (#3d9e13)\nL 11 (#305450)\nD 6 (#2667f3)\nL 7 (#3a8470)\nD 8 (#293191)\nR 3 (#207ee0)\nD 4 (#293193)\nR 3 (#2c4360)\nD 4 (#2667f1)\nR 7 (#250ee0)\nU 4 (#70e1c3)\nR 4 (#2907d0)\nD 6 (#0b69a1)\nR 6 (#3babc0)\nD 6 (#7698c3)\nR 2 (#2752c0)\nD 3 (#7698c1)\nL 4 (#2dc550)\nD 11 (#4ec121)\nL 8 (#199d00)\nU 11 (#33f261)\nL 7 (#3b4e30)\nD 5 (#24e991)\nL 6 (#0aaeb2)\nU 9 (#15a993)\nL 5 (#59ed02)\nU 2 (#15a991)\nL 5 (#2c0432)\nU 10 (#337e81)\nL 7 (#248670)\nD 2 (#511d31)\nL 3 (#52ebc0)\nD 13 (#511d33)\nL 4 (#192db0)\nD 7 (#3dcf11)\nL 2 (#285030)\nD 3 (#15acc1)\nL 6 (#3a6c70)\nD 5 (#36f281)\nL 4 (#44fd02)\nU 5 (#4e8821)\nL 4 (#473972)\nU 5 (#2ab9f1)\nL 8 (#60aaa0)\nU 5 (#35c651)\nL 3 (#4736b2)\nU 10 (#4741d1)\nL 3 (#1973f2)\nU 5 (#1b5031)\nL 3 (#3c6532)\nD 5 (#49bd31)\nL 4 (#5e3f60)\nD 3 (#4a2011)\nL 4 (#2ba190)\nD 6 (#4a2013)\nL 3 (#653430)\nD 7 (#10dda1)\nL 11 (#2532d2)\nD 3 (#675311)\nL 4 (#27d642)\nD 6 (#02cae1)\nL 10 (#466652)\nD 7 (#34cef3)\nR 3 (#263692)\nD 7 (#34cef1)\nR 8 (#2c59d2)\nD 5 (#31afe1)\nL 8 (#091562)\nD 5 (#12c861)\nR 4 (#47a772)\nD 5 (#68a5b1)\nL 7 (#1f79a2)\nD 4 (#3b3c13)\nR 10 (#0e7122)\nD 4 (#087363)\nR 4 (#3e26c2)\nU 13 (#4953f3)\nR 3 (#5ac862)\nU 3 (#4953f1)\nR 3 (#13cfe2)\nD 5 (#087361)\nR 11 (#57f7a2)\nD 4 (#3b3c11)\nL 11 (#6dcb32)\nD 7 (#35e653)\nR 6 (#525282)\nD 5 (#3dac93)\nR 9 (#377082)\nD 6 (#2afda1)\nR 10 (#3e6422)\nD 10 (#220471)\nR 10 (#37ebf2)\nD 2 (#4d0213)\nR 5 (#2fa2f2)\nD 4 (#30df53)\nR 5 (#617e00)\nU 6 (#536393)\nR 5 (#496510)\nD 6 (#5f6733)\nR 4 (#3bf9b0)\nD 3 (#5f6731)\nR 4 (#48d940)\nD 3 (#35a5d3)\nR 4 (#284a82)\nD 9 (#445b23)\nL 4 (#2535c2)\nD 4 (#3f8b43)\nR 2 (#41a002)\nD 7 (#20b143)\nR 3 (#63ae42)\nU 8 (#328b03)\nR 9 (#383210)\nU 3 (#1ce143)\nR 7 (#383212)\nU 6 (#2ed603)\nR 5 (#00c512)\nU 6 (#6dea43)\nR 6 (#00c510)\nU 7 (#0f0643)\nR 3 (#4292a2)\nU 7 (#684961)\nR 3 (#03de80)\nU 5 (#46e0b1)\nR 6 (#3d4ae2)\nD 5 (#1d5fc1)\nR 7 (#3d4ae0)\nU 13 (#470ab1)\nR 5 (#03de82)\nU 4 (#282c71)\nR 6 (#5520f2)\nD 5 (#2f0981)\nR 2 (#5520f0)\nD 12 (#4081a1)\nR 6 (#22a272)\nU 5 (#284c53)\nR 8 (#081202)\nD 5 (#0b7831)\nR 4 (#3e4552)\nD 13 (#0b7833)\nR 5 (#38e092)\nU 11 (#284c51)\nR 2 (#550082)\nU 2 (#175033)\nR 6 (#036dc2)\nD 3 (#068791)\nR 9 (#3ff6f2)\nD 5 (#4a5783)\nR 13 (#4d5f92)\nD 6 (#3e3423)\nL 12 (#4f62d2)\nD 7 (#5e4363)\nL 3 (#0f7032)\nU 7 (#285261)\nL 12 (#4ea392)\nD 5 (#4c2dc1)\nL 4 (#0d2822)\nD 5 (#4c2dc3)\nR 9 (#518da2)\nD 2 (#41b3b1)\nR 7 (#023270)\nD 3 (#13d6e1)\nR 11 (#0874c0)\nD 3 (#2026c1)\nR 4 (#68f3a0)\nD 7 (#2026c3)\nL 8 (#208470)\nD 4 (#09bd81)\nL 3 (#193a10)\nD 7 (#5f3491)\nL 4 (#08cad2)\nD 10 (#068793)\nL 10 (#48acb2)\nD 4 (#20e341)\nL 7 (#6137a2)\nD 8 (#20e343)\nL 7 (#0bf292)\nD 7 (#5b5f13)\nL 8 (#2b2532)\nD 3 (#034073)\nL 5 (#3c7bb2)\nD 11 (#09c643)\nL 3 (#0d6e52)\nU 3 (#569d23)\nL 5 (#63fed0)\nU 4 (#162193)\nL 4 (#2eb310)\nU 3 (#655e23)\nL 10 (#42f8e0)\nU 4 (#341983)\nR 14 (#3dbbc0)\nU 5 (#551b13)\nL 5 (#2a94f0)\nU 6 (#05ae53)\nL 2 (#09db90)\nU 5 (#2c9e13)\nL 8 (#4c6d10)\nD 10 (#40ffb3)\nL 3 (#306c30)\nD 2 (#338911)\nL 6 (#4bed00)\nD 7 (#338913)\nR 7 (#12aae0)\nD 4 (#459613)\nL 7 (#75d3a2)\nD 7 (#37ad61)\nL 6 (#6dcf92)\nD 4 (#3b7703)\nR 9 (#0ee2b2)\nD 4 (#514c13)\nR 6 (#0ee2b0)\nD 3 (#2863b3)\nL 8 (#52eee2)\nD 8 (#2fc771)\nL 7 (#5be782)\nD 4 (#2f39a1)\nL 6 (#5be780)\nU 4 (#5625b1)\nL 2 (#5588c2)\nU 14 (#37ad63)\nL 3 (#0681e2)\nU 4 (#085481)\nL 3 (#037432)\nU 12 (#31ed51)\nL 4 (#6791e2)\nD 5 (#3546d3)\nL 6 (#4419e2)\nD 10 (#3546d1)\nL 4 (#2c1a72)\nD 10 (#5bead1)\nL 3 (#3b3252)\nD 9 (#3390c1)\nL 3 (#1d78c2)\nD 5 (#488d71)\nR 10 (#244042)\nD 2 (#10d1e1)\nR 5 (#3fd582)\nD 5 (#5025a1)\nL 3 (#381b70)\nD 11 (#771831)\nL 7 (#2abf50)\nU 11 (#17be81)\nL 5 (#1eb3c0)\nD 5 (#3d9c61)\nL 5 (#5f4de2)\nD 8 (#278361)\nL 2 (#2b95b2)\nD 9 (#2cb0b1)\nL 4 (#4a0182)\nD 6 (#2c6bb3)\nL 2 (#499642)\nD 5 (#4c76d3)\nL 8 (#2fe412)\nU 9 (#07b893)\nL 2 (#236d52)\nU 8 (#3956a3)\nL 7 (#34f252)\nU 3 (#52bbf1)\nL 7 (#189470)\nU 4 (#54b661)\nL 9 (#189472)\nU 7 (#0110f1)\nL 3 (#409bf2)\nU 3 (#46d3e3)\nL 5 (#4c0f82)\nU 11 (#215e73)\nL 4 (#4c0f80)\nU 7 (#4050f3)\nL 9 (#39b192)\nU 7 (#28b043)\nL 3 (#011270)\nU 7 (#1f6693)\nR 7 (#73c390)\nU 2 (#2c4113)\nR 5 (#0321c0)\nU 8 (#2f2903)\nL 12 (#5ab560)\nU 3 (#4dd983)\nL 6 (#38b7d2)\nU 12 (#03c8c3)\n", "brief": { - "first": "Thanks to your efforts, the machine parts factory is one of the first factories up and running since the lavafall came back. However, to catch up with the large backlog of parts requests, the factory will also need a *large supply of lava* for a while; the Elves have already started creating a large lagoon nearby for this purpose.\n\nHowever, they aren't sure the lagoon will be big enough; they've asked you to take a look at the *dig plan* (your puzzle input). For example:\n\n```\nR 6 (#70c710)\nD 5 (#0dc571)\nL 2 (#5713f0)\nD 2 (#d2c081)\nR 2 (#59c680)\nD 2 (#411b91)\nL 5 (#8ceee2)\nU 2 (#caa173)\nL 1 (#1b58a2)\nU 2 (#caa171)\nR 2 (#7807d2)\nU 3 (#a77fa3)\nL 2 (#015232)\nU 2 (#7a21e3)\n\n```\n\nThe digger starts in a 1 meter cube hole in the ground. They then dig the specified number of meters *up* (`U`), *down* (`D`), *left* (`L`), or *right* (`R`), clearing full 1 meter cubes as they go. The directions are given as seen from above, so if \"up\" were north, then \"right\" would be east, and so on. Each trench is also listed with *the color that the edge of the trench should be painted* as an [RGB hexadecimal color code](https://en.wikipedia.org/wiki/RGB_color_model#Numeric_representations).\n\nWhen viewed from above, the above example dig plan would result in the following loop of *trench* (`#`) having been dug out from otherwise *ground-level terrain* (`.`):\n\n```\n#######\n#.....#\n###...#\n..#...#\n..#...#\n###.###\n#...#..\n##..###\n.#....#\n.######\n\n```\n\nAt this point, the trench could contain 38 cubic meters of lava. However, this is just the edge of the lagoon; the next step is to *dig out the interior* so that it is one meter deep as well:\n\n```\n#######\n#######\n#######\n..#####\n..#####\n#######\n#####..\n#######\n.######\n.######\n\n```\n\nNow, the lagoon can contain a much more respectable `*62*` cubic meters of lava. While the interior is dug out, the edges are also painted according to the color codes in the dig plan.\n\nThe Elves are concerned the lagoon won't be large enough; if they follow their dig plan, *how many cubic meters of lava could it hold?*\n\nYour puzzle answer was `48652`.\n\nThe first half of this puzzle is complete! It provides one gold star: \\*\n\n\\--- Part Two ---\n----------\n\nThe Elves were right to be concerned; the planned lagoon would be *much too small*.\n\nAfter a few minutes, someone realizes what happened; someone *swapped the color and instruction parameters* when producing the dig plan. They don't have time to fix the bug; one of them asks if you can *extract the correct instructions* from the hexadecimal codes.\n\nEach hexadecimal code is *six hexadecimal digits* long. The first five hexadecimal digits encode the *distance in meters* as a five-digit hexadecimal number. The last hexadecimal digit encodes the *direction to dig*: `0` means `R`, `1` means `D`, `2` means `L`, and `3` means `U`.\n\nSo, in the above example, the hexadecimal codes can be converted into the true instructions:\n\n* `#70c710` = `R 461937`\n* `#0dc571` = `D 56407`\n* `#5713f0` = `R 356671`\n* `#d2c081` = `D 863240`\n* `#59c680` = `R 367720`\n* `#411b91` = `D 266681`\n* `#8ceee2` = `L 577262`\n* `#caa173` = `U 829975`\n* `#1b58a2` = `L 112010`\n* `#caa171` = `D 829975`\n* `#7807d2` = `L 491645`\n* `#a77fa3` = `U 686074`\n* `#015232` = `L 5411`\n* `#7a21e3` = `U 500254`\n\nDigging out this loop and its interior produces a lagoon that can hold an impressive `*952408144115*` cubic meters of lava.\n\nConvert the hexadecimal color codes into the correct instructions; if the Elves follow this new dig plan, *how many cubic meters of lava could the lagoon hold?*\n\nAnswer:\n\nAlthough it hasn't changed, you can still [get your puzzle input](18/input)." + "first": "Thanks to your efforts, the machine parts factory is one of the first factories up and running since the lavafall came back. However, to catch up with the large backlog of parts requests, the factory will also need a *large supply of lava* for a while; the Elves have already started creating a large lagoon nearby for this purpose.\n\nHowever, they aren't sure the lagoon will be big enough; they've asked you to take a look at the *dig plan* (your puzzle input). For example:\n\n```\nR 6 (#70c710)\nD 5 (#0dc571)\nL 2 (#5713f0)\nD 2 (#d2c081)\nR 2 (#59c680)\nD 2 (#411b91)\nL 5 (#8ceee2)\nU 2 (#caa173)\nL 1 (#1b58a2)\nU 2 (#caa171)\nR 2 (#7807d2)\nU 3 (#a77fa3)\nL 2 (#015232)\nU 2 (#7a21e3)\n\n```\n\nThe digger starts in a 1 meter cube hole in the ground. They then dig the specified number of meters *up* (`U`), *down* (`D`), *left* (`L`), or *right* (`R`), clearing full 1 meter cubes as they go. The directions are given as seen from above, so if \"up\" were north, then \"right\" would be east, and so on. Each trench is also listed with *the color that the edge of the trench should be painted* as an [RGB hexadecimal color code](https://en.wikipedia.org/wiki/RGB_color_model#Numeric_representations).\n\nWhen viewed from above, the above example dig plan would result in the following loop of *trench* (`#`) having been dug out from otherwise *ground-level terrain* (`.`):\n\n```\n#######\n#.....#\n###...#\n..#...#\n..#...#\n###.###\n#...#..\n##..###\n.#....#\n.######\n\n```\n\nAt this point, the trench could contain 38 cubic meters of lava. However, this is just the edge of the lagoon; the next step is to *dig out the interior* so that it is one meter deep as well:\n\n```\n#######\n#######\n#######\n..#####\n..#####\n#######\n#####..\n#######\n.######\n.######\n\n```\n\nNow, the lagoon can contain a much more respectable `*62*` cubic meters of lava. While the interior is dug out, the edges are also painted according to the color codes in the dig plan.\n\nThe Elves are concerned the lagoon won't be large enough; if they follow their dig plan, *how many cubic meters of lava could it hold?*\n\nYour puzzle answer was `48652`.\n\nThe first half of this puzzle is complete! It provides one gold star: \\*\n\n\\--- Part Two ---\n----------\n\nThe Elves were right to be concerned; the planned lagoon would be *much too small*.\n\nAfter a few minutes, someone realizes what happened; someone *swapped the color and instruction parameters* when producing the dig plan. They don't have time to fix the bug; one of them asks if you can *extract the correct instructions* from the hexadecimal codes.\n\nEach hexadecimal code is *six hexadecimal digits* long. The first five hexadecimal digits encode the *distance in meters* as a five-digit hexadecimal number. The last hexadecimal digit encodes the *direction to dig*: `0` means `R`, `1` means `D`, `2` means `L`, and `3` means `U`.\n\nSo, in the above example, the hexadecimal codes can be converted into the true instructions:\n\n* `#70c710` = `R 461937`\n* `#0dc571` = `D 56407`\n* `#5713f0` = `R 356671`\n* `#d2c081` = `D 863240`\n* `#59c680` = `R 367720`\n* `#411b91` = `D 266681`\n* `#8ceee2` = `L 577262`\n* `#caa173` = `U 829975`\n* `#1b58a2` = `L 112010`\n* `#caa171` = `D 829975`\n* `#7807d2` = `L 491645`\n* `#a77fa3` = `U 686074`\n* `#015232` = `L 5411`\n* `#7a21e3` = `U 500254`\n\nDigging out this loop and its interior produces a lagoon that can hold an impressive `*952408144115*` cubic meters of lava.\n\nConvert the hexadecimal color codes into the correct instructions; if the Elves follow this new dig plan, *how many cubic meters of lava could the lagoon hold?*\n\nAnswer:\n\nAlthough it hasn't changed, you can still [get your puzzle input](18/input).", + "second": "Thanks to your efforts, the machine parts factory is one of the first factories up and running since the lavafall came back. However, to catch up with the large backlog of parts requests, the factory will also need a *large supply of lava* for a while; the Elves have already started creating a large lagoon nearby for this purpose.\n\nHowever, they aren't sure the lagoon will be big enough; they've asked you to take a look at the *dig plan* (your puzzle input). For example:\n\n```\nR 6 (#70c710)\nD 5 (#0dc571)\nL 2 (#5713f0)\nD 2 (#d2c081)\nR 2 (#59c680)\nD 2 (#411b91)\nL 5 (#8ceee2)\nU 2 (#caa173)\nL 1 (#1b58a2)\nU 2 (#caa171)\nR 2 (#7807d2)\nU 3 (#a77fa3)\nL 2 (#015232)\nU 2 (#7a21e3)\n\n```\n\nThe digger starts in a 1 meter cube hole in the ground. They then dig the specified number of meters *up* (`U`), *down* (`D`), *left* (`L`), or *right* (`R`), clearing full 1 meter cubes as they go. The directions are given as seen from above, so if \"up\" were north, then \"right\" would be east, and so on. Each trench is also listed with *the color that the edge of the trench should be painted* as an [RGB hexadecimal color code](https://en.wikipedia.org/wiki/RGB_color_model#Numeric_representations).\n\nWhen viewed from above, the above example dig plan would result in the following loop of *trench* (`#`) having been dug out from otherwise *ground-level terrain* (`.`):\n\n```\n#######\n#.....#\n###...#\n..#...#\n..#...#\n###.###\n#...#..\n##..###\n.#....#\n.######\n\n```\n\nAt this point, the trench could contain 38 cubic meters of lava. However, this is just the edge of the lagoon; the next step is to *dig out the interior* so that it is one meter deep as well:\n\n```\n#######\n#######\n#######\n..#####\n..#####\n#######\n#####..\n#######\n.######\n.######\n\n```\n\nNow, the lagoon can contain a much more respectable `*62*` cubic meters of lava. While the interior is dug out, the edges are also painted according to the color codes in the dig plan.\n\nThe Elves are concerned the lagoon won't be large enough; if they follow their dig plan, *how many cubic meters of lava could it hold?*\n\nYour puzzle answer was `48652`.\n\n\\--- Part Two ---\n----------\n\nThe Elves were right to be concerned; the planned lagoon would be *much too small*.\n\nAfter a few minutes, someone realizes what happened; someone *swapped the color and instruction parameters* when producing the dig plan. They don't have time to fix the bug; one of them asks if you can *extract the correct instructions* from the hexadecimal codes.\n\nEach hexadecimal code is *six hexadecimal digits* long. The first five hexadecimal digits encode the *distance in meters* as a five-digit hexadecimal number. The last hexadecimal digit encodes the *direction to dig*: `0` means `R`, `1` means `D`, `2` means `L`, and `3` means `U`.\n\nSo, in the above example, the hexadecimal codes can be converted into the true instructions:\n\n* `#70c710` = `R 461937`\n* `#0dc571` = `D 56407`\n* `#5713f0` = `R 356671`\n* `#d2c081` = `D 863240`\n* `#59c680` = `R 367720`\n* `#411b91` = `D 266681`\n* `#8ceee2` = `L 577262`\n* `#caa173` = `U 829975`\n* `#1b58a2` = `L 112010`\n* `#caa171` = `D 829975`\n* `#7807d2` = `L 491645`\n* `#a77fa3` = `U 686074`\n* `#015232` = `L 5411`\n* `#7a21e3` = `U 500254`\n\nDigging out this loop and its interior produces a lagoon that can hold an impressive `*952408144115*` cubic meters of lava.\n\nConvert the hexadecimal color codes into the correct instructions; if the Elves follow this new dig plan, *how many cubic meters of lava could the lagoon hold?*\n\nYour puzzle answer was `45757884535661`.\n\nBoth parts of this puzzle are complete! They provide two gold stars: \\*\\*\n\nAt this point, you should [return to your Advent calendar](/2023) and try another puzzle.\n\nIf you still want to see it, you can [get your puzzle input](18/input)." } } \ No newline at end of file diff --git a/src/day18.rs b/src/day18.rs index 448be5b..76117c4 100644 --- a/src/day18.rs +++ b/src/day18.rs @@ -203,7 +203,8 @@ fn main() { let a = polygon.calc_area(); test!(62, a); // Part 1 - let polygon = Polygon::from_dig_plan(&aoc::get(2023, 18), false); + let i = aoc::get(2023, 18); + let polygon = Polygon::from_dig_plan(&i, false); let a = polygon.calc_area(); test!(48652, a); // Part 2 - Example @@ -211,4 +212,8 @@ fn main() { //dbg!(&polygon); let a = polygon.calc_area(); test!(952408144115 as i64, a); + // Part 2 + let polygon = Polygon::from_dig_plan(&i, true); + let a = polygon.calc_area(); + test!(45757884535661 as i64, a); }