Skip to content

Commit d9585d9

Browse files
committed
Add year 2023 day 5 part 1
1 parent ff1bf52 commit d9585d9

File tree

4 files changed

+263
-0
lines changed

4 files changed

+263
-0
lines changed

2023/day5/input.txt

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
seeds: 304740406 53203352 1080760686 52608146 1670978447 367043978 1445830299 58442414 4012995194 104364808 4123691336 167638723 2284615844 178205532 3164519436 564398605 90744016 147784453 577905361 122056749
2+
3+
seed-to-soil map:
4+
0 699677807 922644641
5+
4174180469 3833727510 120786827
6+
1525682201 2566557266 229511566
7+
3280624601 3954514337 340452959
8+
2228029508 2796068832 310221139
9+
3621077560 3280624601 553102909
10+
2120836342 592484641 107193166
11+
1982514669 227320902 138321673
12+
1755193767 0 227320902
13+
922644641 1622322448 603037560
14+
2538250647 365642575 226842066
15+
2765092713 2225360008 341197258
16+
17+
soil-to-fertilizer map:
18+
1916776044 145070025 3464138
19+
1920240182 0 145070025
20+
706160141 2208005933 115191764
21+
2898492924 830275742 87027483
22+
3489083348 3344594558 103871907
23+
2985520407 148534163 415139950
24+
821351905 917303225 327392865
25+
1148744770 1517236949 182706102
26+
295069722 3448466465 411090419
27+
1816984891 3244803405 99791153
28+
4282585972 4292886644 2080652
29+
3592955255 563674113 266601629
30+
4266462972 4158154511 16123000
31+
1331450872 1244696090 272540859
32+
2715943131 3062253612 182549793
33+
4284666624 4174277511 10300672
34+
4158154511 4184578183 108308461
35+
1603991731 1995012773 212993160
36+
2065310207 2411620688 650632924
37+
0 1699943051 295069722
38+
3400660357 2323197697 88422991
39+
40+
fertilizer-to-water map:
41+
3585244197 3493316345 482900943
42+
2871272496 878061687 456215665
43+
3477664135 4187387234 107580062
44+
845559238 15587711 56716031
45+
121711204 2918313406 409174755
46+
1639718746 0 15587711
47+
530885959 2603640127 314673279
48+
902275269 2435903232 167736895
49+
2635221133 72303742 236051363
50+
1070012164 308355105 569706582
51+
1699846244 1334277352 935374889
52+
4279315086 3477664135 15652210
53+
1655306457 2269652241 44539787
54+
109056711 2423248739 12654493
55+
0 2314192028 109056711
56+
4068145140 3976217288 211169946
57+
58+
water-to-light map:
59+
3841742547 3016842841 17384315
60+
2875021919 2637593760 185450069
61+
3413635232 3588265685 87508205
62+
1311241677 236307150 54007684
63+
3349161906 4276682782 18284514
64+
896790030 1355845673 34430118
65+
3060471988 3835573209 145836645
66+
2741184131 3675773890 133837788
67+
1387754847 947687177 15489861
68+
3785944618 2057196631 55797929
69+
2006585491 2931426646 85416195
70+
3873217816 3809611678 25961531
71+
1667765627 643929130 34884144
72+
2092001686 2434956599 202637161
73+
1001898651 158618769 77688381
74+
3899179347 2253048950 181907649
75+
1786416461 377140410 101956748
76+
0 833901414 113785763
77+
1403244708 479097158 56815029
78+
3859126862 3034227156 14090954
79+
747996464 678813274 31450438
80+
869173795 963177038 27616235
81+
3268502638 2006585491 50611140
82+
113785763 0 148879571
83+
262665334 1511505797 386606610
84+
1187603975 710263712 123637702
85+
3319113778 3987361499 30048128
86+
3367446420 2885237834 46188812
87+
931220148 990793273 15913032
88+
1460059737 1006706305 120880314
89+
1079587032 535912187 108016943
90+
3645890228 2112994560 140054390
91+
3206308633 2823043829 62194005
92+
1888373209 148879571 9739198
93+
3501143437 3443518894 144746791
94+
779446902 1127586619 89726893
95+
947133180 1217313512 54765471
96+
2481910976 4017409627 259273155
97+
1365249361 1390275791 22505486
98+
4087038641 3048318110 207928655
99+
1702649771 1272078983 83766690
100+
649271944 1412781277 98724520
101+
2294638847 3256246765 187272129
102+
4081086996 3981409854 5951645
103+
1580940051 290314834 86825576
104+
105+
light-to-temperature map:
106+
2659452899 3773423191 23529065
107+
1010417677 1830019321 229964714
108+
1506263997 1764304095 65715226
109+
3017023682 3993999178 103632805
110+
3758361154 3931294907 62704271
111+
2513441862 2529586713 106552791
112+
3821065425 3163657189 7959671
113+
3410504451 3191697730 271334719
114+
2500616406 3150831733 12825456
115+
2065874786 2636139504 257698620
116+
4142272690 2382216135 108163002
117+
1377732678 1378901025 61208694
118+
91217027 248578952 8927711
119+
2463617376 3879075083 36999030
120+
3982807123 2315058258 67157877
121+
2323573406 2065874786 97274446
122+
958870382 916323074 51547295
123+
3868386197 3579887474 114420926
124+
931392999 1351423642 27477383
125+
2942753127 3694308400 74270555
126+
1812734437 168620508 79958444
127+
3301364949 2163149232 3197696
128+
2420847852 2166346928 42769524
129+
3829025096 3111470632 39361101
130+
2619994653 2490379137 39207576
131+
1571979223 1523548881 240755214
132+
2927532333 3916074113 15220794
133+
3125500723 4097631983 175864226
134+
1438941372 10080856 67322625
135+
2049903179 0 10080856
136+
3304562645 2209116452 105941806
137+
1976132043 1277652506 73771136
138+
2659202229 3171616860 250670
139+
4256036535 3463032449 38930761
140+
1240382391 257506663 137350287
141+
0 77403481 91217027
142+
3120656487 3768578955 4844236
143+
100144738 967870369 309782137
144+
409926875 394856950 521466124
145+
2682981964 4273496209 21471087
146+
2704453051 3501963210 77924264
147+
2802207515 2893838124 125324818
148+
3681839170 3796952256 76521984
149+
4250435692 3873474240 5600843
150+
1892692881 1440109719 83439162
151+
4049965000 3019162942 92307690
152+
2782377315 3171867530 19830200
153+
154+
temperature-to-humidity map:
155+
1281293605 2434144353 57731817
156+
3534843655 3623804479 36539813
157+
1516028925 367078655 499627624
158+
3340374639 3427302148 25514722
159+
1176213912 2491876170 105079693
160+
3872645852 3827818849 188531931
161+
508302359 1375008638 300832898
162+
0 866706279 508302359
163+
4146417618 3475254801 148549678
164+
4083438506 3660344292 62979112
165+
3365889361 3745584127 82234722
166+
4061177783 3723323404 22260723
167+
2015656549 1675841536 348405327
168+
1056134836 246999579 120079076
169+
3448124083 3452816870 22437931
170+
3321587434 3408514943 18787205
171+
3470562014 4016350780 64281641
172+
3571383468 3321587434 86927509
173+
1339025422 2024246863 177003503
174+
809135257 0 246999579
175+
2364061876 2596955863 115651453
176+
3658310977 4080632421 214334875
177+
2479713329 2201250366 232893987
178+
179+
humidity-to-location map:
180+
2408792839 708984436 12070437
181+
3916327360 4103567762 90492800
182+
2136669394 2902458135 226099404
183+
1414655297 721054873 722014097
184+
2462136308 3514619416 2467233
185+
1254861475 3327498132 98562162
186+
2362768798 569836962 46024041
187+
4185175199 3916327360 8885363
188+
421054090 234463197 201173738
189+
2497827912 1550759989 35404865
190+
849065671 0 224309687
191+
37059832 615861003 93123433
192+
4006820160 3925212723 178355039
193+
2863253575 1705311678 653833074
194+
622227828 1443068970 107691019
195+
2464603541 2869233764 33224371
196+
1353423637 3128557539 61231660
197+
1073375358 3426060294 47286090
198+
2725544642 3189789199 137708933
199+
26906322 224309687 10153510
200+
2420863276 3473346384 41273032
201+
729918847 1586164854 119146824
202+
2533232777 2676921899 192311865
203+
0 2359144752 26906322
204+
1120661448 435636935 134200027
205+
130183265 2386051074 290870825

2023/day5/part1.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
def parse_section(section):
2+
lines = section.split('\n')[1:]
3+
return list(map(lambda line: list(map(int, line.split())), lines))
4+
5+
def parse(inp):
6+
sections = inp.split('\n\n')
7+
seeds = list(map(int, sections[0].split(': ')[1].split()))
8+
transforms = list(map(parse_section, sections[1:]))
9+
return seeds,transforms
10+
11+
def convert(seed, transforms):
12+
s = seed
13+
for transform in transforms:
14+
for transform_item in transform:
15+
dest_start, src_start ,rng = transform_item
16+
if src_start <= s <= src_start + rng:
17+
s = s - src_start + dest_start
18+
break
19+
return s
20+
21+
def solution(input):
22+
seeds,transforms = parse(input)
23+
return min(map(lambda x: convert(x,transforms), seeds))

2023/day5/part2.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
def solution(input):
2+
pass

2023/day5/sample.txt

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
seeds: 79 14 55 13
2+
3+
seed-to-soil map:
4+
50 98 2
5+
52 50 48
6+
7+
soil-to-fertilizer map:
8+
0 15 37
9+
37 52 2
10+
39 0 15
11+
12+
fertilizer-to-water map:
13+
49 53 8
14+
0 11 42
15+
42 0 7
16+
57 7 4
17+
18+
water-to-light map:
19+
88 18 7
20+
18 25 70
21+
22+
light-to-temperature map:
23+
45 77 23
24+
81 45 19
25+
68 64 13
26+
27+
temperature-to-humidity map:
28+
0 69 1
29+
1 0 69
30+
31+
humidity-to-location map:
32+
60 56 37
33+
56 93 4

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy