From 68d575c53875a66c499ba9e0b12959f8589e3752 Mon Sep 17 00:00:00 2001 From: Joey Pollack Date: Tue, 10 Dec 2024 16:22:40 -0500 Subject: [PATCH] Adds settings to the program that can be specified with command line args --- crates/day_1/src/day_1.rs | 10 - crates/day_2/src/day_2.rs | 5 - crates/day_3/src/day_3.rs | 4 - crates/day_4/src/day_4.rs | 5 - crates/day_5/src/day_5.rs | 5 - crates/day_6/src/day_6.rs | 5 - crates/day_7/data/day7_input | 850 ++++++++++++++++++++++++++ crates/day_7/data/day7_test_input | 9 + crates/day_7/src/day_7.rs | 31 +- crates/day_7/src/equation.rs | 61 ++ crates/day_7/src/lib.rs | 4 +- crates/day_8/src/day_8.rs | 5 - crates/solver_base/src/solver_base.rs | 6 - src/main.rs | 140 ++--- src/settings.rs | 90 +++ 15 files changed, 1087 insertions(+), 143 deletions(-) create mode 100644 crates/day_7/src/equation.rs create mode 100644 src/settings.rs diff --git a/crates/day_1/src/day_1.rs b/crates/day_1/src/day_1.rs index 561490e..b33865b 100644 --- a/crates/day_1/src/day_1.rs +++ b/crates/day_1/src/day_1.rs @@ -104,16 +104,6 @@ impl Day1 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| impl Solver for Day1 { - fn print_test() - { - println!("DAY 1 TEST PRINT"); - // solver_base::print_test(); - - let dir = utils::get_working_dir(); - let data = utils::load_data(&format!("{}/data/TESTING", dir)); - println!("DATA: {}", data); - } - fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool) { self.data_set = data_set; diff --git a/crates/day_2/src/day_2.rs b/crates/day_2/src/day_2.rs index 8a87114..12753d3 100644 --- a/crates/day_2/src/day_2.rs +++ b/crates/day_2/src/day_2.rs @@ -46,11 +46,6 @@ impl Day2 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| impl Solver for Day2 { - fn print_test() - { - println!("DAY 2 TEST PRINT"); - } - fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool) { self.data_set = data_set; diff --git a/crates/day_3/src/day_3.rs b/crates/day_3/src/day_3.rs index f86aab9..c3042f9 100644 --- a/crates/day_3/src/day_3.rs +++ b/crates/day_3/src/day_3.rs @@ -93,10 +93,6 @@ impl Day3 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| impl Solver for Day3 { - fn print_test() - { - println!("DAY 3 TEST PRINT"); - } fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool) { diff --git a/crates/day_4/src/day_4.rs b/crates/day_4/src/day_4.rs index 5bf634f..0e8e70c 100644 --- a/crates/day_4/src/day_4.rs +++ b/crates/day_4/src/day_4.rs @@ -66,11 +66,6 @@ impl Day4 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| impl Solver for Day4 { - fn print_test() - { - println!("DAY 4 TEST PRINT"); - } - fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool) { self.data_set = data_set; diff --git a/crates/day_5/src/day_5.rs b/crates/day_5/src/day_5.rs index eda772b..e24afea 100644 --- a/crates/day_5/src/day_5.rs +++ b/crates/day_5/src/day_5.rs @@ -115,11 +115,6 @@ impl Day5 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| impl Solver for Day5 { - fn print_test() - { - println!("DAY 5 TEST PRINT"); - } - fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool) { self.data_set = data_set; diff --git a/crates/day_6/src/day_6.rs b/crates/day_6/src/day_6.rs index b969f14..53ec4d6 100644 --- a/crates/day_6/src/day_6.rs +++ b/crates/day_6/src/day_6.rs @@ -175,11 +175,6 @@ impl Day6 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| impl Solver for Day6 { - fn print_test() - { - println!("DAY 6 TEST PRINT"); - } - fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool) { self.data_set = data_set; diff --git a/crates/day_7/data/day7_input b/crates/day_7/data/day7_input index e69de29..1a5eac8 100644 --- a/crates/day_7/data/day7_input +++ b/crates/day_7/data/day7_input @@ -0,0 +1,850 @@ +2382106471: 2 8 175 1 17 3 5 9 4 51 5 +864708004: 278 22 259 2 12 3 +1659517050: 33 8 9 673 51 967 +5331437: 5 3 305 89 849 +97828: 8 6 6 3 5 70 4 696 5 91 3 +793977: 7 93 977 +21316689: 8 8 3 833 67 22 19 19 +4685569: 3 5 3 9 9 3 4 1 746 951 7 +4635637004: 7 1 9 9 87 8 14 7 8 1 78 9 +367804926120: 9 900 129 43 9 8 57 40 +3977374: 397 7 37 4 +28883667: 640 6 1 9 5 2 7 59 1 6 93 +1219750: 7 614 28 37 5 7 2 +54994: 7 7 5 948 46 +192115489: 6 3 8 47 19 81 887 4 4 8 +434184384002: 916 790 61 8 22 75 8 +263569049: 28 6 4 881 92 +2598922: 4 9 3 5 511 199 94 5 58 +2191959663: 42 9 796 51 63 +11481664: 480 8 9 3 7 21 1 85 34 +4043221: 8 1 7 1 21 77 10 46 8 3 +6479: 7 3 9 3 6 15 3 7 521 7 4 +10772736: 480 47 5 1 2 136 8 249 +10349128: 4 5 58 50 851 95 968 +6780304916: 251 7 5 8 657 64 8 3 8 5 +53712: 123 5 19 84 449 7 +1452950: 203 8 1 40 3 59 2 7 84 2 +2456: 6 57 31 9 494 +2418157349: 7 3 481 8 14 6 9 6 7 349 +5643308: 551 5 128 30 8 +10656439186: 205 8 5 6 1 344 95 189 +63002934: 46 9 37 457 9 +4484073532: 468 7 918 8 735 32 +510325939: 510 3 256 65 274 +9567: 4 4 8 1 5 5 4 8 8 5 3 252 +904: 89 52 2 3 58 +12123: 59 42 4 5 6 +2479191: 5 48 5 7 662 +1193127204: 47 1 8 3 40 84 831 204 +27725: 5 693 30 38 61 +15096938125: 1 953 9 8 55 3 8 9 3 9 4 9 +10093504: 121 4 3 6 3 7 80 6 2 2 1 4 +7926914632: 1 366 70 19 1 829 49 +444: 3 346 10 76 9 +67765762: 909 446 3 5 762 +1480: 4 9 5 5 8 +39223463485: 1 53 779 8 563 95 +52299: 3 2 3 6 844 391 8 6 2 39 +1404: 579 63 410 346 6 +2392535: 7 4 6 6 876 49 35 +174294604359: 2 17 7 1 8 5 460 4 351 6 +30117431713: 939 2 1 69 6 6 7 3 8 4 8 1 +9033780153: 376 4 4 1 2 17 1 1 6 155 +3200: 28 5 9 50 791 309 +1888632: 7 3 115 857 6 3 +2297911: 7 456 41 8 121 +13775832: 61 448 5 21 24 +59732183: 19 9 2 3 1 1 5 256 5 903 +413686: 3 405 2 1 1 2 8 9 4 2 56 7 +2589158: 2 51 46 59 18 3 +6715806: 114 8 3 3 65 4 +1270778040: 7 6 359 169 82 1 16 30 +2346904: 598 4 3 4 98 +282842410: 803 6 995 29 59 9 +29768672665: 465 8 1 8 67 17 9 1 86 8 +27658973736: 76 6 939 769 7 1 5 3 4 +677256: 76 5 94 645 6 5 +86134173: 3 858 335 6 70 +307442: 1 379 4 67 8 506 +43695562: 6 728 40 53 60 2 64 +7027: 6 8 94 625 1 8 4 +78437507851763: 8 1 5 9 1 377 3 85 17 6 1 +4472775: 56 74 449 25 309 +146696940: 464 2 787 35 4 +254597703: 254 59 7 70 3 +110736324793: 782 8 973 72 2 1 4 7 7 3 +1306: 9 1 71 70 34 483 80 +850952602077: 52 11 6 1 6 30 42 81 8 +3980028639: 44 222 534 9 2 577 +61001050: 602 82 6 54 206 275 1 +1386822: 8 5 9 3 3 387 23 2 7 17 3 +66226371125: 580 2 820 58 93 24 5 3 +1290201: 8 82 59 5 8 941 98 +82432532: 342 5 9 36 201 8 5 1 4 +17789: 39 76 6 3 2 +1040129: 628 452 963 91 +1307603831: 3 775 6 4 8 7 3 676 155 +361: 1 19 1 7 9 1 +1257300: 698 5 2 90 +266697: 738 672 63 8 32 29 3 +105897530: 1 1 4 84 5 6 9 1 2 467 30 +2691: 316 92 3 5 636 +47374272: 4 5 2 8 684 1 2 9 85 6 8 +164763: 2 793 61 63 +229255550: 8 506 3 5 176 1 3 1 842 +92931: 838 5 908 4 1 +3542894: 6 69 272 371 1 8 27 1 7 +139994: 1 289 2 24 1 10 778 5 +943431: 86 3 79 750 312 369 +3306471: 89 37 1 502 2 89 3 207 +142824: 91 21 6 362 8 962 44 6 +1039: 82 2 5 5 865 +7893: 7 71 93 +44685: 4 557 5 2 115 +54366742: 4 2 2 88 5 1 361 92 5 45 +3399952319: 4 5 347 63 3 4 4 1 8 24 9 +294382273: 8 957 5 9 61 1 1 22 7 1 1 +1108143400: 634 21 5 5 8 1 5 4 5 4 26 +40828: 7 56 9 7 25 +222726: 1 70 58 5 31 9 662 +101719: 25 5 171 3 5 5 44 38 1 +214620: 8 1 9 97 1 885 15 2 3 84 +50844: 4 4 42 876 38 +261299424: 6 77 2 6 9 472 8 2 1 7 8 3 +557557: 6 929 4 11 7 +27804653: 3 3 1 8 4 251 4 9 9 5 6 54 +5857596: 238 3 2 9 909 +8534: 3 58 79 65 5 41 34 +665908: 85 580 246 633 6 23 +876187: 758 36 82 186 +2219399700: 41 692 25 7 447 +181782: 61 1 6 4 4 1 8 635 2 3 7 +255488: 86 9 3 98 5 +31163581141221: 8 707 847 2 787 7 223 +3527: 1 8 264 70 9 +4724: 79 50 6 674 94 +6911: 427 322 9 2 168 +808818: 5 803 818 +47394124459: 75 82 980 41 487 3 +12589039286: 9 47 58 6 382 84 +140673507285: 694 9 367 53 6 2 86 +32672908: 4 45 2 9 9 29 8 2 6 7 23 8 +350000: 4 43 3 5 2 574 5 4 4 4 25 +2342957505: 9 4 9 178 9 2 5 3 625 4 5 +6044: 854 7 2 1 61 +158331: 53 8 66 3 6 3 69 383 7 +327772555: 793 4 5 411 52 +4682966: 3 991 644 9 7 101 +47838956: 69 277 25 5 559 57 +2689736729299: 3 127 600 848 86 1 9 +12233009: 114 25 807 300 709 +965842527: 5 85 9 9 907 5 6 2 7 4 18 +4698007: 37 3 96 800 7 +16353552803424: 181 706 142 2 9 5 4 24 +10738744938260: 8 3 93 19 3 80 8 2 9 260 +18147746655: 4 272 59 4 8 3 88 5 3 +132272271376: 84 2 9 9 1 9 2 4 650 7 9 6 +13347038: 66 202 14 942 96 +344154833: 344 15 48 1 32 +10305860179: 2 35 24 9 12 1 2 8 71 2 2 +47072953319: 3 3 6 4 841 8 7 8 3 31 9 +3239993322: 6 1 59 99 258 9 +21787920: 3 257 8 7 88 63 5 +111171: 336 716 59 32 41 +236030557: 7 6 5 193 7 5 620 54 1 +228460145: 2 2 900 405 2 52 4 3 3 8 +13623952: 53 86 7 427 90 +28187398: 7 6 36 73 2 7 39 8 +6432594: 6 888 132 38 934 59 4 +138673080: 3 38 1 457 51 7 6 130 +557284: 7 764 220 4 85 +41724160: 3 241 424 6 72 2 3 160 +156298903477: 1 29 4 601 6 3 8 8 3 9 7 +28392: 37 766 2 1 48 +325809: 51 5 1 486 60 6 +4527: 2 2 884 4 903 +159001309: 8 84 24 3 8 9 8 29 1 1 +968240: 852 9 315 4 236 7 4 7 +36744109893516: 7 79 7 978 777 655 16 +43924380837: 6 67 20 730 6 838 +25557120: 40 4 986 9 18 +1475720: 1 40 426 4 790 +364450: 985 74 5 +1143: 17 3 1 6 830 +54915101074: 61 9 150 7 2 34 76 75 +3899380697: 513 4 30 563 19 +2407: 7 8 7 92 46 42 26 +26715014: 52 67 797 223 283 +97504: 8 127 18 60 14 88 +56: 4 7 2 +4629: 479 8 3 783 7 3 +68343456: 387 8 6 612 2 7 3 2 8 1 6 +110400: 5 64 69 5 +21372670957: 3 2 3 3 5 8 4 665 5 95 1 6 +25719048602: 63 8 2 566 32 860 5 +179898: 37 9 9 879 133 4 610 +3441866: 1 921 9 3 614 6 6 8 966 +2902747: 719 8 6 72 55 64 +77968009736: 576 56 651 576 329 8 +72897: 72 53 6 4 303 +15472406400: 7 3 4 124 844 6 80 44 3 +1345456: 6 304 62 8 7 +722223: 13 2 51 398 621 +70342: 2 9 97 9 67 997 +43793: 25 350 1 8 5 +229823428: 6 58 2 8 327 386 9 961 +7196338076: 71 963 377 4 33 6 +494954: 4 949 1 5 5 +519873123: 962 7 28 6 90 +62711: 3 614 2 1 4 6 765 +11360674: 2 23 8 4 578 8 6 2 4 2 7 2 +660611: 220 3 611 +31025296: 5 2 1 62 5 880 452 1 16 +3726521: 547 9 375 6 4 7 6 2 38 5 +2820658563: 2 1 8 172 28 6 585 60 +505002798181: 2 7 4 1 9 4 6 2 1 79 81 81 +4418925051: 2 638 53 950 35 5 1 +1344960: 3 3 28 95 4 6 1 7 8 1 120 +632382: 61 2 2 38 2 +155248: 8 7 4 491 42 717 +60653: 602 48 345 10 47 +96465: 952 926 38 8 5 622 3 +103381077600: 34 91 405 40 457 4 +329843745: 3 34 505 5 8 62 7 245 9 +7427849689: 805 623 6 922 6 91 +13144560: 67 2 46 2 914 30 383 +2632579106: 3 15 9 975 7 910 4 2 +157916575: 113 5 2 442 165 69 4 2 +4856266: 8 2 3 6 59 889 4 130 3 2 +7265904: 726 2 90 589 1 8 +155813832880: 508 6 426 6 3 4 8 70 2 9 +106026: 4 3 62 989 37 +484411322: 484 409 8 15 22 +71005945: 7 2 6 2 7 873 79 5 906 7 +85196329288: 96 741 73 88 87 5 84 4 +199739749: 9 4 378 3 6 49 44 5 913 +12795: 4 3 6 6 9 3 3 6 5 1 262 26 +99982734: 9 9 942 40 734 +29992246: 432 16 61 9 6 770 9 71 +3550470679: 55 3 3 1 145 35 5 6 2 6 7 +22716758: 7 532 62 6 760 +2609347872: 74 4 3 5 30 97 47 8 68 4 +799462: 7 1 10 5 939 1 1 9 1 37 3 +13063184: 513 793 30 74 110 +93981: 8 85 264 6 709 +120995640: 100 9 357 55 621 5 +5775: 600 47 8 564 2 33 +122892215: 221 7 443 7 66 43 172 +5204391192441: 23 829 63 24 91 444 +2212820416: 1 921 790 5 4 854 6 1 6 +354487: 315 39 487 +43092: 3 320 3 1 9 32 8 1 44 4 +18564780: 432 56 5 8 95 7 1 390 +2935: 21 96 608 78 53 +398391: 850 321 5 9 6 4 56 1 7 +82718374: 1 875 436 8 1 6 13 63 6 +25618276: 9 5 7 54 8 30 447 20 8 9 +98824526: 58 823 2 3 4 8 1 260 7 3 +402909: 6 5 6 5 6 4 77 742 9 2 7 3 +3045521379: 5 5 1 60 6 8 981 8 8 9 6 3 +307685: 34 15 1 7 86 62 +244370210080: 2 1 9 2 7 5 46 2 762 60 8 +1628618400: 1 59 41 6 613 3 41 4 9 +4082: 260 148 2 +12494: 4 15 605 7 2 +969825164472: 6 9 3 27 63 181 2 7 4 7 2 +55441039: 2 1 1 10 3 38 93 1 82 2 1 +78866043: 175 75 1 4 9 44 590 60 +790231860: 252 139 376 3 60 +7158: 611 5 73 5 2 895 +3078562: 77 7 243 3 18 562 +183: 1 84 6 90 3 +56832: 9 4 1 31 4 443 13 63 +9241601: 3 4 2 8 5 758 7 8 5 92 7 8 +2477793: 91 7 7 27 6 +800: 731 1 70 +3668: 1 516 1 7 1 7 +13970886505: 1 527 21 21 2 3 650 5 +39158484: 5 2 2 9 1 9 9 35 3 8 8 1 +87177878: 4 481 985 6 7 46 842 +1606229402: 7 2 2 1 2 89 6 83 4 2 4 5 +24206: 59 8 44 712 4 608 3 +14549474087: 812 6 6 807 88 3 14 71 +13198077: 8 29 71 5 801 +8875: 9 78 9 8 3 +4939350532: 899 224 584 42 4 +100624848: 4 1 1 927 24 47 +1741852416: 9 9 414 192 7 9 471 1 3 +10746410: 3 579 7 3 6 25 877 529 +102566584870: 797 228 665 84 870 +59054: 4 5 3 1 2 1 5 4 8 615 84 2 +7521851976: 4 58 6 7 3 7 18 2 9 97 6 +2017562212: 3 306 900 579 61 2 22 +7787807: 8 70 79 22 8 875 692 +768604200286: 9 9 7 8 4 7 2 6 7 546 288 +10425811960: 8 200 5 158 3 7 6 9 2 5 1 +44558: 445 3 9 8 8 +1125577245: 103 4 91 577 2 45 +8702642: 480 486 530 430 9 +152938046168: 1 1 420 1 1 6 2 1 3 93 1 8 +85316867881: 93 749 9 48 998 91 61 +4932186112: 47 94 5 6 87 31 76 512 +4890727626: 8 1 43 6 3 480 5 4 76 26 +40846647639: 1 8 7 9 75 2 56 69 9 38 +16644691821884: 80 254 34 2 61 2 188 4 +1169262232744: 6 43 36 8 9 581 713 2 2 +70897756803: 60 59 9 5 7 36 650 2 1 +284154: 71 667 2 1 6 +330809: 41 35 8 4 3 +292483: 3 289 442 44 +332021340: 7 2 434 6 64 5 1 505 18 +146119654121: 5 8 6 769 959 5 5 9 120 +716791244: 28 43 65 69 222 2 43 +513: 6 3 6 8 2 76 +4794148800: 56 64 1 796 30 7 8 +17724842721: 86 71 6 58 32 53 4 4 5 +25567104: 3 3 404 9 2 229 1 4 834 +163916412: 81 958 2 3 3 8 1 +2005947358: 4 199 1 8 51 698 70 58 +1119093: 600 149 166 9 17 2 68 +5570055: 905 7 615 +100688778420: 7 974 8 2 1 71 2 26 9 8 +57006220461: 42 9 7 7 11 40 4 7 7 993 +6849446638058: 8 5 8 4 9 43 1 6 6 3 805 8 +53856346840: 1 373 5 8 60 6 34 6 840 +602355314: 5 7 2 247 95 55 3 14 +39749060736: 549 5 527 58 496 3 22 +110378485252: 9 219 7 305 8 45 252 +18932659200: 27 392 832 430 5 +33830576258: 61 1 29 99 62 29 665 +193410683: 307 90 7 68 5 +10574422880: 7 8 6 44 7 38 1 5 4 2 652 +129319250: 7 3 9 4 19 89 437 7 5 5 +222639: 171 1 26 13 1 +9960: 199 2 5 +1308740360516: 2 9 9 34 4 407 162 19 6 +1095: 20 87 9 6 9 +101223: 34 1 6 1 3 489 +1859305: 6 6 4 24 1 5 5 610 7 5 7 7 +1220: 73 89 32 3 638 +406644: 66 884 889 6 6 +450: 4 1 5 5 9 2 +1131489584: 527 357 97 349 62 +24634747414: 53 34 9 81 1 6 8 4 31 7 +16840835: 1 306 197 55 +36636316: 516 1 71 282 32 +11295907: 81 33 8 1 8 7 62 66 7 66 +13442379: 1 134 33 9 379 +21663601: 2 8 2 94 8 24 7 8 3 6 4 1 +4302636648: 2 5 938 444 542 +1710: 1 7 34 7 630 8 11 816 +241818720: 7 6 2 813 52 130 +826: 7 5 66 9 25 +59959680882: 20 5 43 34 226 68 882 +418672800: 5 90 923 21 48 +639344166: 5 8 8 53 9 31 91 24 42 6 +32138504: 6 14 3 61 52 16 87 3 8 +67979828: 81 711 153 561 1 92 +352414666503: 902 1 6 2 5 2 3 50 65 6 +4399: 2 1 484 9 25 +1713: 16 2 7 78 8 +14519177491: 3 60 82 191 77 483 7 2 +2719929059011: 3 4 8 4 627 679 9 7 5 11 +10035194832: 27 10 57 4 767 8 86 9 +11773248: 79 776 15 3 16 4 +113944583: 9 6 13 85 886 552 +948264845: 2 8 8 2 92 76 7 2 73 27 1 +2076882060: 451 3 92 355 47 +2868648771: 89 366 321 9 8 1 +2059532: 29 71 532 +41760: 471 9 87 +95914368903131: 5 8 54 528 58 903 128 +8043173: 1 175 7 2 51 4 6 8 3 8 8 5 +106498366: 46 4 523 26 11 5 579 +8766468: 2 279 67 3 9 933 +1340432800: 4 78 9 72 583 91 944 7 +642602747: 68 9 105 2 746 +23243449641: 61 344 9 692 50 8 9 4 5 +41810204: 925 565 9 8 132 +2226842795: 38 5 51 924 27 95 +51405379: 7 5 18 9 237 79 +5465120639: 8 7 9 391 8 1 572 160 7 +420135471: 59 77 69 4 4 7 7 9 71 +2064: 1 5 7 8 48 1 3 489 98 3 +8265915: 8 3 363 864 3 6 9 8 4 9 7 +48374427462: 48 374 36 6 74 62 +3919248: 30 12 39 868 233 15 +189697: 1 17 96 97 1 +593: 7 1 6 1 550 +577278: 81 74 310 9 32 2 31 1 6 +13371886716: 111 8 1 41 6 92 1 4 599 +70490: 516 945 548 5 35 +16407296395: 91 3 453 1 9 9 3 1 8 6 5 5 +2128: 245 8 6 8 59 +7811160: 5 7 78 7 5 19 7 79 8 7 5 +74518417: 6 4 525 2 354 2 +1412313084: 720 3 121 1 27 3 78 98 +189454: 9 25 557 7 3 +4302649: 1 4 302 1 649 +1065548: 169 8 1 602 8 +1815864: 210 5 92 623 89 +233: 4 2 14 2 9 +130288519: 1 35 6 6 6 87 74 7 5 704 +1095026362: 2 22 8 8 1 41 6 2 632 4 4 +24530: 272 8 251 26 3 +96373560: 5 8 8 1 28 6 99 6 5 4 586 +514746: 58 37 7 94 9 5 +321316936042: 8 184 72 665 2 820 +529243: 3 5 3 443 2 2 8 2 3 3 8 1 +451021279: 22 7 972 6 1 8 4 20 8 5 +78223043013: 2 75 4 14 743 4 5 9 92 3 +1326967: 176 6 4 2 314 +73457: 451 54 58 74 3 +663133248: 805 8 112 7 20 46 11 6 +1992: 3 83 35 78 2 +66363: 499 11 4 9 2 51 2 7 3 9 3 +55912238: 44 6 4 8 39 7 2 32 5 8 +851316: 1 52 7 7 8 14 5 9 3 56 4 +23923291: 7 4 7 8 6 7 7 3 2 3 7 149 +415982: 50 6 821 469 87 +181474129: 28 3 54 8 532 4 +21509522: 796 1 692 39 86 +1542870: 9 2 73 9 44 6 76 6 9 2 79 +462781908: 2 95 477 7 65 19 908 +6357277: 635 7 2 7 7 +11394264207: 9 1 2 2 8 8 12 5 2 626 9 +504918: 35 798 51 61 9 6 3 +104004: 3 9 9 4 6 3 79 42 6 81 +1438551730: 6 1 4 5 493 794 7 68 7 5 +24129135: 4 7 45 459 72 2 6 813 5 +45117: 5 39 4 86 885 9 +102822123: 96 3 49 7 501 29 130 3 +11742805285: 7 478 3 87 983 50 6 41 +19568477: 7 7 9 80 314 +111798714: 185 9 1 1 42 6 715 +279043: 3 9 8 883 160 +1571547520: 183 943 128 5 1 2 91 +2677994: 2 6 8 579 478 5 6 1 37 8 +9227859: 2 812 370 29 1 62 +196588: 7 28 588 +135241: 2 4 2 1 16 705 8 20 653 +812738: 4 9 69 906 56 +1285797: 64 41 4 8 60 30 +8561: 664 3 734 5 6 2 6 1 67 9 +224773401: 494 65 4 84 1 7 7 2 4 +201633635: 9 91 5 4 234 7 272 6 7 5 +13042: 18 56 771 3 7 549 19 1 +87178848: 6 407 4 7 7 3 8 2 12 7 1 8 +56420: 70 12 67 138 3 +162010: 174 8 59 7 564 8 5 245 +26124280: 5 1 25 1 1 745 8 8 8 65 7 +1802352998: 97 832 669 29 10 88 +14052030: 16 5 1 318 1 85 +17729792956: 55 637 57 256 958 +444692850: 2 5 6 671 58 10 50 +27716779450095: 70 29 93 61 9 9 54 424 +224: 93 7 2 71 49 +7482947: 74 72 41 332 3 +51198618: 511 985 3 8 80 +4856166045: 72 15 33 67 604 6 +247908: 43 298 727 1 +93451256967: 202 45 8 584 577 +32938: 409 80 114 6 98 +1124430: 84 778 4 7 16 185 +666284021: 4 134 1 23 3 2 482 +210: 96 4 27 8 2 73 3 +745115: 6 3 763 8 7 3 6 3 2 3 8 3 +3571500: 293 1 23 75 8 24 3 5 6 5 +47567487: 521 913 96 9 82 +881: 39 6 834 +184768137: 196 576 277 8 2 8 6 9 9 +21447437: 53 562 48 8 59 4 +151: 5 3 7 59 5 +57226632: 26 9 5 1 1 4 6 135 7 9 2 2 +16420444: 694 845 2 7 5 7 4 2 4 6 +135227400: 4 390 4 44 13 3 28 70 +1013755384: 2 39 4 84 8 87 769 2 1 3 +837265: 973 86 47 6 9 +41441224385: 5 92 58 3 9 777 70 86 +27946032: 5 71 32 4 478 6 60 4 +770843706: 3 44 164 43 700 9 +49201035471: 4 9 9 7 4 470 7 64 5 1 7 3 +79176576: 6 29 19 381 2 447 384 +1852556199: 6 6 9 400 7 45 821 619 +784044: 3 9 99 7 355 1 341 29 3 +423915030: 1 930 7 605 747 +765587: 989 86 9 29 70 +3431160: 18 45 47 79 40 +2382693: 3 763 4 932 77 16 +318748: 83 960 6 1 4 +78598: 8 7 9 6 4 237 +1442683947: 1 83 1 2 67 4 98 5 1 5 6 8 +84778: 35 3 4 3 8 5 2 9 9 4 862 +80836937189: 808 36 9 37 189 +29686: 3 9 94 6 761 34 4 +25121: 66 2 12 91 7 5 1 1 3 443 +4703227: 98 6 10 477 7 +129456: 88 98 696 +24507563: 122 5 378 2 6 +132300: 9 981 585 4 21 +786436674: 7 304 313 344 376 10 +23878345: 340 46 62 7 27 45 +1541257896781: 2 94 2 6 5 7 237 8 77 1 2 +939743424968: 32 4 4 62 53 331 6 967 +12994270624: 456 28 33 7 771 9 8 2 4 +2216978: 61 6 5 51 7 8 +2632086: 3 9 30 453 62 +1305247507866: 951 250 549 786 6 +5558039228140: 27 579 772 8 415 916 +78465024: 94 66 1 327 7 7 +1020957: 640 8 459 3 61 +306346: 143 4 6 2 346 +5411863: 76 989 8 9 55 +55768146: 2 6 9 3 136 95 39 3 2 64 +33853869: 5 3 2 5 79 2 35 1 8 9 2 43 +940006483: 7 462 9 3 4 3 3 2 46 1 8 5 +823472: 9 693 33 47 4 +26877509: 984 2 2 8 15 6 91 37 76 +299845192543: 9 7 75 966 541 9 4 4 32 +2874357: 2 873 88 9 469 +6259326: 1 4 149 3 2 10 5 8 7 2 3 1 +1278404772: 3 50 836 3 3 359 5 771 +32898288688: 6 7 5 7 8 78 830 43 44 2 +316858277005: 89 281 390 88 91 +63808504: 410 7 3 51 7 506 +28682400: 5 624 170 30 +19535400065302: 6 665 2 6 8 82 513 408 +105964: 58 92 241 19 2 +44720: 236 71 534 53 90 57 +205616020: 1 42 25 8 9 413 8 2 1 7 +51303616: 4 96 2 6 694 4 92 52 +389719: 7 631 4 994 74 1 71 +76537800303: 914 33 3 7 9 1 2 62 75 5 +469983: 9 2 85 60 2 781 +2206749785: 2 3 6 60 6 1 8 492 93 32 +224859: 775 29 9 1 8 8 5 +41440: 53 4 1 819 5 2 5 6 1 1 5 8 +73731: 7 37 30 1 +209155322: 9 7 49 4 42 88 44 +790791330: 209 2 9 365 42 +502018: 9 4 80 2 24 15 6 7 1 891 +1444487651: 3 8 7 5 533 5 7 59 4 9 2 7 +206016: 3 60 3 18 7 70 5 6 210 +42825391: 86 482 915 7 2 6 97 7 +15829590: 87 65 7 3 86 +2509682: 6 24 351 3 845 2 1 30 2 +18952011194: 472 1 7 98 4 3 5 56 192 +3594: 6 7 66 9 3 +81585126: 518 5 10 3 6 7 3 5 1 2 8 5 +266191435: 843 5 39 3 908 6 25 8 +271040640: 55 56 9 513 4 96 2 +54308170: 4 189 733 1 16 98 +920928869723: 9 2 4 5 9 284 4 6 9 72 3 +198549731: 8 6 32 597 23 +101824: 11 6 57 2 6 83 943 37 8 +8884715: 8 884 7 1 4 +457281742: 6 76 4 9 8 915 7 1 6 4 +6702915212: 83 95 655 67 2 604 85 +6360: 6 5 13 2 4 6 523 19 3 3 9 +129923057: 5 270 916 805 6 3 3 7 5 +33892951: 2 2 1 708 68 7 17 2 3 1 +1585100: 7 9 65 952 9 13 +52753974084: 422 7 8 62 3 39 8 5 8 2 +25964745: 74 246 81 44 745 +36861636905: 585 9 88 7 8 4 35 690 5 +2362255009614: 9 1 2 103 482 3 2 2 8 12 +49390879269: 6 5 1 9 6 52 217 3 1 8 4 6 +415179: 7 593 79 +243453913895: 2 5 35 3 9 756 52 3 6 95 +84330367: 7 2 7 5 6 50 8 8 8 6 889 6 +80506: 20 401 25 1 53 +124145392: 781 7 50 98 454 +8019216039: 1 250 13 787 3 304 42 +5654404: 6 3 8 94 720 7 8 76 1 4 +217229865: 9 5 488 9 4 309 8 393 +9131139: 91 3 1 133 6 +16337908: 3 784 31 25 32 7 20 +93617370380301: 900 6 7 9 55 1 3 802 98 +24808750: 8 61 5 8 6 5 796 7 50 +490769: 199 656 2 7 41 +19604449: 27 60 60 59 71 +2351166: 4 7 64 8 7 6 9 5 1 60 6 6 +12195460: 33 5 5 79 8 5 8 446 8 36 +6310362: 39 73 57 181 4 956 3 6 +172500568: 1 4 375 12 219 349 +20803420: 94 447 11 99 9 5 56 +30560370792: 969 7 8 5 9 66 82 73 9 1 +3144694409: 502 15 17 71 346 749 +23789: 3 8 626 +20738281: 7 6 8 28 2 1 9 6 3 69 87 4 +114054736: 7 9 6 5 1 4 5 4 741 4 4 +8070104014: 6 1 68 400 173 5 7 2 7 +614594760: 6 145 946 39 74 47 +1509840: 1 6 3 2 6 9 10 932 +6801552028: 12 3 2 80 511 382 8 +459858: 89 50 35 33 6 +142040: 332 58 52 7 80 +3568670: 739 672 843 3 251 +527695321: 76 656 91 72 59 63 +6686761316: 7 7 9 97 7 7 15 8 3 48 65 +373266432: 3 93 4 5 4 9 9 399 924 +119359145: 522 8 96 4 53 4 7 8 8 3 6 +700767359: 9 67 9 8 626 917 562 4 +1082: 369 8 702 3 +92393352: 541 99 472 5 1 342 +362200: 7 832 618 605 40 +756120031: 45 42 1 2 7 2 8 5 3 4 621 +5392380452: 6 12 9 7 33 83 5 36 4 4 9 +157537017: 4 8 583 9 5 2 8 3 3 879 +611908798: 611 90 8 757 41 +49743145472: 8 1 202 8 768 304 +31903556450: 4 325 87 1 11 150 23 +2199500: 63 3 2 5 332 +1335737933429: 538 6 5 2 62 8 9 4 421 8 +743: 264 37 123 312 7 +2887981: 4 9 8 23 8 18 381 9 7 4 8 +5975724: 426 81 28 25 5 4 255 +4349020: 4 2 363 5 52 +39502: 43 9 294 363 1 9 12 4 +6405181: 190 51 661 83 8 +22325: 1 507 142 159 84 5 5 +50405902545: 5 27 9 233 94 54 7 +9214855346: 6 9 5 3 6 6 3 1 599 48 47 +811965609: 338 8 3 4 66 6 5 6 2 1 5 2 +112628897172: 6 5 5 873 351 972 +1046045156749: 115 8 5 70 22 285 550 +51844946: 857 7 6 49 46 +947297: 944 7 2 6 17 1 97 +1642568940: 7 550 976 265 1 4 755 +11951: 1 6 1 4 90 42 457 82 17 +346365: 65 46 8 7 387 +17294: 7 2 2 4 7 7 4 1 5 16 2 4 +50817065: 7 7 1 6 1 659 20 13 51 2 +6936871: 6 5 5 35 8 9 7 90 5 9 4 55 +1849: 7 22 63 1 2 20 +46902240849: 6 6 5 6 8 28 4 5 9 6 850 1 +19692: 1 5 32 517 46 +121552241: 2 9 3 32 58 33 1 6 45 4 1 +3418120: 8 9 349 1 9 7 9 17 9 3 4 +5096: 49 2 76 674 6 290 +638583: 904 8 7 9 2 92 +37134900699: 8 94 4 2 5 88 6 93 3 66 8 +882119: 58 325 5 3 23 +2838786315264: 1 84 8 1 681 7 4 4 1 384 +1694: 1 235 7 7 +18374557453: 232 80 159 990 43 +552737250: 62 22 9 37 668 450 +2346364517: 2 237 492 989 315 1 5 +2449020339: 55 175 7 1 131 1 9 81 +132492993: 1 9 96 437 60 3 248 4 +517206480: 2 37 21 4 329 3 6 4 81 +473310931: 466 5 890 6 19 1 5 29 +107583: 17 914 7 6 57 +304: 1 3 22 51 4 +8558484199: 434 4 493 4 196 +50007: 493 63 7 637 +5350718: 5 4 5 54 7 1 4 8 426 5 1 5 +40593642127: 46 895 34 763 29 +112068162: 83 3 7 517 186 +20856819: 695 227 3 9 +392502: 377 9 81 569 2 +207879427: 5 228 1 182 1 3 7 24 6 7 +932646834: 9 3 18 1 7 9 820 7 8 3 2 1 +35246640: 8 259 9 40 44 195 13 +1115016497: 4 7 7 759 6 2 29 68 9 1 7 +613685333186: 85 18 573 3 3 324 7 2 7 +13724: 6 4 9 2 70 54 6 380 +406583095911: 60 564 480 7 2 6 1 999 +81: 1 4 1 8 57 2 9 +30438: 2 9 9 38 1 8 8 4 138 8 70 +1970156520: 458 86 503 85 2 36 +32920930529: 2 944 120 29 16 29 2 9 +59478165882: 60 534 7 816 5 883 +1944162046837: 853 308 6 74 2 4 837 +6309072: 3 1 307 4 4 4 2 5 50 8 7 7 +16086: 402 2 4 +401114: 5 802 2 9 2 +22307418: 7 76 593 8 1 3 600 2 9 +2363683240: 268 6 88 3 2 20 20 +16558: 16 980 628 22 9 8 +145143: 7 7 4 783 5 48 9 2 7 +21429412556: 5 1 51 3 52 5 8 5 5 6 +769: 70 3 54 11 +19372808: 7 30 74 1 15 8 2 92 7 +2877681690: 8 5 2 2 4 4 675 425 8 8 5 +15852963640: 5 592 913 54 758 41 +44352: 1 9 68 4 72 +7649124: 11 752 72 67 47 5 2 4 +4040315368: 8 3 501 10 7 289 39 +128963919283: 469 985 7 3 6 98 4 1 +2089: 2 83 6 8 713 +226651612932: 52 749 8 47 7 4 12 930 +6755: 10 735 1 92 124 3 7 +2821888087200: 7 728 723 75 74 91 +75971046996: 8 4 356 56 3 82 3 3 5 4 6 +1274: 92 419 303 454 5 +444782: 484 61 816 65 +156366: 5 6 18 2 287 812 +193275722808: 74 4 974 647 6 7 6 69 6 +49123022004: 9 79 3 4 60 42 50 8 993 +9757918: 518 147 5 683 127 +9261: 34 54 59 63 +822669876: 3 4 4 84 27 6 4 5 8 7 5 4 +4967: 4 41 10 9 3 20 +127: 43 7 44 33 +78487354: 2 6 971 6 291 +15946118056: 9 41 3 9 2 7 8 2 5 93 9 63 +7980159500: 74 579 561 4 9 4 24 83 +407641: 815 19 4 5 26 +93072830: 89 1 217 84 131 4 694 +599600301: 7 25 97 94 9 2 9 61 4 4 9 +415861205: 97 62 710 6 5 +1793389: 4 592 1 54 30 688 77 4 +5002300: 79 7 83 8 7 94 6 +19547220: 2 86 8 510 22 +111132: 49 88 81 16 2 +99347: 993 4 5 2 1 +9573169: 6 2 2 8 8 841 25 4 2 6 1 8 +68619144557: 65 3 490 129 1 445 60 +321318865: 34 6 45 5 39 35 +594: 3 3 62 2 6 7 2 +55901976918: 799 33 8 470 183 186 +3934709: 2 9 5 638 9 9 6 8 288 5 7 +188647: 41 2 44 736 7 +258096754: 8 6 576 8 4 7 954 4 938 +1730211866: 2 245 1 7 3 1 15 7 61 +184649: 929 6 2 33 348 293 +1707945235: 55 92 633 5 2 4 6 9 2 3 4 +542470680: 47 983 961 80 548 +4386816: 66 9 3 9 8 7 6 6 51 +15242: 97 24 6 12 2 +9655887835: 56 91 8 74 62 783 5 +61323088: 61 3 2 308 7 +207563285: 2 862 8 6 6 7 11 4 7 9 8 5 +558623360: 31 1 49 433 5 82 698 +17732: 6 49 6 4 88 +6900: 2 9 2 62 92 +1244909: 3 5 930 685 34 +17621006887: 6 1 22 80 59 994 4 8 6 8 +5263: 52 1 20 72 7 +432976: 4 6 3 8 6 975 9 17 2 6 9 9 +1060920: 8 1 1 6 51 8 4 429 5 8 7 +56859: 31 27 6 9 3 546 +2337890110: 4 931 54 5 878 +19748726324: 8 6 7 7 4 362 1 1 159 2 6 +3330862922: 50 3 8 8 24 6 69 428 3 2 +11890703: 4 76 2 68 5 74 13 +190830087: 706 77 72 9 27 +183084: 4 90 29 51 45 836 +4378974522972: 7 485 42 6 535 585 +99581876329: 86 13 581 876 329 +35959199: 5 7 77 9 180 196 +6940461987: 771 1 5 9 10 1 1 986 1 +1769: 17 8 190 8 9 31 9 +480805667: 4 37 307 126 122 31 5 +56321318: 473 90 21 269 51 +182676: 94 5 527 26 28 5 3 63 +95290512600: 1 48 941 886 8 5 795 8 +6480095: 591 56 9 738 37 320 +1342904885: 9 2 8 655 56 217 59 8 8 +296056: 4 1 2 4 1 594 7 5 5 8 23 4 +50290953630: 381 2 69 8 239 30 +327571200: 9 273 60 968 20 +772150847148: 9 857 8 50 8 47 142 9 +7896950: 7 868 28 888 62 +407206189229: 5 8 720 613 5 54 1 9 4 2 +14859684: 4 8 4 4 2 614 3 6 60 7 2 6 +3730221: 1 8 21 1 2 4 453 97 24 +42522615: 70 636 235 6 18 +1317: 846 9 430 6 26 +331456603: 27 7 7 5 5 9 124 2 6 5 3 +18671857: 8 2 6 24 8 2 513 6 9 710 +43651194: 4 850 132 9 8 +956: 8 3 2 9 2 2 7 7 38 6 6 563 +1221680: 1 38 2 2 5 3 2 3 9 29 8 59 +225425489452: 16 7 98 250 4 8 9 4 51 +68620392: 9 59 585 35 392 +8305449: 298 7 8 6 1 740 1 9 4 6 9 +47332644807: 4 872 48 5 6 3 824 2 9 3 +2986: 2 6 33 8 6 7 1 37 1 8 601 +7916400: 2 5 45 5 84 2 7 293 20 9 +607324530: 6 482 42 906 5 +83867652: 80 18 108 7 283 9 4 +476676: 5 64 13 967 123 29 6 +67929878: 7 5 47 759 5 9 +591226704: 512 99 6 6 4 6 6 56 9 72 +21653098779: 9 8 5 8 83 6 6 4 1 8 7 79 +115245660: 2 8 3 8 3 4 3 99 1 3 163 8 +1039127928: 298 11 317 1 931 +616377637433: 7 46 1 8 3 91 8 826 30 1 +304871104828: 2 294 1 9 8 8 4 2 7 5 9 25 +4674881518: 2 777 6 8 815 11 6 +6404580000: 45 397 460 36 875 +6070260: 82 1 22 8 9 3 7 6 611 3 +91509075: 957 708 213 76 135 +718184: 11 60 817 7 7 +10793017: 4 9 102 6 34 9 21 7 7 9 +12455: 74 593 485 93 2 +24904022043: 585 426 709 6 3 +1156127845: 5 7 80 62 1 277 4 642 2 +849473: 5 21 1 184 8 +40071: 5 723 7 5 5 +5215364: 49 367 1 29 4 +2331336: 6 1 9 7 65 7 9 7 519 7 3 +118089: 32 977 117 6 26 4 +394864: 3 850 13 85 62 +552506235: 76 56 49 55 417 +93806: 8 31 50 3 8 1 6 2 4 49 5 2 +466758: 38 9 9 3 136 6 +8559759: 1 93 432 9 22 8 2 9 7 5 9 +237429532810: 50 8 1 9 634 740 8 3 6 +13218090: 5 440 2 806 209 6 +253809670: 7 1 25 47 53 751 772 7 +4506180047: 850 7 1 5 9 4 69 525 48 +12060062546: 6 50 67 103 67 57 2 3 4 +11718: 582 6 7 2 52 +2189788764: 3 209 4 3 654 81 7 76 4 +1130742: 9 1 113 743 +338765495: 51 3 2 889 5 6 9 9 7 2 9 5 +692363: 8 65 2 91 4 +43: 3 10 27 3 +2332068280: 365 4 6 658 9 5 8 6 2 80 +5080: 1 50 9 745 6 256 +2298732: 2 47 39 627 75 69 8 +5567998: 200 29 80 3 4 +727991: 92 9 360 1 5 2 27 4 417 +6085890663: 72 97 231 834 6 6 +820731870: 9 906 53 22 1 8 870 +123378298: 25 738 77 57 21 +27539326: 656 7 354 96 29 2 +65229: 440 61 443 69 93 +639396320840: 153 82 99 75 111 413 +410898697: 953 43 110 869 7 +51466: 25 1 2 76 494 81 9 +163097737: 2 7 1 8 5 566 440 8 6 9 2 +99879070: 7 9 216 6 86 611 8 53 2 +4799789342: 5 3 88 614 1 69 9 8 854 +6825076: 84 269 358 6 2 1 9 862 +6390172: 70 998 9 7 20 89 236 +629951300: 47 8 9 483 7 1 569 4 3 8 +108987561: 85 1 6 4 1 9 8 7 4 6 7 147 +15038: 42 68 5 757 4 +3759866880: 264 238 88 8 85 +727507036: 97 1 750 703 6 +526823946: 47 5 5 1 6 18 7 3 512 5 8 +97945447936: 979 43 2 44 793 6 +1720: 217 4 117 702 33 2 +247324388: 3 65 7 45 426 8 3 976 +33214453: 1 376 437 88 +4157865: 54 595 736 954 1 3 +18750438: 3 2 9 2 51 3 5 6 7 882 7 1 +4535685396: 275 77 357 66 6 +1884: 9 2 2 1 178 6 3 416 175 +25551: 80 3 7 45 805 1 +4262304: 400 9 216 2 8 444 48 +197140838: 7 656 97 9 1 884 290 +54511: 66 9 4 1 690 +112209: 220 3 503 7 3 33 +667351380575: 745 644 895 5 73 +108408786: 1 287 2 1 578 4 6 1 5 7 3 \ No newline at end of file diff --git a/crates/day_7/data/day7_test_input b/crates/day_7/data/day7_test_input index e69de29..87b8b25 100644 --- a/crates/day_7/data/day7_test_input +++ b/crates/day_7/data/day7_test_input @@ -0,0 +1,9 @@ +190: 10 19 +3267: 81 40 27 +83: 17 5 +156: 15 6 +7290: 6 8 6 15 +161011: 16 10 13 +192: 17 8 14 +21037: 9 7 18 13 +292: 11 6 16 20 \ No newline at end of file diff --git a/crates/day_7/src/day_7.rs b/crates/day_7/src/day_7.rs index 63d15ac..88ab82a 100644 --- a/crates/day_7/src/day_7.rs +++ b/crates/day_7/src/day_7.rs @@ -11,12 +11,16 @@ use ::solver_base::solver_base::{Solver, DataSet, RunMode}; use utils::utils; +use crate::equation::Equation; + pub struct Day7 { data_set: DataSet, run_mode: RunMode, do_debug_prints: bool, do_verbose_prints: bool, + + equations: Vec, pub final_result: i32, } @@ -33,6 +37,8 @@ impl Day7 run_mode: RunMode::FirstCase, do_debug_prints: false, do_verbose_prints: false, + equations: vec![], + final_result: 0 } } @@ -56,11 +62,6 @@ impl Day7 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| impl Solver for Day7 { - fn print_test() - { - println!("DAY 7 TEST PRINT"); - } - fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool) { self.data_set = data_set; @@ -77,9 +78,25 @@ impl Solver for Day7 DataSet::Full => format!("{}/data/day7_input", dir), }; - let _data = utils::load_data(&data_filename); + let data = utils::load_data(&data_filename); + + let mut split_pattern = "\n"; + if data.contains("\r\n") + { + split_pattern = "\r\n"; + } - // TODO: Day7::init + for line in data.split(split_pattern) + { + let equation = Equation::parse(line); + + if self.do_debug_prints + { + equation.print(); + } + + self.equations.push(equation); + } } diff --git a/crates/day_7/src/equation.rs b/crates/day_7/src/equation.rs new file mode 100644 index 0000000..8886b49 --- /dev/null +++ b/crates/day_7/src/equation.rs @@ -0,0 +1,61 @@ +/****************************************************************************** +* @file equation.rs +* @author Joey Pollack +* @date 2024/12/10 (y/m/d) +* @modified 2024/12/10 (y/m/d) +* @copyright Joseph R Pollack +* @brief Represents one calibration equation +******************************************************************************/ + +#[derive(Copy, Clone, PartialEq, Debug)] +pub enum Operators +{ + Add, + Mult, +} + +#[derive(Clone, Debug)] +pub struct Equation +{ + values: Vec, + result: i64, +} + +impl Equation +{ + pub fn parse(line: &str) -> Equation + { + if !line.contains(":") + { + panic!("ERROR: Failed to parse Equation: line does not contain a colon (:)"); + } + + let mut data_iter = line.split(":"); + + let result = data_iter.next().unwrap().parse::().expect(&format!("Failed to parse result value from data: {}", line)); + + let mut values: Vec = vec![]; + for v in data_iter.next().unwrap().split(" ") + { + if v.is_empty() + { + continue; + } + + values.push(v.parse::().expect(&format!("ERROR: Failed to parse value: {}", v))); + } + + Equation { values, result } + } + + pub fn print(self: &Equation) + { + print!("Equation: {}: ", self.result); + for v in &self.values + { + print!(" {}", v); + } + + println!(); + } +} \ No newline at end of file diff --git a/crates/day_7/src/lib.rs b/crates/day_7/src/lib.rs index 7716c2d..74c9f2e 100644 --- a/crates/day_7/src/lib.rs +++ b/crates/day_7/src/lib.rs @@ -1,2 +1,4 @@ -pub mod day_7; \ No newline at end of file +pub mod day_7; + +pub mod equation; \ No newline at end of file diff --git a/crates/day_8/src/day_8.rs b/crates/day_8/src/day_8.rs index 6f10d43..28a55b3 100644 --- a/crates/day_8/src/day_8.rs +++ b/crates/day_8/src/day_8.rs @@ -55,11 +55,6 @@ impl Day8 //||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| impl Solver for Day8 { - fn print_test() - { - println!("DAY 8 TEST PRINT"); - } - fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool) { self.data_set = data_set; diff --git a/crates/solver_base/src/solver_base.rs b/crates/solver_base/src/solver_base.rs index 507aa05..b5553c8 100644 --- a/crates/solver_base/src/solver_base.rs +++ b/crates/solver_base/src/solver_base.rs @@ -17,12 +17,6 @@ pub enum DataSet pub trait Solver { - - // TODO: Remove this function. Right now it just shows a "static" trait method. - fn print_test() - { - println!("SOLVER BASE PRINT TEST"); - } fn init(self: &mut Self, data_set: DataSet, run_mode: RunMode, enable_debug_prints: bool, enable_verbose_prints: bool); fn solve(self: &mut Self) -> String; diff --git a/src/main.rs b/src/main.rs index 5fb8a19..065cf40 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,8 @@ * @brief Advent of Code 2024 main file ******************************************************************************/ +mod settings; + use day_1::day_1::Day1; use day_2::day_2::Day2; use day_3::day_3::Day3; @@ -15,99 +17,57 @@ use day_5::day_5::Day5; use day_6::day_6::Day6; use day_7::day_7::Day7; use solver_base::solver_base::{Solver, DataSet, RunMode}; +use settings::Settings; fn main() { - // DAY 1 - let mut day_1 = Day1::new(); - day_1.init(DataSet::Full, RunMode::FirstCase, false, false); - let day1_result = day_1.solve(); - println!("Day 1 Part 1 Final Result: {}", day1_result); - - let mut day_1 = Day1::new(); - day_1.init(DataSet::Full, RunMode::SecondCase, false, false); - let day1_result = day_1.solve(); - println!("Day 1 Part 2 Final Result: {}", day1_result); - - println!("-------------------------"); - - - // DAY 2 - let mut day_2 = Day2::new(); - day_2.init(DataSet::Full, RunMode::FirstCase, false, false); - let day2_result = day_2.solve(); - println!("Day 2 Part 1 Final Result: {}", day2_result); - - let mut day_2 = Day2::new(); - day_2.init(DataSet::Full, RunMode::SecondCase, false, false); - let day2_result = day_2.solve(); - println!("Day 2 Part 2 Final Result: {}", day2_result); - - println!("-------------------------"); - - // DAY 3 - let mut day_3 = Day3::new(); - day_3.init(DataSet::Full, RunMode::FirstCase, false, false); - let day3_result = day_3.solve(); - println!("Day 3 Part 1 Final Result: {}", day3_result); - - let mut day_3 = Day3::new(); - day_3.init(DataSet::Full, RunMode::SecondCase, false, false); - let day3_result = day_3.solve(); - println!("Day 3 Part 2 Final Result: {}", day3_result); - - println!("-------------------------"); - - // DAY 4 - let mut day_4 = Day4::new(); - day_4.init(DataSet::Full, RunMode::FirstCase, false, false); - let day4_result = day_4.solve(); - println!("Day 4 Part 1 Final Result: {}", day4_result); - - let mut day_4 = Day4::new(); - day_4.init(DataSet::Full, RunMode::SecondCase, false, false); - let day4_result = day_4.solve(); - println!("Day 4 Part 2 Final Result: {}", day4_result); - - println!("-------------------------"); - - // DAY 5 - let mut day_5 = Day5::new(); - day_5.init(DataSet::Full, RunMode::FirstCase, false, false); - let day5_result = day_5.solve(); - println!("Day 5 Part 1 Final Result: {}", day5_result); - - let mut day_5 = Day5::new(); - day_5.init(DataSet::Full, RunMode::SecondCase, false, false); - let day5_result = day_5.solve(); - println!("Day 5 Part 2 Final Result: {}", day5_result); - - println!("-------------------------"); + const NUM_PROBLEMS: i32 = 7; + let program_settings = Settings::new(); + + for i in 1..=NUM_PROBLEMS + { + if !program_settings.skip_problems_contains(i) + { + let debug = program_settings.debug_problems_contains(i); + let verbose = program_settings.verbose_problems_contains(i); + + let data_set = match debug + { + true => DataSet::Test, + false => DataSet::Full, + }; + + let mut solver = create_problem_solver(i); + solver.init(data_set, RunMode::FirstCase, debug, verbose); + let result = solver.solve(); + println!("Day {} Part 1 Final Result: {}", i, result); - // DAY 6 - let mut day_6 = Day6::new(); - day_6.init(DataSet::Full, RunMode::FirstCase, false, false); - let day6_result = day_6.solve(); - println!("Day 6 Part 1 Final Result: {}", day6_result); - - let mut day_6 = Day6::new(); - day_6.init(DataSet::Full, RunMode::SecondCase, false, false); - let day6_result = day_6.solve(); - println!("Day 6 Part 2 Final Result: {}", day6_result); - - println!("-------------------------"); - - // DAY 7 - let mut day_7 = Day7::new(); - day_7.init(DataSet::Full, RunMode::FirstCase, false, false); - let day7_result = day_7.solve(); - println!("Day 7 Part 1 Final Result: {}", day7_result); - - let mut day_7 = Day7::new(); - day_7.init(DataSet::Full, RunMode::SecondCase, false, false); - let day7_result = day_7.solve(); - println!("Day 7 Part 2 Final Result: {}", day7_result); - - println!("-------------------------"); + solver = create_problem_solver(i); + solver.init(data_set, RunMode::SecondCase, debug, verbose); + let result = solver.solve(); + println!("Day {} Part 2 Final Result: {}", i, result); + } + else + { + println!("Day {} SKIPPING", i); + } + + println!("-------------------------"); + } +} +fn create_problem_solver(day_num: i32) -> Box +{ + match day_num + { + 1 => Box::new(Day1::new()), + 2 => Box::new(Day2::new()), + 3 => Box::new(Day3::new()), + 4 => Box::new(Day4::new()), + 5 => Box::new(Day5::new()), + 6 => Box::new(Day6::new()), + 7 => Box::new(Day7::new()), + + _ => panic!("ERROR in create_problem_solver: Invalid day_num: {}", day_num) + } } diff --git a/src/settings.rs b/src/settings.rs new file mode 100644 index 0000000..07b0291 --- /dev/null +++ b/src/settings.rs @@ -0,0 +1,90 @@ +/****************************************************************************** +* @file settings.rs +* @author Joey Pollack +* @date 2024/12/10 (y/m/d) +* @modified 2024/12/10 (y/m/d) +* @copyright Joseph R Pollack +* @brief Handles the main program settings +******************************************************************************/ + +use std::env; + +pub struct Settings +{ + skip_problems: Vec, + debug_problems: Vec, + verbose_problems: Vec, +} + +impl Settings +{ + pub fn new() -> Settings + { + let args: Vec = env::args().collect(); + let mut last_option = ""; + + let mut skip_problems: Vec = vec![]; + let mut debug_problems: Vec = vec![]; + let mut verbose_problems: Vec = vec![]; + + for arg in args + { + if arg.starts_with("-") + { + // Skip Problems + if arg == "-s" + { + last_option = "s"; + } + + // Set debug output for problems + if arg == "-d" + { + last_option = "d"; + } + + // Set verbose output for problems + if arg == "-v" + { + last_option = "v"; + } + } + else + { + // TODO: Allow for specifying which part of the problem to apply the setting to + // So should be able to only debug day x part y: -d 2.1 will set debug for day 2 part 1 only + + match last_option + { + "s" => skip_problems.push(arg.parse::().expect(&format!("SETTINGS ERROR: Failed to parse -s value: {}", arg))), + "d" => debug_problems.push(arg.parse::().expect(&format!("SETTINGS ERROR: Failed to parse -d value: {}", arg))), + "v" => verbose_problems.push(arg.parse::().expect(&format!("SETTINGS ERROR: Failed to parse -v value: {}", arg))), + "" => (), + + _ => println!("SETTINGS WARNING: Unknown option: {}", last_option), + } + } + } + + Settings { + skip_problems, + debug_problems, + verbose_problems + } + } + + pub fn skip_problems_contains(self: &Settings, prob_num: i32) -> bool + { + self.skip_problems.contains(&prob_num) + } + + pub fn debug_problems_contains(self: &Settings, prob_num: i32) -> bool + { + self.debug_problems.contains(&prob_num) + } + + pub fn verbose_problems_contains(self: &Settings, prob_num: i32) -> bool + { + self.verbose_problems.contains(&prob_num) + } +} \ No newline at end of file