day 5 part 1
This commit is contained in:
parent
9e92b66cbe
commit
89734cdd86
3 changed files with 290 additions and 242 deletions
39
example.txt
39
example.txt
|
@ -1,6 +1,33 @@
|
||||||
Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53
|
seeds: 79 14 55 13
|
||||||
Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19
|
|
||||||
Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1
|
seed-to-soil map:
|
||||||
Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83
|
50 98 2
|
||||||
Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36
|
52 50 48
|
||||||
Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11
|
|
||||||
|
soil-to-fertilizer map:
|
||||||
|
0 15 37
|
||||||
|
37 52 2
|
||||||
|
39 0 15
|
||||||
|
|
||||||
|
fertilizer-to-water map:
|
||||||
|
49 53 8
|
||||||
|
0 11 42
|
||||||
|
42 0 7
|
||||||
|
57 7 4
|
||||||
|
|
||||||
|
water-to-light map:
|
||||||
|
88 18 7
|
||||||
|
18 25 70
|
||||||
|
|
||||||
|
light-to-temperature map:
|
||||||
|
45 77 23
|
||||||
|
81 45 19
|
||||||
|
68 64 13
|
||||||
|
|
||||||
|
temperature-to-humidity map:
|
||||||
|
0 69 1
|
||||||
|
1 0 69
|
||||||
|
|
||||||
|
humidity-to-location map:
|
||||||
|
60 56 37
|
||||||
|
56 93 4
|
||||||
|
|
370
input.txt
370
input.txt
|
@ -1,198 +1,172 @@
|
||||||
Card 1: 72 28 41 15 98 13 27 99 93 38 | 62 5 80 81 53 29 23 25 59 72 90 19 54 86 68 73 55 21 56 27 32 15 12 42 44
|
seeds: 5844012 110899473 1132285750 58870036 986162929 109080640 3089574276 100113624 2693179996 275745330 2090752257 201704169 502075018 396653347 1540050181 277513792 1921754120 26668991 3836386950 66795009
|
||||||
Card 2: 37 28 78 94 73 43 57 44 75 85 | 1 70 85 94 68 39 11 16 86 77 28 25 78 43 71 26 10 97 81 83 31 88 54 60 98
|
|
||||||
Card 3: 29 62 28 53 94 87 50 67 7 24 | 62 37 95 70 38 7 28 97 24 67 78 35 94 22 21 50 10 87 33 49 92 53 29 55 2
|
seed-to-soil map:
|
||||||
Card 4: 82 49 64 77 88 37 48 55 74 10 | 48 2 97 27 62 42 49 63 94 32 77 40 8 82 52 87 37 76 45 44 88 41 20 74 3
|
3547471595 1239929038 174680800
|
||||||
Card 5: 6 67 39 18 36 95 50 74 55 98 | 50 15 18 59 45 75 67 36 4 79 13 98 47 11 97 54 23 95 99 55 37 90 6 42 74
|
3052451552 758183681 481745357
|
||||||
Card 6: 23 15 17 73 24 59 22 80 46 67 | 27 59 60 32 35 14 33 12 44 45 69 73 2 46 7 24 23 92 17 67 25 94 80 22 15
|
0 1427884524 1775655006
|
||||||
Card 7: 51 76 4 56 62 55 67 16 58 64 | 67 32 82 22 62 55 64 65 24 4 58 45 68 16 61 66 72 96 31 83 21 56 76 51 54
|
2844087171 549819300 208364381
|
||||||
Card 8: 44 48 45 99 54 60 78 37 65 1 | 82 66 45 54 11 94 41 1 26 12 22 43 96 60 9 92 56 46 93 81 61 49 91 3 65
|
3767989253 4004864866 5194940
|
||||||
Card 9: 87 25 59 21 58 27 72 9 85 52 | 53 4 20 89 93 42 56 23 17 3 57 10 21 5 26 25 79 98 87 85 27 2 74 54 49
|
3534196909 1414609838 13274686
|
||||||
Card 10: 9 76 20 82 41 52 87 78 37 59 | 37 29 76 44 99 56 14 70 9 45 82 93 5 89 95 41 65 20 27 87 61 71 39 51 52
|
1775655006 114264781 435554519
|
||||||
Card 11: 59 22 35 8 90 28 60 97 10 13 | 46 18 54 30 47 88 74 14 21 17 50 52 26 84 39 37 36 67 94 66 59 95 28 41 86
|
4148908402 4010059806 146058894
|
||||||
Card 12: 11 10 77 92 45 61 50 47 23 44 | 45 49 61 10 48 39 73 44 66 97 53 90 85 24 70 47 2 74 83 93 82 79 42 33 15
|
2729822390 0 114264781
|
||||||
Card 13: 82 25 28 20 48 29 90 22 45 96 | 81 14 28 12 97 25 60 76 5 90 11 29 85 4 89 96 38 69 57 95 24 86 22 63 98
|
3773184193 4156118700 138848596
|
||||||
Card 14: 48 27 4 95 22 45 78 73 70 12 | 85 23 45 51 68 73 62 18 40 31 30 55 19 27 65 74 88 24 98 72 48 63 47 26 12
|
2211209525 3203539530 518612865
|
||||||
Card 15: 27 87 34 36 64 85 32 74 58 20 | 22 27 26 3 6 92 42 64 36 68 58 72 32 82 59 18 74 85 78 34 17 20 79 53 54
|
3912032789 3767989253 236875613
|
||||||
Card 16: 63 90 45 7 41 6 27 11 43 24 | 2 9 88 24 71 52 91 3 95 7 45 50 20 28 39 49 34 63 41 21 6 11 43 13 27
|
|
||||||
Card 17: 96 57 79 27 22 14 87 99 65 28 | 1 75 98 45 5 4 95 55 93 56 44 68 16 47 62 77 17 64 71 8 10 34 6 7 52
|
soil-to-fertilizer map:
|
||||||
Card 18: 56 46 12 15 66 36 30 13 54 5 | 81 39 98 37 9 74 83 13 86 56 85 77 11 57 78 75 47 95 10 84 99 1 8 3 26
|
912405184 1056091028 152837752
|
||||||
Card 19: 92 11 56 8 42 86 89 40 58 2 | 31 42 33 58 98 74 29 54 10 26 25 79 3 81 59 78 95 52 39 22 8 45 72 40 15
|
194471272 1208928780 200072008
|
||||||
Card 20: 96 5 95 79 86 54 14 34 68 20 | 45 86 96 35 43 56 28 12 3 33 59 41 54 65 29 21 47 5 61 95 82 83 63 16 27
|
136115250 240819204 58356022
|
||||||
Card 21: 38 79 50 63 76 64 41 20 14 85 | 37 5 27 56 14 58 13 26 71 55 60 51 21 78 94 76 15 42 53 73 20 80 24 83 3
|
3502815281 3536983174 299994001
|
||||||
Card 22: 81 91 75 86 56 48 69 61 41 40 | 60 23 74 75 4 22 59 19 93 94 88 2 56 87 36 73 98 41 42 97 90 8 53 24 20
|
2321814552 2458149869 18748048
|
||||||
Card 23: 43 81 40 66 11 53 90 48 1 4 | 7 79 33 28 89 21 26 3 55 47 83 42 88 91 32 19 69 84 96 31 82 49 77 76 81
|
3173949445 2623931701 9591555
|
||||||
Card 24: 34 97 36 21 9 16 33 1 61 77 | 25 19 40 47 74 64 11 50 22 17 7 83 67 26 53 93 78 56 30 68 13 8 39 54 98
|
394543280 888648379 167442649
|
||||||
Card 25: 94 85 93 45 95 64 9 49 76 3 | 32 57 82 75 90 42 89 13 71 99 39 6 70 24 81 56 51 52 21 36 53 69 91 20 48
|
1990258415 3891640206 212931291
|
||||||
Card 26: 74 99 5 37 76 19 68 96 49 36 | 70 79 60 21 9 78 18 96 7 25 22 6 29 74 87 45 85 30 11 89 27 94 15 77 17
|
1068754270 54862533 153774684
|
||||||
Card 27: 44 7 49 67 45 53 79 77 81 33 | 6 77 53 44 45 49 8 7 27 68 79 24 2 12 75 11 35 69 51 83 40 46 61 85 88
|
1222528954 660792432 186471834
|
||||||
Card 28: 62 45 65 77 83 80 81 17 74 16 | 5 17 70 78 59 52 37 84 80 45 7 93 81 25 58 10 50 75 95 57 9 43 77 12 51
|
3340878967 3405750148 131233026
|
||||||
Card 29: 49 1 22 80 19 12 5 63 82 91 | 35 89 38 20 77 14 33 67 52 96 60 71 37 97 30 80 8 58 28 72 41 1 68 53 64
|
3472111993 3836977175 30703288
|
||||||
Card 30: 81 45 73 37 48 13 16 18 58 54 | 56 48 41 32 18 13 81 16 52 45 6 27 12 73 62 5 33 36 37 70 54 64 4 58 95
|
561985929 299175226 225501956
|
||||||
Card 31: 33 21 74 11 63 14 47 22 83 8 | 79 24 22 20 60 26 21 1 31 61 11 45 72 59 91 69 63 94 14 47 8 97 49 7 34
|
2942828492 4104571497 88527954
|
||||||
Card 32: 48 99 47 86 67 39 50 84 60 12 | 76 77 67 47 28 4 20 71 60 8 21 84 78 91 30 79 88 2 31 16 14 39 74 26 33
|
874532405 850775600 37872779
|
||||||
Card 33: 2 74 96 24 70 73 37 3 39 64 | 13 18 89 32 39 21 71 24 51 76 5 70 38 15 17 6 43 27 8 81 91 55 25 49 52
|
3031356446 3867680463 23959743
|
||||||
Card 34: 51 77 1 25 79 59 6 23 98 88 | 62 24 58 67 43 64 54 85 28 76 44 15 81 48 98 80 73 40 53 84 8 42 86 87 16
|
842350418 208637217 32181987
|
||||||
Card 35: 60 72 53 73 10 17 88 6 91 8 | 6 25 31 93 97 22 76 43 84 63 78 23 86 12 40 77 21 20 73 13 38 46 47 56 57
|
0 524677182 136115250
|
||||||
Card 36: 5 87 56 90 74 94 6 57 41 73 | 88 98 35 31 59 53 56 30 85 66 40 16 95 14 21 11 73 64 86 10 3 26 55 90 87
|
1065242936 847264266 3511334
|
||||||
Card 37: 89 92 85 40 67 50 26 37 49 68 | 3 23 69 53 19 31 95 14 58 79 82 22 62 65 52 68 33 57 4 99 92 89 67 21 54
|
2203189706 2339525023 118624846
|
||||||
Card 38: 9 97 60 3 13 82 54 42 83 40 | 42 98 10 97 92 84 68 46 75 1 13 62 53 36 24 72 95 45 14 37 6 78 38 23 19
|
1929736108 2563409394 60522307
|
||||||
Card 39: 46 60 95 83 18 38 29 47 74 86 | 34 78 77 99 83 52 23 96 46 97 14 20 88 62 36 98 37 64 82 59 86 49 93 40 65
|
3802809282 1847367009 492158014
|
||||||
Card 40: 14 25 41 36 91 58 31 20 57 3 | 71 46 86 22 30 63 96 42 43 66 18 35 2 67 54 59 7 16 97 69 5 50 89 4 53
|
1847367009 2790861223 82369099
|
||||||
Card 41: 78 93 75 66 13 81 26 20 49 27 | 21 63 33 79 14 89 32 15 18 2 59 47 80 69 74 95 40 34 50 12 94 65 62 17 68
|
2442430445 2873230322 500398047
|
||||||
Card 42: 43 46 47 80 38 45 34 7 53 98 | 77 36 19 14 2 48 69 62 56 16 70 58 97 87 63 76 31 29 59 94 26 15 72 57 5
|
3183541000 2633523256 157337967
|
||||||
Card 43: 16 93 58 31 6 57 68 91 35 72 | 55 23 47 10 51 38 99 41 27 46 42 30 9 4 54 73 3 89 12 95 50 40 11 98 53
|
3141827666 3373628369 32121779
|
||||||
Card 44: 24 17 51 82 96 32 45 25 99 87 | 99 29 60 64 25 46 87 75 6 53 74 1 24 70 82 37 78 76 32 3 22 4 69 44 86
|
787487885 0 54862533
|
||||||
Card 45: 8 12 5 56 2 10 24 87 45 78 | 79 50 87 19 95 96 17 22 14 36 77 81 69 54 66 30 20 37 2 68 34 1 10 92 56
|
3055316189 2476897917 86511477
|
||||||
Card 46: 14 35 28 26 61 20 33 59 86 85 | 29 35 36 73 5 8 24 14 88 61 19 9 97 82 89 91 28 20 15 34 59 30 87 83 84
|
2340562600 4193099451 101867845
|
||||||
Card 47: 4 9 24 39 11 40 82 70 87 2 | 51 70 13 79 56 23 24 73 62 28 39 11 2 58 17 9 82 27 78 40 37 12 5 43 69
|
|
||||||
Card 48: 60 91 22 79 97 21 86 74 44 75 | 75 44 85 41 8 60 74 19 86 25 37 71 47 33 97 82 36 54 43 38 21 56 79 91 22
|
fertilizer-to-water map:
|
||||||
Card 49: 52 41 36 9 83 92 34 37 79 14 | 36 41 50 15 47 70 57 38 84 62 22 94 63 27 39 9 85 78 82 56 53 90 88 40 87
|
798315344 439687669 1930292
|
||||||
Card 50: 86 60 91 4 33 25 46 83 38 97 | 29 54 63 85 46 70 25 6 1 15 89 36 21 93 49 28 73 65 77 84 71 74 42 82 76
|
1174979421 2966258900 475289790
|
||||||
Card 51: 60 56 33 57 65 22 72 51 82 53 | 70 85 79 54 41 26 87 61 21 3 81 71 94 34 92 47 77 50 25 19 1 10 88 55 42
|
439687669 778614573 55925503
|
||||||
Card 52: 33 87 57 5 77 9 60 73 12 92 | 99 67 45 65 25 7 1 64 73 19 60 48 76 75 68 57 62 85 79 72 55 63 77 17 87
|
3743699694 3453541232 155280637
|
||||||
Card 53: 11 44 51 20 77 64 49 83 84 28 | 32 10 85 15 45 53 99 24 55 37 6 33 64 11 84 25 91 36 58 21 7 83 29 49 52
|
2989334775 1659556189 96021468
|
||||||
Card 54: 4 15 29 19 16 42 97 90 3 6 | 40 59 63 41 19 61 95 83 31 29 86 71 69 96 47 9 52 42 22 81 18 60 79 89 3
|
1650269211 3441548690 11992542
|
||||||
Card 55: 34 45 40 36 50 37 72 5 95 33 | 51 55 41 1 74 3 11 84 72 54 78 8 71 38 62 94 91 10 27 76 21 31 17 47 35
|
3898980331 3608821869 395986965
|
||||||
Card 56: 19 45 18 13 7 88 40 56 12 30 | 6 55 96 20 73 23 31 78 16 79 57 76 35 64 82 86 49 92 41 59 25 60 91 21 70
|
1705125292 2123762646 842496254
|
||||||
Card 57: 17 45 10 89 54 19 24 86 13 34 | 6 33 69 42 26 51 73 27 62 93 94 14 43 46 87 68 9 80 4 61 65 5 52 12 95
|
3375514705 1755577657 368184989
|
||||||
Card 58: 73 72 85 69 30 16 78 13 38 34 | 65 12 91 22 1 66 2 15 27 96 94 18 48 17 75 46 40 63 39 14 90 77 56 4 23
|
646363825 441617961 94777173
|
||||||
Card 59: 64 29 70 58 74 68 59 99 83 95 | 68 29 70 78 24 91 96 46 92 93 95 23 43 60 5 69 66 6 51 33 28 45 65 31 61
|
1662261753 1616692650 42863539
|
||||||
Card 60: 15 38 3 56 96 93 70 35 48 62 | 59 3 76 65 40 12 55 95 16 24 97 2 23 61 41 31 89 20 68 82 38 43 70 46 80
|
495613172 627863920 150750653
|
||||||
Card 61: 21 96 73 10 62 64 28 24 48 41 | 10 46 24 58 45 25 53 4 78 41 90 64 26 33 56 36 21 55 28 80 96 82 83 74 91
|
2777061135 1174979421 212273640
|
||||||
Card 62: 10 68 28 76 71 89 51 97 41 79 | 61 5 99 4 52 74 10 57 59 76 40 68 82 79 65 84 51 17 41 71 28 89 97 1 64
|
741140998 834540076 57174346
|
||||||
Card 63: 3 92 2 69 42 29 11 87 49 79 | 3 77 2 15 93 42 71 96 45 49 59 90 7 99 69 16 4 26 58 11 27 22 92 87 79
|
800245636 536395134 91468786
|
||||||
Card 64: 56 63 16 57 53 43 30 48 74 72 | 77 87 36 27 21 18 42 25 70 15 81 34 9 44 82 10 45 99 4 84 46 62 47 61 57
|
2547621546 1387253061 229439589
|
||||||
Card 65: 23 40 28 75 43 82 88 51 46 33 | 67 74 11 90 82 94 51 12 53 78 8 23 56 18 44 19 42 29 43 63 70 28 21 37 2
|
3085356243 4004808834 290158462
|
||||||
Card 66: 97 40 80 41 13 60 15 45 24 78 | 2 15 78 97 67 90 51 24 77 7 58 47 60 62 80 13 53 19 84 74 81 45 40 41 30
|
|
||||||
Card 67: 9 17 47 46 20 7 36 32 29 94 | 7 32 44 47 11 59 81 9 76 96 20 56 71 50 43 46 94 62 29 92 17 31 36 55 91
|
water-to-light map:
|
||||||
Card 68: 22 72 60 86 49 1 96 89 78 19 | 25 93 1 95 17 12 70 9 89 78 20 60 53 49 19 86 51 72 73 44 97 71 96 22 74
|
541719462 212840988 165903288
|
||||||
Card 69: 12 53 67 30 65 41 92 80 42 5 | 84 78 12 31 90 80 47 42 67 76 19 65 92 8 5 75 89 53 18 52 15 30 41 88 91
|
3437755571 1615831015 672632835
|
||||||
Card 70: 43 83 27 60 36 38 15 63 18 47 | 6 94 25 47 17 1 2 27 9 98 11 69 42 43 87 59 83 5 81 48 86 18 36 22 60
|
1051033542 2678450187 510773217
|
||||||
Card 71: 71 46 90 3 24 41 80 5 7 6 | 70 63 74 88 98 87 97 61 21 86 18 2 48 27 77 81 79 43 29 13 66 26 37 1 95
|
243353905 378744276 104057369
|
||||||
Card 72: 16 5 84 22 70 2 46 65 35 52 | 9 20 40 23 80 82 8 4 38 45 6 87 55 53 14 5 32 37 56 51 57 61 16 65 48
|
1561806759 3801474127 134575711
|
||||||
Card 73: 61 65 99 78 52 7 64 44 53 3 | 6 23 41 92 74 17 54 84 96 29 27 58 35 36 86 51 5 62 87 76 2 9 85 39 81
|
707622750 677109833 258560892
|
||||||
Card 74: 91 62 63 12 90 27 93 98 84 68 | 25 31 91 69 98 62 18 74 82 48 15 36 3 95 27 63 53 23 43 4 46 90 39 76 68
|
2580483557 1051033542 195631857
|
||||||
Card 75: 80 47 42 96 28 39 71 52 58 21 | 49 73 4 18 10 12 87 93 29 8 46 50 99 94 21 63 2 45 86 95 59 69 44 58 83
|
0 935670725 30512917
|
||||||
Card 76: 28 13 94 21 26 99 97 52 91 57 | 45 81 4 62 90 5 66 23 29 19 70 39 41 75 76 54 72 46 28 65 36 51 95 47 31
|
347411274 482801645 194308188
|
||||||
Card 77: 53 33 56 44 78 17 64 16 25 28 | 93 32 82 96 49 35 81 67 73 10 68 21 50 43 80 89 41 33 98 97 78 4 66 42 24
|
30512917 0 127836567
|
||||||
Card 78: 45 65 44 80 19 2 87 61 30 74 | 76 11 48 98 97 74 21 37 50 33 75 87 45 8 34 67 55 86 25 32 93 62 41 39 5
|
2190497220 2288463850 389986337
|
||||||
Card 79: 20 23 59 53 50 73 30 87 22 48 | 72 45 33 47 29 32 89 65 79 64 5 41 49 69 7 62 6 57 14 9 31 48 61 23 75
|
3068589955 1246665399 369165616
|
||||||
Card 80: 25 48 7 89 93 32 98 80 75 41 | 90 1 54 81 43 40 22 60 14 86 99 55 5 21 56 30 50 92 44 87 59 45 29 19 18
|
1754579039 3936049838 66442917
|
||||||
Card 81: 65 42 66 68 69 64 87 17 32 22 | 13 19 6 24 35 45 21 98 16 20 67 1 26 95 33 59 55 14 29 93 61 84 83 99 89
|
4110388406 3616895237 184578890
|
||||||
Card 82: 58 2 11 55 69 89 78 70 30 43 | 15 54 24 28 14 2 9 37 34 79 43 11 58 89 70 27 30 69 94 55 78 75 87 86 48
|
158349484 127836567 85004421
|
||||||
Card 83: 3 51 75 92 98 65 9 50 95 53 | 9 24 72 53 1 68 98 50 59 60 89 75 4 48 51 95 3 66 54 58 70 65 73 63 92
|
2776115414 4002492755 292474541
|
||||||
Card 84: 39 98 33 99 44 64 37 68 59 72 | 65 33 53 52 6 20 46 16 96 44 82 4 78 84 58 74 17 85 24 55 28 77 79 38 99
|
1821021956 3247419973 369475264
|
||||||
Card 85: 37 91 78 34 23 32 84 90 68 45 | 15 23 25 8 36 90 13 17 2 37 57 84 78 68 75 33 10 1 6 45 16 88 32 91 34
|
1696382470 3189223404 58196569
|
||||||
Card 86: 77 83 46 88 11 64 24 79 14 6 | 73 79 10 86 26 76 87 32 42 48 58 16 88 8 18 37 77 54 47 64 46 49 31 6 68
|
|
||||||
Card 87: 8 19 64 68 51 78 79 34 59 95 | 94 68 49 6 51 69 37 24 95 77 79 35 8 81 52 14 97 96 62 78 5 29 4 42 18
|
light-to-temperature map:
|
||||||
Card 88: 72 63 39 73 77 11 83 17 87 99 | 75 92 48 73 71 30 72 39 66 33 87 10 16 11 90 17 99 83 67 89 77 50 24 27 63
|
338228166 2812162941 77503977
|
||||||
Card 89: 48 33 27 86 64 15 45 6 18 12 | 15 45 5 80 59 13 28 18 26 33 75 99 82 72 37 6 12 11 19 97 31 32 88 8 54
|
3123877206 693964345 40932068
|
||||||
Card 90: 63 90 32 36 76 67 79 78 69 37 | 20 63 41 50 13 64 81 22 25 46 91 12 3 30 6 9 76 34 16 90 65 7 42 26 68
|
3939438903 614787731 633466
|
||||||
Card 91: 30 61 19 92 69 14 78 55 15 89 | 99 6 30 41 40 97 69 48 83 21 29 9 81 28 7 34 55 66 49 15 19 42 12 89 74
|
3301169239 2299402886 215156012
|
||||||
Card 92: 87 24 74 68 86 66 64 22 78 98 | 57 68 6 97 78 4 44 79 65 21 80 34 85 87 10 56 22 91 86 39 95 63 48 37 77
|
3516325251 499164007 115623724
|
||||||
Card 93: 78 30 24 11 89 83 17 93 48 23 | 69 78 77 84 67 56 99 51 62 36 18 30 68 79 42 10 89 53 97 43 82 21 48 80 20
|
3852145506 3365439095 87293397
|
||||||
Card 94: 45 25 91 43 70 86 39 52 56 50 | 81 69 2 77 63 50 10 13 91 56 94 45 26 99 20 34 25 30 1 39 64 15 8 43 98
|
875755064 3565078024 729889272
|
||||||
Card 95: 6 82 38 27 32 46 97 9 28 73 | 77 40 8 64 6 67 14 1 89 73 97 2 54 88 48 47 29 84 90 69 46 31 12 79 71
|
2849390436 734896413 11914872
|
||||||
Card 96: 78 87 5 28 59 49 21 17 9 18 | 84 60 27 61 41 1 88 70 94 32 34 66 75 46 33 65 37 22 36 92 83 89 99 67 48
|
2861305308 215265512 77518872
|
||||||
Card 97: 13 51 2 66 89 1 18 17 7 40 | 99 74 81 94 39 12 9 82 79 43 77 84 62 87 71 95 98 34 57 48 16 52 45 83 64
|
4220385528 2056242491 68417151
|
||||||
Card 98: 12 88 9 78 64 14 2 80 6 87 | 75 95 61 99 39 76 89 60 57 4 41 93 30 45 25 82 7 81 34 21 27 86 54 18 13
|
2221674563 3167682469 34693717
|
||||||
Card 99: 97 59 19 58 48 42 49 95 39 86 | 80 99 1 56 9 24 83 88 78 35 4 66 31 92 84 32 17 36 13 65 73 6 51 96 34
|
2765973467 292784384 83416969
|
||||||
Card 100: 42 61 26 14 66 81 98 48 13 19 | 1 92 82 36 6 69 89 70 35 31 76 55 29 56 46 85 75 84 71 65 78 5 80 58 99
|
3198884011 1699097031 22283517
|
||||||
Card 101: 88 61 42 18 23 11 73 72 12 1 | 80 32 57 93 35 70 21 44 92 87 55 71 22 99 98 77 36 40 54 47 53 64 29 67 65
|
3164809274 2889666918 34074737
|
||||||
Card 102: 53 24 65 75 35 80 13 22 98 14 | 13 46 3 80 97 75 85 22 43 7 53 28 98 1 49 24 35 14 93 8 45 50 30 68 65
|
809366712 746811285 52314986
|
||||||
Card 103: 94 39 46 24 64 34 10 29 54 1 | 23 60 86 55 71 56 5 52 1 94 69 40 95 19 80 26 72 64 6 24 3 67 84 18 81
|
4096970661 1633036395 58945085
|
||||||
Card 104: 3 82 86 60 32 35 75 94 39 55 | 37 21 64 20 92 85 59 94 1 86 35 43 56 32 50 72 28 3 75 7 82 39 4 60 55
|
3221167528 2699611924 80001711
|
||||||
Card 105: 87 70 72 25 8 88 5 15 40 11 | 67 5 41 25 40 61 75 56 11 15 66 88 72 47 31 87 97 85 70 43 8 98 23 95 46
|
697021180 3452732492 112345532
|
||||||
Card 106: 20 28 80 56 54 63 96 8 16 95 | 56 74 32 36 92 78 96 79 2 76 6 62 24 87 8 93 3 4 59 54 80 77 95 58 28
|
2059345064 799126271 162329499
|
||||||
Card 107: 64 75 22 29 30 63 98 28 5 95 | 38 68 96 79 90 30 3 5 91 31 34 66 83 16 46 75 35 7 48 6 8 18 10 54 20
|
4155915746 629494563 64469782
|
||||||
Card 108: 34 95 1 70 37 38 74 60 8 23 | 30 84 35 16 66 67 31 20 13 53 98 14 56 80 47 73 96 86 87 44 85 93 49 43 55
|
2431111524 1721380548 334861943
|
||||||
Card 109: 59 3 78 98 6 51 44 72 90 47 | 19 15 90 37 52 39 51 29 66 74 47 4 85 6 27 75 82 5 32 55 77 21 78 72 88
|
684283267 2779613635 12737913
|
||||||
Card 110: 4 97 60 52 22 43 14 42 31 30 | 19 6 96 37 42 86 81 72 48 45 92 7 97 13 78 63 17 35 59 38 64 99 4 98 1
|
440342453 2923741655 243940814
|
||||||
Card 111: 45 9 43 76 40 56 22 27 77 71 | 75 37 51 1 92 65 59 40 58 39 29 91 70 83 54 86 74 97 42 50 73 4 61 23 57
|
3634265609 961455770 217879897
|
||||||
Card 112: 97 64 16 37 6 70 35 18 10 14 | 41 88 95 57 34 90 2 69 9 30 11 78 92 60 86 80 89 37 65 68 58 8 72 13 74
|
4288802679 3202376186 6164617
|
||||||
Card 113: 46 98 31 39 63 64 58 33 5 36 | 81 91 29 20 52 61 77 82 98 96 97 19 72 67 32 45 1 22 40 3 27 89 71 7 37
|
415732143 1691981480 4798917
|
||||||
Card 114: 89 40 82 24 39 45 74 17 15 47 | 78 21 79 3 68 56 52 30 40 97 71 67 90 34 16 32 55 42 85 6 45 41 84 13 35
|
1605644336 1179335667 453700728
|
||||||
Card 115: 25 67 21 27 93 84 40 16 8 57 | 74 77 24 14 39 97 78 73 52 19 31 10 23 76 58 38 11 42 34 63 45 27 17 64 41
|
420531060 2792351548 19811393
|
||||||
Card 116: 46 27 38 53 18 29 95 40 96 58 | 66 97 13 3 87 25 41 24 98 49 69 45 5 94 59 7 6 36 32 10 17 31 42 84 75
|
3631948975 1696780397 2316634
|
||||||
Card 117: 87 43 58 55 92 45 94 24 67 25 | 37 73 36 13 86 63 14 69 88 87 40 95 70 4 90 84 89 96 39 60 54 50 17 61 66
|
2938824180 2514558898 185053026
|
||||||
Card 118: 40 11 89 16 10 45 51 90 64 18 | 50 61 64 83 9 90 11 10 44 97 30 60 32 14 40 51 45 18 16 29 99 79 36 24 89
|
215265512 376201353 122962654
|
||||||
Card 119: 27 78 72 35 5 20 53 40 49 77 | 38 14 20 56 78 69 88 35 92 77 70 34 95 2 74 72 29 91 99 96 49 18 5 27 52
|
2256368280 2124659642 174743244
|
||||||
Card 120: 51 25 23 8 7 89 21 56 82 41 | 79 47 2 41 50 39 86 51 61 17 21 28 85 7 25 68 89 19 87 23 40 8 56 11 82
|
3940072369 3208540803 156898292
|
||||||
Card 121: 35 45 14 58 40 83 4 28 69 92 | 22 64 50 55 78 36 66 74 42 12 23 70 11 49 5 15 48 21 79 53 87 72 76 68 82
|
861681698 615421197 14073366
|
||||||
Card 122: 86 5 49 22 93 54 78 4 23 10 | 92 29 80 22 55 5 13 6 87 78 4 20 25 81 86 19 54 23 93 96 94 10 16 49 38
|
|
||||||
Card 123: 12 58 15 7 79 86 33 39 78 28 | 25 94 1 81 39 78 61 93 86 45 19 60 83 2 15 33 28 58 7 51 82 67 12 79 52
|
temperature-to-humidity map:
|
||||||
Card 124: 64 81 69 71 37 66 20 33 2 24 | 10 2 90 74 33 81 87 37 36 69 49 71 6 68 21 66 64 44 24 88 43 29 20 94 47
|
841576398 2731200418 60836938
|
||||||
Card 125: 13 62 34 47 51 49 97 41 32 40 | 2 54 97 79 14 35 40 51 75 91 76 10 72 57 78 49 60 98 9 13 28 65 70 25 50
|
1860695540 395011682 292982985
|
||||||
Card 126: 69 26 74 4 70 3 34 65 48 16 | 47 20 52 36 66 59 77 41 6 51 15 19 28 72 14 35 39 10 55 40 45 33 42 90 79
|
1518037021 3432774193 53954373
|
||||||
Card 127: 13 84 29 23 70 77 89 75 83 51 | 79 5 85 25 91 75 64 57 83 89 73 69 39 56 6 70 13 33 32 84 60 68 23 77 29
|
1786573987 2461900019 55353430
|
||||||
Card 128: 92 48 56 8 69 72 43 11 17 98 | 48 17 8 72 23 93 82 68 36 15 6 56 43 69 92 73 11 98 75 2 49 74 1 20 29
|
2940303448 1995108352 6974538
|
||||||
Card 129: 86 55 77 27 48 50 3 12 23 97 | 38 84 71 5 8 70 99 78 96 90 69 34 93 40 36 6 59 74 81 15 83 52 94 82 18
|
3014069287 1664464874 53916789
|
||||||
Card 130: 36 61 95 38 65 76 84 24 58 51 | 92 82 38 73 16 67 87 84 34 58 63 54 65 99 61 93 8 13 21 66 24 3 31 64 62
|
753139746 2190061656 88436652
|
||||||
Card 131: 93 27 24 39 25 6 47 86 45 95 | 25 99 69 35 51 9 24 60 46 28 64 95 74 36 30 44 8 12 18 42 52 27 22 39 43
|
2351822957 2925825589 209990361
|
||||||
Card 132: 5 33 58 17 92 51 99 49 28 82 | 94 33 58 11 81 63 82 39 48 3 53 5 31 47 77 10 17 61 51 80 92 45 85 59 49
|
3079884326 3498626816 37609115
|
||||||
Card 133: 11 82 92 35 33 94 70 53 98 5 | 52 12 50 41 86 66 36 76 25 72 10 81 71 63 96 60 83 55 61 48 14 85 16 97 28
|
4067060121 4186346579 108620717
|
||||||
Card 134: 31 13 39 66 47 40 11 34 41 29 | 9 80 66 47 76 44 41 71 35 93 45 67 34 39 52 21 29 31 53 23 30 57 63 65 20
|
4175680838 4102322798 3778367
|
||||||
Card 135: 8 19 59 77 25 62 84 67 86 39 | 32 60 18 6 30 22 20 47 28 46 72 91 52 71 83 35 49 66 11 80 14 90 16 87 44
|
1571991394 2415899186 46000833
|
||||||
Card 136: 59 29 20 44 26 15 54 51 76 83 | 94 26 46 92 12 38 37 75 84 48 22 55 34 43 79 3 16 70 64 80 68 58 13 8 28
|
2841627583 1157034722 22534242
|
||||||
Card 137: 45 30 32 91 57 61 43 93 5 94 | 34 16 59 72 66 58 77 80 54 84 44 25 55 49 48 23 69 14 85 51 6 42 13 41 20
|
1841927417 2517253449 18768123
|
||||||
Card 138: 44 94 8 27 58 67 10 53 59 25 | 9 44 11 13 49 23 72 41 94 64 25 95 74 85 43 37 32 69 96 18 17 98 56 29 45
|
2153678525 47765849 108568164
|
||||||
Card 139: 38 49 5 91 53 27 17 44 96 32 | 71 97 3 84 48 90 88 35 14 70 94 62 40 87 86 53 43 15 21 83 16 28 79 33 72
|
3251281674 1179568964 226737882
|
||||||
Card 140: 15 47 6 40 21 45 23 69 3 20 | 72 65 96 71 19 87 42 86 62 77 8 97 57 33 22 95 55 74 73 12 79 27 60 90 18
|
3067986076 3486728566 11898250
|
||||||
Card 141: 92 18 65 62 38 34 48 57 67 20 | 41 4 8 10 40 29 88 6 59 89 24 98 26 70 3 23 61 25 64 1 82 52 46 16 30
|
1308101633 1785172964 209935388
|
||||||
Card 142: 76 43 72 60 88 34 65 74 84 10 | 60 58 5 84 20 10 77 74 65 23 38 24 34 44 33 83 88 41 43 76 35 50 28 13 72
|
2262246689 1406306846 89576268
|
||||||
Card 143: 91 51 38 29 88 10 90 96 70 49 | 38 59 90 20 29 7 35 13 51 88 14 86 47 91 80 28 12 49 96 70 43 10 65 37 5
|
902413336 2278498308 137400878
|
||||||
Card 144: 51 89 31 27 50 44 17 59 24 16 | 74 27 77 89 44 53 52 31 14 6 16 51 17 2 59 69 83 57 4 15 79 75 13 78 26
|
1039814214 3765380846 268287419
|
||||||
Card 145: 23 40 50 80 79 56 84 81 82 1 | 34 85 79 10 75 11 48 47 3 24 91 50 60 62 51 98 63 15 17 82 69 52 6 54 21
|
45422022 156334013 238677669
|
||||||
Card 146: 80 16 41 55 53 64 10 96 33 65 | 71 27 64 77 18 55 66 41 78 96 24 80 33 11 65 88 13 57 99 10 30 31 84 20 53
|
3617672799 2612163195 119037223
|
||||||
Card 147: 55 15 61 46 86 2 45 17 5 32 | 10 75 8 20 69 7 4 34 72 13 92 28 78 17 48 27 55 15 90 11 66 61 46 86 21
|
2947277986 1718381663 66791301
|
||||||
Card 148: 52 90 71 33 34 88 75 63 99 76 | 71 31 99 74 32 34 52 63 59 87 42 88 90 75 5 38 12 13 3 96 76 25 49 33 56
|
1617992227 1495883114 168581760
|
||||||
Card 149: 65 98 39 11 57 7 80 95 12 53 | 7 47 72 65 57 11 80 29 53 94 28 41 19 3 50 55 23 95 66 43 39 21 45 12 91
|
284099691 687994667 469040055
|
||||||
Card 150: 47 43 6 94 78 81 91 9 97 56 | 99 18 68 94 49 39 40 79 64 37 56 7 85 32 80 6 23 9 38 52 92 81 67 91 97
|
4214721882 4106101165 80245414
|
||||||
Card 151: 79 62 61 82 73 78 83 74 12 51 | 26 6 73 63 83 49 25 61 87 40 96 74 38 2 62 18 78 91 90 82 84 12 51 79 3
|
2839283756 45422022 2343827
|
||||||
Card 152: 93 7 5 39 52 70 95 27 26 41 | 91 79 26 7 41 70 52 67 93 71 95 10 39 15 27 54 5 62 74 9 88 73 80 38 97
|
3117493441 2792037356 133788233
|
||||||
Card 153: 95 42 37 86 44 21 59 93 63 6 | 96 45 58 16 98 17 69 97 7 18 72 71 86 38 22 33 28 13 56 50 41 78 57 48 24
|
2864161825 2536021572 76141623
|
||||||
Card 154: 91 55 94 22 90 18 56 81 45 43 | 80 84 47 23 26 70 8 14 15 66 22 2 12 40 44 85 93 58 39 3 17 71 68 65 52
|
4179459205 4067060121 35262677
|
||||||
Card 155: 65 15 24 75 10 50 96 86 69 11 | 7 43 21 57 82 16 53 90 39 84 60 49 91 79 66 94 25 54 5 93 97 70 1 30 28
|
3736710022 3135815950 296958243
|
||||||
Card 156: 83 43 19 68 70 71 65 89 26 66 | 34 67 60 87 97 22 96 33 62 99 5 71 37 35 58 1 86 14 55 21 82 91 44 17 24
|
3478019556 2002082890 139653243
|
||||||
Card 157: 67 50 3 60 34 39 84 18 31 58 | 60 27 82 61 94 75 30 45 72 85 10 48 76 34 79 32 17 18 67 35 70 38 93 29 12
|
2610138841 3536235931 229144915
|
||||||
Card 158: 35 33 92 31 34 58 94 60 95 6 | 31 69 97 92 98 85 53 81 87 84 58 28 4 93 22 44 35 55 27 13 95 41 88 89 36
|
2561813318 2141736133 48325523
|
||||||
Card 159: 10 65 42 20 67 84 32 6 7 86 | 56 4 97 50 9 12 53 10 39 84 43 77 61 68 32 91 36 87 22 15 60 7 11 24 49
|
|
||||||
Card 160: 54 48 50 52 7 51 24 58 31 85 | 45 81 28 56 88 20 43 76 36 4 25 99 30 18 98 49 71 95 60 35 91 70 51 33 55
|
humidity-to-location map:
|
||||||
Card 161: 20 97 89 66 48 23 14 46 80 57 | 83 74 19 13 87 28 5 94 35 81 56 58 65 55 45 90 39 29 14 12 22 59 57 95 67
|
608325534 0 231346900
|
||||||
Card 162: 95 26 51 56 83 41 19 66 79 25 | 84 95 37 71 18 27 87 33 3 16 51 47 66 86 49 48 55 7 28 50 20 43 75 9 85
|
222429954 453776854 385895580
|
||||||
Card 163: 79 24 49 72 70 61 18 84 68 86 | 88 3 73 69 21 83 76 51 1 47 45 43 82 33 14 15 16 93 22 7 31 50 19 94 99
|
3710263359 3540956206 563631409
|
||||||
Card 164: 81 80 24 59 30 55 73 94 7 70 | 89 72 62 43 58 14 47 71 41 92 5 36 46 3 96 33 30 18 63 64 12 44 86 9 76
|
1193511298 1116937854 38719102
|
||||||
Card 165: 10 83 1 18 5 82 81 29 67 92 | 65 17 74 88 3 11 54 80 4 42 8 91 99 59 6 58 62 30 96 63 2 41 90 43 38
|
1702450793 1176729484 153572024
|
||||||
Card 166: 59 36 88 19 99 93 81 53 62 30 | 12 88 36 85 4 22 55 96 68 63 83 15 14 40 93 81 97 9 75 6 94 5 44 31 23
|
1694669826 1109156887 7780967
|
||||||
Card 167: 34 22 98 78 19 30 6 88 53 41 | 7 26 47 84 22 30 99 73 93 98 90 89 6 54 18 72 74 41 69 9 39 44 32 59 70
|
0 231346900 222429954
|
||||||
Card 168: 32 31 53 65 64 85 36 19 95 12 | 82 60 69 84 55 76 30 83 14 81 35 57 59 4 72 40 15 97 47 92 11 39 50 8 38
|
1856022817 1686715664 1854240542
|
||||||
Card 169: 58 66 14 82 42 97 86 64 40 57 | 58 64 87 97 89 85 91 66 77 53 86 50 26 13 3 45 14 33 40 11 17 82 99 49 24
|
1588644556 4104587615 106025270
|
||||||
Card 170: 43 68 96 70 98 14 63 53 29 67 | 17 10 29 46 78 75 38 41 50 37 5 92 74 26 83 1 33 71 67 88 87 44 25 60 95
|
1109156887 4210612885 84354411
|
||||||
Card 171: 85 86 81 15 67 50 52 92 72 30 | 23 52 3 12 57 35 83 84 54 97 43 18 1 8 86 6 67 92 51 93 15 91 55 47 7
|
4273894768 1155656956 21072528
|
||||||
Card 172: 25 15 48 85 17 51 36 27 88 18 | 37 23 48 55 16 42 20 64 95 75 78 28 98 74 68 97 58 45 26 14 57 46 3 90 62
|
1232230400 1330301508 356414156
|
||||||
Card 173: 85 61 27 99 65 24 43 13 33 71 | 44 23 32 84 80 65 68 18 72 69 99 55 13 33 89 62 24 43 59 7 19 83 85 79 56
|
|
||||||
Card 174: 28 24 96 72 92 30 10 55 87 2 | 53 96 75 62 44 33 5 79 50 23 55 87 26 47 13 28 41 39 52 42 14 7 16 71 86
|
|
||||||
Card 175: 27 55 99 66 20 68 24 98 82 56 | 87 62 85 15 2 52 50 11 37 93 90 98 57 33 6 20 96 71 66 73 68 80 86 92 39
|
|
||||||
Card 176: 47 1 83 14 21 66 73 87 95 63 | 77 14 94 80 61 88 52 86 24 8 5 69 42 12 78 79 30 60 76 46 55 34 65 9 51
|
|
||||||
Card 177: 98 74 54 15 83 86 64 35 91 19 | 7 64 65 49 18 84 24 12 9 43 86 96 33 15 5 47 13 92 35 70 69 61 40 68 82
|
|
||||||
Card 178: 74 82 22 4 77 79 99 39 11 72 | 90 64 27 44 53 15 19 55 75 43 78 88 93 17 38 41 25 18 20 63 6 82 67 91 24
|
|
||||||
Card 179: 73 67 27 18 86 17 35 2 56 51 | 14 12 75 49 31 52 9 57 43 25 82 32 59 56 40 67 74 24 10 46 66 6 58 13 39
|
|
||||||
Card 180: 71 9 76 19 38 1 23 63 45 89 | 14 20 83 65 88 50 3 16 47 77 48 59 55 98 97 8 53 39 82 73 62 11 4 28 56
|
|
||||||
Card 181: 8 79 95 19 56 64 51 10 92 66 | 29 33 57 77 9 98 90 76 42 89 52 94 47 15 70 78 80 32 71 75 14 93 11 16 4
|
|
||||||
Card 182: 41 13 46 42 45 61 40 70 21 80 | 84 21 69 80 29 25 13 43 45 70 57 99 41 39 50 42 40 46 11 66 61 20 74 75 26
|
|
||||||
Card 183: 78 12 3 97 22 21 53 83 82 75 | 33 21 3 36 42 60 10 56 40 87 88 69 97 65 50 83 12 78 53 22 61 75 25 92 82
|
|
||||||
Card 184: 47 1 26 10 90 17 22 7 49 16 | 10 5 16 53 40 81 1 7 76 26 9 74 49 44 59 56 47 14 82 30 17 22 65 90 15
|
|
||||||
Card 185: 63 5 84 69 73 44 94 86 75 79 | 17 22 98 88 50 93 96 87 38 54 81 6 83 64 99 48 18 82 52 11 4 33 72 37 60
|
|
||||||
Card 186: 37 74 76 3 68 97 55 59 42 23 | 67 47 82 55 53 3 68 13 44 60 62 37 42 63 75 61 93 87 76 51 59 97 84 74 99
|
|
||||||
Card 187: 25 62 26 41 91 55 89 58 90 50 | 43 5 32 26 91 62 89 41 87 94 48 60 58 16 44 24 90 28 11 10 66 50 85 55 25
|
|
||||||
Card 188: 82 46 29 70 17 49 31 71 61 42 | 80 3 7 66 87 71 82 21 99 67 29 96 5 31 13 17 69 47 32 42 46 92 70 22 49
|
|
||||||
Card 189: 68 86 63 6 56 55 53 87 18 4 | 9 74 53 90 20 73 26 86 76 79 91 63 92 50 6 4 68 35 56 48 21 46 44 62 80
|
|
||||||
Card 190: 85 16 79 27 67 93 66 90 14 15 | 27 84 99 16 40 55 97 95 89 38 28 46 88 13 63 60 96 92 30 6 2 64 43 69 10
|
|
||||||
Card 191: 61 69 58 10 63 29 92 70 57 65 | 88 79 86 89 75 52 92 70 25 26 73 71 29 10 93 57 7 58 51 84 8 67 21 85 5
|
|
||||||
Card 192: 57 33 7 82 64 81 61 23 58 12 | 80 58 81 82 75 50 92 33 20 95 61 53 56 40 19 62 13 79 57 73 60 18 54 85 8
|
|
||||||
Card 193: 3 19 86 33 83 58 27 68 53 96 | 72 33 51 93 1 81 25 68 85 37 73 63 27 4 65 60 6 79 17 43 36 41 3 67 28
|
|
||||||
Card 194: 54 33 59 27 9 25 69 80 48 37 | 37 86 38 79 44 48 57 84 5 73 20 4 31 85 2 25 19 33 61 32 89 91 76 72 45
|
|
||||||
Card 195: 63 23 43 87 14 85 82 46 19 54 | 91 19 79 59 56 67 6 20 70 26 37 63 53 32 42 18 46 17 35 94 69 84 96 72 13
|
|
||||||
Card 196: 11 86 29 39 65 76 95 40 26 98 | 51 88 69 75 46 79 37 14 48 43 41 70 64 58 55 95 6 26 60 80 17 85 8 57 38
|
|
||||||
Card 197: 94 22 97 6 26 74 51 90 9 45 | 72 63 80 58 59 64 81 96 24 91 69 82 29 86 47 35 76 27 4 38 36 42 67 62 93
|
|
||||||
Card 198: 76 46 7 94 90 2 95 25 29 26 | 17 13 62 43 24 4 56 30 5 20 65 40 10 45 91 15 9 93 73 53 42 68 75 55 51
|
|
||||||
|
|
123
src/main.rs
123
src/main.rs
|
@ -1,48 +1,95 @@
|
||||||
use anyhow::Result;
|
use std::{collections::HashMap, io::stdin};
|
||||||
use std::{collections::HashSet, io::stdin};
|
|
||||||
|
|
||||||
struct Row {
|
use anyhow::Result;
|
||||||
cards: usize,
|
use regex::Regex;
|
||||||
matches: usize,
|
//
|
||||||
|
// #[derive(Debug)]
|
||||||
|
// struct Seed(i64);
|
||||||
|
//
|
||||||
|
// #[derive(Debug)]
|
||||||
|
// struct Soil(i64);
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Map {
|
||||||
|
ranges: Vec<(i64, i64, i64)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Map {
|
||||||
|
fn new() -> Map {
|
||||||
|
Map { ranges: vec![] }
|
||||||
|
}
|
||||||
|
fn add_range(&mut self, range: (i64, i64, i64)) {
|
||||||
|
self.ranges.push(range);
|
||||||
|
}
|
||||||
|
fn map(&self, value: i64) -> i64 {
|
||||||
|
for (to, from, len) in &self.ranges {
|
||||||
|
if value >= *from && value < (from + len) {
|
||||||
|
return to + (value - from);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// impl Seed {
|
||||||
|
// fn to_soil(self) -> Soil {
|
||||||
|
// Soil(seed_to_soil
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// type RangeMap = Vec<(i64, i64, i64)>;
|
||||||
|
|
||||||
fn main() -> Result<()> {
|
fn main() -> Result<()> {
|
||||||
let mut sum = 0;
|
let mut maps: HashMap<String, Map> = HashMap::new();
|
||||||
|
let numbers = Regex::new(r"(\d+)")?;
|
||||||
|
let mut current_map = String::new();
|
||||||
|
let mut seeds: Vec<i64> = vec![];
|
||||||
|
|
||||||
let mut rows = vec![];
|
|
||||||
for line in stdin().lines().map_while(Result::ok) {
|
for line in stdin().lines().map_while(Result::ok) {
|
||||||
let p: Vec<_> = line.split(':').collect();
|
if line.starts_with("seeds:") {
|
||||||
let nums: Vec<_> = p[1].split('|').collect();
|
seeds = numbers
|
||||||
|
.captures_iter(&line)
|
||||||
let winning: HashSet<i32> = nums[0]
|
.map(|c| c.get(1).unwrap().as_str().parse())
|
||||||
.split_whitespace()
|
.map_while(Result::ok)
|
||||||
.map(str::parse)
|
.collect();
|
||||||
.map_while(Result::ok)
|
} else if line.ends_with(" map:") {
|
||||||
.collect();
|
current_map = line
|
||||||
|
.split_whitespace()
|
||||||
let mine: HashSet<i32> = nums[1]
|
.next()
|
||||||
.split_whitespace()
|
.unwrap_or_default()
|
||||||
.map(str::parse)
|
.to_owned();
|
||||||
.map_while(Result::ok)
|
} else {
|
||||||
.collect();
|
let nums: Vec<i64> = numbers
|
||||||
|
.captures_iter(&line)
|
||||||
let both = winning.intersection(&mine);
|
.map(|c| c.get(1).unwrap().as_str().parse())
|
||||||
let c = both.count();
|
.map_while(Result::ok)
|
||||||
rows.push(Row {
|
.collect();
|
||||||
cards: 1,
|
if nums.len() == 3 {
|
||||||
matches: c,
|
let map = maps.entry(current_map.clone()).or_insert_with(Map::new);
|
||||||
});
|
map.add_range((nums[0], nums[1], nums[2]));
|
||||||
}
|
}
|
||||||
for i in 0..rows.len() {
|
|
||||||
// let row = &rows[i];
|
|
||||||
let (front, back) = rows.split_at_mut(i + 1);
|
|
||||||
let row = front.last().unwrap();
|
|
||||||
for r in back.iter_mut().take(row.matches) {
|
|
||||||
r.cards += row.cards;
|
|
||||||
}
|
}
|
||||||
sum += row.cards;
|
|
||||||
}
|
}
|
||||||
|
let map_names = [
|
||||||
println!("{sum}");
|
"seed-to-soil",
|
||||||
|
"soil-to-fertilizer",
|
||||||
|
"fertilizer-to-water",
|
||||||
|
"water-to-light",
|
||||||
|
"light-to-temperature",
|
||||||
|
"temperature-to-humidity",
|
||||||
|
"humidity-to-location",
|
||||||
|
];
|
||||||
|
let mut locations = vec![];
|
||||||
|
for seed in &seeds {
|
||||||
|
let mut step = *seed;
|
||||||
|
for map_name in map_names {
|
||||||
|
let mapped = maps.get(map_name).unwrap().map(step);
|
||||||
|
println!("mapped {step} using {map_name} to {mapped}");
|
||||||
|
step = mapped;
|
||||||
|
}
|
||||||
|
locations.push(step);
|
||||||
|
println!();
|
||||||
|
}
|
||||||
|
println!("{}", locations.iter().min().unwrap());
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue