this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

2023 day05: start

+370
+9
2023/day05/deno.json
··· 1 + { 2 + "tasks": { 3 + "cache": "deno cache part1.ts part2.ts", 4 + "pull": "aoc --day 5 download --overwrite", 5 + "test": "deno test --watch", 6 + "p1": "deno run -A part1.ts", 7 + "p2": "deno run -A part2.ts" 8 + } 9 + }
+206
2023/day05/input
··· 1 + seeds: 1367444651 99920667 3319921504 153335682 67832336 139859832 2322838536 666063790 1591621692 111959634 442852010 119609663 733590868 56288233 2035874278 85269124 4145746192 55841637 864476811 347179760 2 + 3 + seed-to-soil map: 4 + 873256303 3438158294 3400501 5 + 3338810960 408700040 99469568 6 + 876656804 586381004 55967396 7 + 2937187724 3352513245 85645049 8 + 3633224442 4294716315 250981 9 + 4063203128 3993405594 231764168 10 + 628606346 884567853 85164246 11 + 1848085960 2225191252 328179324 12 + 1686068310 2992301693 162017650 13 + 1456962076 179593806 229106234 14 + 0 1520731987 239660433 15 + 2759350898 1833519805 177836826 16 + 494634602 642348400 67929420 17 + 3022832773 758696310 125871543 18 + 3563677889 4225169762 69546553 19 + 2637775123 710277820 48418490 20 + 3148704316 969732099 112580498 21 + 3261284814 2623022420 77526146 22 + 489910414 174869618 4724188 23 + 1187482559 2700548566 269479517 24 + 713770592 2139594657 85596595 25 + 850982693 2970028083 22273610 26 + 932624200 2013609609 125985048 27 + 799367187 1082312597 51615506 28 + 3633475423 3563677889 429727705 29 + 562564022 3283192654 66042324 30 + 2181319395 2553370576 69651844 31 + 2250971239 1133928103 386803884 32 + 3438280528 3349234978 3278267 33 + 2686193613 513223719 73157285 34 + 239660433 1760392420 73127385 35 + 487657436 2011356631 2252978 36 + 312787818 0 174869618 37 + 1058609248 3154319343 128873311 38 + 2176265284 508169608 5054111 39 + 40 + soil-to-fertilizer map: 41 + 297032819 3559164217 26523093 42 + 323555912 2482284077 316032053 43 + 74171080 3214516077 10202585 44 + 3176226661 2368836568 113447509 45 + 2918425623 1610395638 257801038 46 + 3933490965 2171144546 103908097 47 + 1218064889 55976272 92496985 48 + 2591090931 0 23819721 49 + 1798514394 148473257 159960710 50 + 2288143061 1868196676 302947870 51 + 639587965 3736262447 6060799 52 + 3609511269 699586127 40962058 53 + 1575586870 3249692350 47378699 54 + 1310561874 2798316130 265024996 55 + 3650473327 2308711439 60125129 56 + 1958475104 483393073 178493006 57 + 259332771 661886079 37700048 58 + 907741932 980768687 228854035 59 + 1185908338 23819721 32156551 60 + 3437918904 3874038292 163360770 61 + 645648764 3297071049 262093168 62 + 2648569448 1432515231 29635673 63 + 1647939257 3585687310 150575137 64 + 3710598456 1209622722 222892509 65 + 2678205121 740548185 240220502 66 + 84373665 308433967 174959106 67 + 2614910652 2275052643 33658796 68 + 1622965569 3224718662 24973688 69 + 3289674170 1462150904 148244734 70 + 3601279674 3791635617 8231595 71 + 0 3799867212 74171080 72 + 2136968110 3063341126 151174951 73 + 1136595967 3742323246 49312371 74 + 75 + fertilizer-to-water map: 76 + 0 478733437 191375707 77 + 2494518625 3362803490 180386054 78 + 1605510969 1985802816 27464898 79 + 3545871802 2267467733 385725819 80 + 1580307385 1113809296 8335179 81 + 2267467733 4179194655 34953467 82 + 1588642564 52640953 16868405 83 + 768087626 69509358 314799711 84 + 2835042306 4002148814 177045841 85 + 320920516 1122144475 447167110 86 + 1082887337 670109144 443700152 87 + 3218018460 3543189544 156036618 88 + 1921732119 1569311585 321765324 89 + 1632975867 384309069 40704472 90 + 1526587489 425013541 53719896 91 + 3140697718 2802291105 77320742 92 + 1726321292 1891076909 94725907 93 + 3070918618 2732512005 69779100 94 + 1673680339 0 52640953 95 + 3374055078 3830332090 171816724 96 + 2755723853 2653193552 79318453 97 + 3012088147 3242981522 58830471 98 + 2363412697 3699226162 131105928 99 + 1821047199 2013267714 100684920 100 + 2302421200 3301811993 60991497 101 + 191375707 2113952634 129544809 102 + 3931597621 2879611847 363369675 103 + 2674904679 4214148122 80819174 104 + 105 + water-to-light map: 106 + 3219102205 2181622520 201394006 107 + 920319894 2563844887 124975374 108 + 739491533 2383016526 180828361 109 + 653894144 112244681 85597389 110 + 3420496211 0 112244681 111 + 3657404452 197842070 151065180 112 + 2385949305 1028427888 284402820 113 + 3532740892 1312830708 124663560 114 + 379827855 754361599 274066289 115 + 0 374533744 379827855 116 + 1070921762 1437494268 744128252 117 + 1815050014 3237570341 372982025 118 + 2670352125 2688820261 548750080 119 + 1045295268 348907250 25626494 120 + 2188032039 3610552366 197917266 121 + 122 + light-to-temperature map: 123 + 2153765789 597465407 100160624 124 + 2781845200 2181361650 40610317 125 + 667326513 1345068833 191904517 126 + 2473693610 3180449558 308151590 127 + 3613083869 2293229230 341401182 128 + 1062907936 2938916666 34067323 129 + 1451871003 2221971967 71257263 130 + 3954485051 4137063579 102141117 131 + 4192502901 3838513492 49627103 132 + 1389629967 2876675630 62241036 133 + 1593277643 2972983989 143397067 134 + 859231030 2634630412 203676906 135 + 4056626168 790528713 68145539 136 + 1523128266 2838307318 38368312 137 + 503645468 3488601148 84794865 138 + 1333867367 4239204696 55762600 139 + 2902105909 1961894500 219467150 140 + 3268371481 858674252 266627384 141 + 2253926413 1125301636 219767197 142 + 4124771707 3888140595 67731194 143 + 1159014133 3663660258 174853234 144 + 3121573059 1536973350 56534177 145 + 4242130004 1593507527 52837292 146 + 3534998865 697626031 78085004 147 + 1096975259 503645468 62038874 148 + 588440333 3116381056 64068502 149 + 2052224391 3955871789 101541398 150 + 3178107236 3573396013 90264245 151 + 1736674710 1646344819 315549681 152 + 1561496578 565684342 31781065 153 + 2822455517 4057413187 79650392 154 + 652508835 775711035 14817678 155 + 156 + temperature-to-humidity map: 157 + 539306376 906765326 12587914 158 + 0 164719538 374586838 159 + 3299714596 2417002864 137882274 160 + 3574681727 1862289721 10695948 161 + 1377359247 1111480860 147188226 162 + 2546515862 3738486436 38563842 163 + 2519543212 3564238204 26972650 164 + 1619134727 3777050278 31686173 165 + 551894290 728868054 177897272 166 + 3834998050 3919246788 238635651 167 + 729791562 919353240 625999 168 + 1524547473 3627710187 94587254 169 + 2399595894 3277935618 48769514 170 + 1340859914 3591210854 36499333 171 + 2585079704 2011159197 185411491 172 + 3723551203 3452791357 111446847 173 + 2895131743 2873352765 404582853 174 + 374586838 0 164719538 175 + 1776907125 1258669086 373340162 176 + 2881001532 2859222554 14130211 177 + 2217932998 2606381854 181662896 178 + 2166436282 2554885138 51496716 179 + 2448365408 2788044750 71177804 180 + 1650820900 3326705132 126086225 181 + 1110579441 1632009248 230280473 182 + 3437596870 4157882439 137084857 183 + 730417561 539306376 189561678 184 + 4294065877 1110579441 901419 185 + 2150247287 3722297441 16188995 186 + 2770491195 3808736451 110510337 187 + 3585377675 1872985669 138173528 188 + 4073633701 2196570688 220432176 189 + 190 + humidity-to-location map: 191 + 3656475570 3037182697 7397903 192 + 682722270 547529272 780546181 193 + 266636474 1328075453 316323944 194 + 1591860664 3642496089 50700992 195 + 1642561656 266636474 280892798 196 + 1923454454 1644399397 1264527167 197 + 3979139381 3408096655 6045369 198 + 3663873473 4002979627 291987669 199 + 3955861142 3208017899 23278239 200 + 582960418 3414142024 99761852 201 + 3187981621 3231296138 176800517 202 + 3364782138 3044580600 163437299 203 + 1463268451 3513903876 128592213 204 + 3528219437 2908926564 128256133 205 + 4175159701 3693197081 119807595 206 + 3985184750 3813004676 189974951
+13
2023/day05/part1.ts
··· 1 + if (import.meta.main) { 2 + const input = ( 3 + await Deno.readFile("input").then((bytes) => 4 + new TextDecoder().decode(bytes), 5 + ) 6 + ).trim(); 7 + console.log(answer(input)); 8 + } 9 + 10 + export function answer(input: string): number { 11 + console.log(input); 12 + return 42; 13 + }
+13
2023/day05/part2.ts
··· 1 + if (import.meta.main) { 2 + const input = ( 3 + await Deno.readFile("input").then((bytes) => 4 + new TextDecoder().decode(bytes), 5 + ) 6 + ).trim(); 7 + console.log(answer(input)); 8 + } 9 + 10 + export function answer(input: string): number { 11 + console.log(input); 12 + return 42; 13 + }
+116
2023/day05/puzzle.md
··· 1 + \--- Day 5: If You Give A Seed A Fertilizer --- 2 + ---------- 3 + 4 + You take the boat and find the gardener right where you were told he would be: managing a giant "garden" that looks more to you like a farm. 5 + 6 + "A water source? Island Island *is* the water source!" You point out that Snow Island isn't receiving any water. 7 + 8 + "Oh, we had to stop the water because we *ran out of sand* to [filter](https://en.wikipedia.org/wiki/Sand_filter) it with! Can't make snow with dirty water. Don't worry, I'm sure we'll get more sand soon; we only turned off the water a few days... weeks... oh no." His face sinks into a look of horrified realization. 9 + 10 + "I've been so busy making sure everyone here has food that I completely forgot to check why we stopped getting more sand! There's a ferry leaving soon that is headed over in that direction - it's much faster than your boat. Could you please go check it out?" 11 + 12 + You barely have time to agree to this request when he brings up another. "While you wait for the ferry, maybe you can help us with our *food production problem*. The latest Island Island [Almanac](https://en.wikipedia.org/wiki/Almanac) just arrived and we're having trouble making sense of it." 13 + 14 + The almanac (your puzzle input) lists all of the seeds that need to be planted. It also lists what type of soil to use with each kind of seed, what type of fertilizer to use with each kind of soil, what type of water to use with each kind of fertilizer, and so on. Every type of seed, soil, fertilizer and so on is identified with a number, but numbers are reused by each category - that is, soil `123` and fertilizer `123` aren't necessarily related to each other. 15 + 16 + For example: 17 + 18 + ``` 19 + seeds: 79 14 55 13 20 + 21 + seed-to-soil map: 22 + 50 98 2 23 + 52 50 48 24 + 25 + soil-to-fertilizer map: 26 + 0 15 37 27 + 37 52 2 28 + 39 0 15 29 + 30 + fertilizer-to-water map: 31 + 49 53 8 32 + 0 11 42 33 + 42 0 7 34 + 57 7 4 35 + 36 + water-to-light map: 37 + 88 18 7 38 + 18 25 70 39 + 40 + light-to-temperature map: 41 + 45 77 23 42 + 81 45 19 43 + 68 64 13 44 + 45 + temperature-to-humidity map: 46 + 0 69 1 47 + 1 0 69 48 + 49 + humidity-to-location map: 50 + 60 56 37 51 + 56 93 4 52 + 53 + ``` 54 + 55 + The almanac starts by listing which seeds need to be planted: seeds `79`, `14`, `55`, and `13`. 56 + 57 + The rest of the almanac contains a list of *maps* which describe how to convert numbers from a *source category* into numbers in a *destination category*. That is, the section that starts with `seed-to-soil map:` describes how to convert a *seed number* (the source) to a *soil number* (the destination). This lets the gardener and his team know which soil to use with which seeds, which water to use with which fertilizer, and so on. 58 + 59 + Rather than list every source number and its corresponding destination number one by one, the maps describe entire *ranges* of numbers that can be converted. Each line within a map contains three numbers: the *destination range start*, the *source range start*, and the *range length*. 60 + 61 + Consider again the example `seed-to-soil map`: 62 + 63 + ``` 64 + 50 98 2 65 + 52 50 48 66 + 67 + ``` 68 + 69 + The first line has a *destination range start* of `50`, a *source range start* of `98`, and a *range length* of `2`. This line means that the source range starts at `98` and contains two values: `98` and `99`. The destination range is the same length, but it starts at `50`, so its two values are `50` and `51`. With this information, you know that seed number `98` corresponds to soil number `50` and that seed number `99` corresponds to soil number `51`. 70 + 71 + The second line means that the source range starts at `50` and contains `48` values: `50`, `51`, ..., `96`, `97`. This corresponds to a destination range starting at `52` and also containing `48` values: `52`, `53`, ..., `98`, `99`. So, seed number `53` corresponds to soil number `55`. 72 + 73 + Any source numbers that *aren't mapped* correspond to the *same* destination number. So, seed number `10` corresponds to soil number `10`. 74 + 75 + So, the entire list of seed numbers and their corresponding soil numbers looks like this: 76 + 77 + ``` 78 + seed soil 79 + 0 0 80 + 1 1 81 + ... ... 82 + 48 48 83 + 49 49 84 + 50 52 85 + 51 53 86 + ... ... 87 + 96 98 88 + 97 99 89 + 98 50 90 + 99 51 91 + 92 + ``` 93 + 94 + With this map, you can look up the soil number required for each initial seed number: 95 + 96 + * Seed number `79` corresponds to soil number `81`. 97 + * Seed number `14` corresponds to soil number `14`. 98 + * Seed number `55` corresponds to soil number `57`. 99 + * Seed number `13` corresponds to soil number `13`. 100 + 101 + The gardener and his team want to get started as soon as possible, so they'd like to know the closest location that needs a seed. Using these maps, find *the lowest location number that corresponds to any of the initial seeds*. To do this, you'll need to convert each seed number through other categories until you can find its corresponding *location number*. In this example, the corresponding types are: 102 + 103 + * Seed `79`, soil `81`, fertilizer `81`, water `81`, light `74`, temperature `78`, humidity `78`, *location `82`*. 104 + * Seed `14`, soil `14`, fertilizer `53`, water `49`, light `42`, temperature `42`, humidity `43`, *location `43`*. 105 + * Seed `55`, soil `57`, fertilizer `57`, water `53`, light `46`, temperature `82`, humidity `82`, *location `86`*. 106 + * Seed `13`, soil `13`, fertilizer `52`, water `41`, light `34`, temperature `34`, humidity `35`, *location `35`*. 107 + 108 + So, the lowest location number in this example is `*35*`. 109 + 110 + *What is the lowest location number that corresponds to any of the initial seed numbers?* 111 + 112 + To begin, [get your puzzle input](5/input). 113 + 114 + Answer: 115 + 116 + You can also [Shareon [Twitter](https://twitter.com/intent/tweet?text=%22If+You+Give+A+Seed+A+Fertilizer%22+%2D+Day+5+%2D+Advent+of+Code+2023&url=https%3A%2F%2Fadventofcode%2Ecom%2F2023%2Fday%2F5&related=ericwastl&hashtags=AdventOfCode) [Mastodon](javascript:void(0);)] this puzzle.
+13
2023/day05/test.ts
··· 1 + import { assertEquals } from "https://deno.land/std@0.208.0/assert/mod.ts"; 2 + import * as p1 from "./part1.ts"; 3 + import * as p2 from "./part2.ts"; 4 + 5 + Deno.test("part1", () => { 6 + const examples = ["abc", "def"].join("\n"); 7 + assertEquals(p1.answer(examples), 42); 8 + }); 9 + 10 + Deno.test("part2", () => { 11 + const examples = ["abc", "def"].join("\n"); 12 + assertEquals(p2.answer(examples), 42); 13 + });