From 39b7dd0e8bd4be1a5c646c254447de5fe8d11186 Mon Sep 17 00:00:00 2001 From: Felix Suchert Date: Sat, 11 Jan 2025 16:28:26 +0100 Subject: [PATCH] Add solutions for day 4 and 5.1 --- inputs/day_4.txt | 141 +++++ inputs/day_5.txt | 1353 ++++++++++++++++++++++++++++++++++++++++ src/main.rs | 4 + src/solutions/day_4.rs | 184 ++++++ src/solutions/day_5.rs | 91 +++ src/solutions/mod.rs | 2 + 6 files changed, 1775 insertions(+) create mode 100644 inputs/day_4.txt create mode 100644 inputs/day_5.txt create mode 100644 src/solutions/day_4.rs create mode 100644 src/solutions/day_5.rs diff --git a/inputs/day_4.txt b/inputs/day_4.txt new file mode 100644 index 0000000..5199c0c --- /dev/null +++ b/inputs/day_4.txt @@ -0,0 +1,141 @@ +XMXMAXXSXSSMMMXAMXMMMAMXMAMXAMSAMXSAMXMXMMMAXXMASMSMSAMXMSMMMAMXMXAMMAMMMXMAMMMMMAMMMMSAMXMMAMXAXMXMAMXSXSMMSMMMMSMMXXAMSMSASAXMMMSMMMSMASMM +MSMSMSMXMMAASAMXMASMMXSSMSSMSMMXXSAMXMXMXMSMMXMMMAAXXAAAMXSSSMAAXSXSMSASXMMSMMAAMAMXMASMSASASXMASMMSMSAMMASXAXAASAAMAMSXMAXAMAMSAXAAMASMAMAM +MAAAAXXAAXXMMMSASASASAAAAAAAAAXSMSAMMMAMAMAAMMMAMMMMMSSXSAMXAMMMMAXSAXAXMMAAASXMMASMMMSXSASAXMSAAXAMAMAXSAMMSMSSSMSMMAAAMMMMMAMMASMSMAXMASAM +XMSMSMSASXMAAAMMMAMAMMSMMMMXMSMAASXMASASXMSMMAMXXAMXAMXMMAXSMMMSAMXMAMSMAMSSMMAMSMSASAMAMAMAMAMSAMXMAMXMMASAMXMAXXXAXXSSMXASXXXSAMXXMAXSMXAS +MMAMXXXAAAMMMSSSMMMXMAXXSXXXSAAMMMXMXSAXMAXASMSMXAMXSSXMSSMXXSXMAXSMXMAMSMAMAMM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XAAAASAMXMMXAMMAMAXMXMMASMMSXMMMSSSMXMXSMAMAMSMSXMASXMSSMMMAAASMSX +SXXSXSSMMAASASMMMSAMAMAMASASAXXAMAMAMSSSMMMSMSAMASXAAMAMXSXSAMAMAXXSASXSASMSXSSMASAMMMAMMXSSSMAMMMMXASMSMMXAXXAXXXAAMMMASAMXAMAAXAXMSSSXSSXM +MAXSAMXXMSAMXSASMMAMXMXMASAMASMMMAMSMMAXMAAAAMAXAMMMSSXMXAAAMMSSXMASXSXMAMXMMMAMAMASASMMSMAAXMAXAXXMMSAAXSMMMSMSMMSXXASXSMSSMSSXXMMMAAXMXMXA +MMMXAMXXAMASXSAMXSSMAMXMAMAMAXAASAXMAMXMSMSSSSSMXSAXMAXSAMXMMAMXMAXMAMXMMSMMASAMXSAMXSAAAMMMMSMSSSMAMMMMXMASAMASAMMMSMSAXMAXMAMAMMAMMSMMSMMM +AAASXMASXSMMAMMMXAXMASAMASAMXSSMSMXSAMMAXAAAAAAAASAXSAXMAXXSMXSAMSAXAXXSAMASMSXSAMXSAMXSXSMXXXXAAAXSMXXXASMMSAASMMAAAAMMMMASMAMAXSAXSAASAAAX +SXXAMMAXMAMMXMXMASASMSASMSXSAMAMXAMSAMXSSMASMSMMMXSAMXSSMMAXSXSASXMSAMXXMMMAMXXMXXSAMXMMMXXMASMMSMMMMSAMXSMAXMASXSMSSSMXXAMMXASMXAMXSASXSSMS + diff --git a/inputs/day_5.txt b/inputs/day_5.txt new file mode 100644 index 0000000..38fc817 --- /dev/null +++ b/inputs/day_5.txt @@ -0,0 +1,1353 @@ +77|76 +22|91 +22|76 +42|25 +42|76 +42|84 +34|25 +34|37 +34|21 +34|82 +21|11 +21|79 +21|77 +21|19 +21|58 +82|98 +82|19 +82|89 +82|85 +82|21 +82|41 +76|81 +76|16 +76|29 +76|25 +76|57 +76|66 +76|45 +29|54 +29|61 +29|78 +29|82 +29|75 +29|98 +29|89 +29|46 +63|42 +63|11 +63|83 +63|57 +63|79 +63|91 +63|22 +63|69 +63|53 +75|49 +75|79 +75|28 +75|77 +75|11 +75|63 +75|22 +75|74 +75|83 +75|71 +35|53 +35|17 +35|12 +35|42 +35|15 +35|41 +35|63 +35|34 +35|31 +35|79 +35|83 +85|99 +85|63 +85|41 +85|28 +85|19 +85|77 +85|35 +85|71 +85|65 +85|11 +85|79 +85|56 +37|82 +37|71 +37|41 +37|99 +37|75 +37|85 +37|16 +37|79 +37|46 +37|98 +37|28 +37|77 +37|19 +99|79 +99|17 +99|12 +99|28 +99|42 +99|11 +99|56 +99|15 +99|83 +99|77 +99|35 +99|23 +99|53 +99|63 +65|75 +65|15 +65|31 +65|77 +65|22 +65|71 +65|58 +65|56 +65|17 +65|63 +65|28 +65|74 +65|79 +65|83 +65|41 +16|78 +16|98 +16|42 +16|49 +16|28 +16|79 +16|77 +16|85 +16|35 +16|56 +16|41 +16|75 +16|22 +16|46 +16|58 +16|12 +66|82 +66|19 +66|63 +66|85 +66|41 +66|75 +66|71 +66|77 +66|17 +66|28 +66|54 +66|46 +66|78 +66|98 +66|89 +66|21 +66|65 +45|65 +45|41 +45|78 +45|63 +45|56 +45|71 +45|99 +45|75 +45|35 +45|21 +45|85 +45|17 +45|46 +45|79 +45|98 +45|66 +45|89 +45|54 +17|81 +17|23 +17|53 +17|15 +17|74 +17|61 +17|11 +17|76 +17|29 +17|94 +17|25 +17|84 +17|31 +17|83 +17|34 +17|91 +17|69 +17|37 +17|86 +54|65 +54|16 +54|78 +54|77 +54|11 +54|56 +54|46 +54|35 +54|63 +54|99 +54|19 +54|71 +54|41 +54|42 +54|17 +54|21 +54|28 +54|79 +54|75 +54|98 +91|78 +91|16 +91|81 +91|89 +91|99 +91|46 +91|45 +91|61 +91|84 +91|25 +91|21 +91|85 +91|35 +91|65 +91|69 +91|66 +91|37 +91|57 +91|29 +91|54 +91|76 +11|76 +11|57 +11|34 +11|69 +11|81 +11|37 +11|25 +11|94 +11|61 +11|15 +11|53 +11|74 +11|23 +11|29 +11|31 +11|42 +11|83 +11|84 +11|45 +11|91 +11|22 +11|86 +31|45 +31|57 +31|37 +31|78 +31|54 +31|34 +31|66 +31|16 +31|85 +31|69 +31|21 +31|25 +31|94 +31|46 +31|61 +31|99 +31|86 +31|29 +31|82 +31|76 +31|84 +31|91 +31|81 +46|23 +46|11 +46|42 +46|41 +46|77 +46|75 +46|15 +46|78 +46|17 +46|28 +46|79 +46|35 +46|65 +46|19 +46|56 +46|98 +46|22 +46|63 +46|89 +46|58 +46|12 +46|49 +46|99 +46|71 +71|23 +71|11 +71|91 +71|29 +71|31 +71|17 +71|12 +71|74 +71|57 +71|86 +71|81 +71|83 +71|28 +71|69 +71|58 +71|25 +71|15 +71|42 +71|34 +71|22 +71|76 +71|53 +71|49 +71|94 +86|25 +86|78 +86|69 +86|85 +86|75 +86|82 +86|65 +86|54 +86|77 +86|16 +86|89 +86|84 +86|57 +86|46 +86|99 +86|37 +86|45 +86|81 +86|19 +86|98 +86|35 +86|66 +86|21 +86|61 +94|85 +94|57 +94|76 +94|99 +94|25 +94|81 +94|61 +94|21 +94|37 +94|66 +94|82 +94|54 +94|69 +94|34 +94|86 +94|84 +94|45 +94|29 +94|78 +94|89 +94|98 +94|16 +94|91 +94|46 +23|86 +23|53 +23|34 +23|16 +23|82 +23|61 +23|91 +23|29 +23|66 +23|37 +23|84 +23|74 +23|85 +23|45 +23|94 +23|76 +23|81 +23|21 +23|57 +23|25 +23|54 +23|83 +23|31 +23|69 +58|45 +58|22 +58|91 +58|31 +58|86 +58|25 +58|81 +58|84 +58|76 +58|15 +58|34 +58|94 +58|66 +58|83 +58|74 +58|69 +58|54 +58|37 +58|23 +58|61 +58|57 +58|29 +58|53 +58|82 +81|35 +81|16 +81|65 +81|19 +81|82 +81|41 +81|61 +81|99 +81|21 +81|45 +81|89 +81|75 +81|66 +81|78 +81|37 +81|56 +81|84 +81|77 +81|98 +81|85 +81|54 +81|46 +81|63 +81|25 +56|42 +56|94 +56|22 +56|34 +56|17 +56|86 +56|15 +56|76 +56|29 +56|23 +56|83 +56|91 +56|71 +56|31 +56|28 +56|63 +56|53 +56|11 +56|69 +56|74 +56|12 +56|49 +56|79 +56|58 +84|66 +84|19 +84|65 +84|41 +84|21 +84|56 +84|98 +84|71 +84|79 +84|35 +84|12 +84|28 +84|89 +84|82 +84|99 +84|16 +84|46 +84|85 +84|75 +84|45 +84|78 +84|77 +84|63 +84|54 +69|81 +69|75 +69|65 +69|78 +69|19 +69|16 +69|46 +69|54 +69|84 +69|82 +69|45 +69|66 +69|21 +69|25 +69|89 +69|35 +69|77 +69|37 +69|85 +69|41 +69|98 +69|57 +69|99 +69|61 +41|86 +41|12 +41|28 +41|74 +41|56 +41|29 +41|63 +41|31 +41|23 +41|91 +41|22 +41|17 +41|83 +41|11 +41|42 +41|94 +41|53 +41|58 +41|76 +41|71 +41|49 +41|79 +41|34 +41|15 +53|83 +53|21 +53|54 +53|34 +53|69 +53|16 +53|61 +53|81 +53|76 +53|57 +53|37 +53|66 +53|46 +53|45 +53|84 +53|74 +53|85 +53|91 +53|31 +53|94 +53|82 +53|86 +53|25 +53|29 +83|74 +83|81 +83|25 +83|76 +83|91 +83|37 +83|86 +83|66 +83|85 +83|34 +83|31 +83|61 +83|46 +83|16 +83|69 +83|21 +83|94 +83|54 +83|45 +83|57 +83|29 +83|84 +83|82 +83|98 +61|21 +61|82 +61|99 +61|65 +61|46 +61|85 +61|79 +61|19 +61|84 +61|71 +61|89 +61|56 +61|16 +61|63 +61|54 +61|35 +61|98 +61|37 +61|41 +61|78 +61|66 +61|45 +61|77 +61|75 +12|11 +12|53 +12|23 +12|81 +12|91 +12|94 +12|69 +12|86 +12|15 +12|34 +12|74 +12|22 +12|17 +12|76 +12|25 +12|31 +12|58 +12|29 +12|42 +12|49 +12|83 +12|61 +12|37 +12|57 +15|16 +15|84 +15|53 +15|29 +15|83 +15|25 +15|76 +15|82 +15|21 +15|61 +15|66 +15|45 +15|37 +15|31 +15|54 +15|74 +15|23 +15|91 +15|86 +15|69 +15|81 +15|57 +15|34 +15|94 +78|79 +78|53 +78|56 +78|71 +78|23 +78|83 +78|89 +78|74 +78|15 +78|41 +78|28 +78|63 +78|77 +78|17 +78|58 +78|49 +78|19 +78|12 +78|11 +78|42 +78|75 +78|35 +78|22 +78|65 +89|83 +89|31 +89|53 +89|42 +89|75 +89|15 +89|63 +89|74 +89|71 +89|41 +89|17 +89|58 +89|79 +89|23 +89|49 +89|12 +89|19 +89|28 +89|65 +89|56 +89|11 +89|22 +89|77 +89|35 +98|71 +98|19 +98|79 +98|12 +98|65 +98|41 +98|23 +98|89 +98|53 +98|75 +98|77 +98|28 +98|56 +98|17 +98|49 +98|35 +98|99 +98|11 +98|22 +98|15 +98|58 +98|63 +98|42 +98|78 +57|25 +57|37 +57|89 +57|56 +57|66 +57|81 +57|77 +57|35 +57|41 +57|21 +57|46 +57|84 +57|75 +57|98 +57|78 +57|99 +57|54 +57|16 +57|61 +57|85 +57|19 +57|82 +57|45 +57|65 +49|61 +49|34 +49|37 +49|53 +49|84 +49|42 +49|22 +49|45 +49|76 +49|25 +49|91 +49|29 +49|83 +49|94 +49|58 +49|23 +49|74 +49|81 +49|86 +49|15 +49|11 +49|57 +49|69 +49|31 +28|53 +28|42 +28|58 +28|49 +28|17 +28|91 +28|74 +28|15 +28|31 +28|23 +28|25 +28|57 +28|94 +28|29 +28|34 +28|22 +28|12 +28|86 +28|61 +28|11 +28|83 +28|76 +28|81 +28|69 +79|29 +79|91 +79|17 +79|34 +79|28 +79|69 +79|83 +79|86 +79|58 +79|71 +79|31 +79|22 +79|42 +79|11 +79|15 +79|81 +79|94 +79|23 +79|76 +79|57 +79|49 +79|12 +79|53 +79|74 +19|77 +19|76 +19|15 +19|31 +19|42 +19|83 +19|91 +19|49 +19|74 +19|94 +19|41 +19|17 +19|12 +19|56 +19|11 +19|71 +19|23 +19|79 +19|53 +19|22 +19|58 +19|34 +19|28 +19|63 +74|46 +74|84 +74|21 +74|16 +74|99 +74|34 +74|94 +74|31 +74|45 +74|66 +74|25 +74|86 +74|81 +74|57 +74|29 +74|54 +74|61 +74|82 +74|69 +74|37 +74|91 +74|98 +74|76 +74|85 +25|89 +25|99 +25|41 +25|61 +25|37 +25|35 +25|45 +25|77 +25|82 +25|54 +25|84 +25|85 +25|46 +25|21 +25|63 +25|66 +25|98 +25|79 +25|19 +25|65 +25|75 +25|78 +25|16 +25|56 +77|74 +77|11 +77|79 +77|42 +77|28 +77|17 +77|12 +77|94 +77|34 +77|83 +77|29 +77|58 +77|41 +77|91 +77|15 +77|22 +77|23 +77|49 +77|56 +77|63 +77|31 +77|53 +77|71 +22|15 +22|86 +22|23 +22|84 +22|25 +22|31 +22|29 +22|81 +22|66 +22|21 +22|83 +22|54 +22|57 +22|53 +22|37 +22|74 +22|61 +22|82 +22|69 +22|45 +22|34 +22|94 +42|37 +42|53 +42|15 +42|57 +42|31 +42|94 +42|29 +42|86 +42|83 +42|22 +42|74 +42|23 +42|61 +42|69 +42|58 +42|81 +42|91 +42|66 +42|34 +42|45 +42|82 +34|86 +34|61 +34|99 +34|46 +34|84 +34|66 +34|91 +34|45 +34|89 +34|76 +34|81 +34|98 +34|69 +34|57 +34|16 +34|54 +34|29 +34|85 +34|78 +34|65 +21|89 +21|71 +21|17 +21|78 +21|65 +21|12 +21|56 +21|46 +21|75 +21|28 +21|98 +21|85 +21|99 +21|35 +21|42 +21|49 +21|63 +21|16 +21|41 +82|56 +82|11 +82|71 +82|99 +82|49 +82|77 +82|35 +82|63 +82|17 +82|79 +82|78 +82|54 +82|16 +82|12 +82|28 +82|65 +82|75 +82|46 +76|85 +76|35 +76|82 +76|46 +76|54 +76|89 +76|78 +76|37 +76|61 +76|99 +76|86 +76|84 +76|98 +76|65 +76|21 +76|69 +76|75 +29|37 +29|35 +29|99 +29|57 +29|25 +29|84 +29|66 +29|69 +29|81 +29|85 +29|65 +29|45 +29|86 +29|19 +29|16 +29|21 +63|86 +63|74 +63|12 +63|71 +63|15 +63|49 +63|58 +63|28 +63|17 +63|23 +63|94 +63|34 +63|29 +63|76 +63|31 +75|12 +75|56 +75|94 +75|53 +75|34 +75|91 +75|58 +75|42 +75|17 +75|31 +75|15 +75|19 +75|23 +75|41 +35|23 +35|75 +35|94 +35|28 +35|74 +35|56 +35|71 +35|19 +35|49 +35|11 +35|77 +35|22 +35|58 +85|58 +85|42 +85|89 +85|49 +85|78 +85|15 +85|75 +85|98 +85|17 +85|46 +85|22 +85|12 +37|66 +37|21 +37|89 +37|35 +37|78 +37|63 +37|56 +37|65 +37|45 +37|84 +37|54 +99|22 +99|75 +99|71 +99|49 +99|41 +99|78 +99|19 +99|65 +99|89 +99|58 +65|19 +65|94 +65|11 +65|23 +65|35 +65|12 +65|49 +65|42 +65|53 +16|71 +16|65 +16|19 +16|89 +16|17 +16|63 +16|11 +16|99 +66|56 +66|79 +66|35 +66|12 +66|99 +66|49 +66|16 +45|77 +45|12 +45|16 +45|82 +45|19 +45|28 +17|58 +17|22 +17|42 +17|49 +17|57 +54|85 +54|89 +54|12 +54|49 +91|98 +91|82 +91|86 +11|58 +11|66 +31|98 + +91,76,94,81,45,78,21 +34,76,63,42,31,41,83,56,15,53,23,28,79,71,94,77,91,49,74 +61,66,21,46,98,65,75 +56,71,28,12,17,58,53,31,94,34,86 +81,25,45,82,54,21,99,35,75 +83,31,76,29,69,57,25,37,45,66,16,85,46 +57,25,69,86,61,37,29,74,94,45,53,84,83,21,91,34,76,16,66,85,82 +91,57,98,86,21,85,78,54,34,82,76,29,45,84,99,46,61,16,66,25,89 +79,99,58,49,22,78,89,35,63,19,12,28,11,71,65,53,17 +12,23,61,74,91,34,53 +58,15,74,94,91,76,29,57,81,25,82 +15,23,53,81,37,82,21 +82,21,16,85,46,98,99,78,65,35,77,63,79,71,12,17,49 +76,53,17,49,79,63,56,15,28,91,58,34,22,74,77 +86,69,57,25,61,37,84,45,66,16,46,98,99,78,89,65,35,75,19 +41,91,15,31,79,29,83,58,94,17,56,76,63 +41,63,54,65,84,66,99,78,28,85,89,46,35,45,79,82,77 +81,61,84,45,82,54,98,78,89 +23,35,58,98,49,12,11 +61,37,84,66,54,21,85,99,78,35,77,41,56,63,79 +84,56,41,46,28,98,79 +49,11,23,83,29,37,84 +57,84,82,21,65,35,41 +83,74,31,94,34,29,86,69,81,25,37,45,82,21,16,85,46 +84,76,23,53,25 +81,66,54,16,85,46,98,99,65,35,19,77,56 +16,77,75,41,12,11,42,58,89 +22,53,74,94,34,91,76,29,86,69,57,81,25,61,37,45,54 +12,17,49,11,58,22,15,23,53,83,74,31,94,34,91,76,29,86,69,57,81,25,61 +46,82,84,16,41,65,45,98,56,78,99 +54,71,77,35,11,41,89,16,65,21,46,85,49,56,79 +42,15,23,53,74,31,94,34,91,76,29,86,69,61,37,45,66 +75,63,12,17,42,58,31,94,34 +15,35,79,78,41,89,28,49,77,56,71,17,19,75,98 +21,16,85,98,99,78,89,65,35,75,19,77,41,56,63,79,71,28,12,17,49,11,42 +22,23,53,83,74,31,94,34,76,29,57,81,25,37,84,45,66 +83,74,94,34,91,76,29,86,69,57,25,61,37,84,45,66,82,21,16,85,46 +57,76,37,17,83,91,81,49,86,58,69,74,11,15,22,31,61,94,25 +46,65,25,98,99,61,45,82,89,81,85,69,21,37,35,54,78,86,76 +89,12,83,74,11,77,28,15,71,63,35,19,79 +85,46,98,99,78,89,65,35,75,19,77,41,56,63,79,71,12,17,49,11,42,58,22 +12,19,28,23,74,89,77 +98,85,77,37,99,41,25,35,19,16,65,81,66,89,61,57,75,84,21,46,82 +86,69,66,98,99,78,35 +71,28,12,49,11,42,83,74,94,76,29,86,81 +84,98,78,19,41 +21,16,46,98,99,78,89,65,35,75,19,77,41,56,63,79,71,28,12,17,49,11,42 +25,61,66,82,75,77,63 +11,49,91,94,76,15,23,31,34,71,28,79,42,17,63,69,22 +99,78,75,77,63,79,49,22,15 +53,83,31,94,34,91,29,86,57,81,25,61,37,84,45,66,82,54,85 +23,94,74,91,31,69,25,53,15,81,22 +75,85,98,37,63 +78,54,37,82,41,16,46,71,99,66,75,56,21,84,65 +84,45,66,54,21,85,46,99,78,89,65,77,41,63,79,71,28 +34,53,71,58,86,81,57 +76,69,57,81,25,61,45,66,82,54,21,16,98,99,89 +21,46,98,99,78,35,19,77,41,56,63,79,71,17,49,11,42 +45,66,82,54,21,16,85,46,98,99,78,65,35,75,77,41,56,63,71,28,12 +85,19,77,82,98,56,49,75,41,89,71,17,12,79,35 +23,22,37,76,15,31,86,94,82,61,74,58,57 +56,17,49,58,23,83,31 +22,45,91,25,42,83,15,61,66 +82,21,85,98,75,63,49 +35,25,45,57,75 +81,75,77,46,25,37,84,85,89,16,78,19,66,69,98,35,21,82,61,57,65 +77,41,56,79,71,28,17,49,11,42,58,15,23,83,74,31,94,34,76 +58,41,77,15,42,71,12,35,53,83,19,74,63,75,22,89,79 +11,23,49,19,42,94,34,56,75,53,22,83,28,15,31,71,17 +35,53,17,22,77,12,75,83,11,41,71,23,56 +41,85,79,11,65,49,77,75,17,42,99,28,71,35,89,63,78,22,19 +45,85,35,66,75,63,98,84,89,21,78,54,82,25,77,16,19,41,99 +53,74,25,83,23,54,29,81,86,82,22,57,61,94,76,91,69,34,31 +65,75,16,78,99,35,98 +86,91,11,57,53,29,23,69,83,81,31,17,71 +71,17,42,63,41,74,58,22,53,56,28,83,79,91,34,15,19,23,94 +65,41,56,71,28,49,22,15,23,74,31 +29,69,57,61,37,84,45,82,21,46,98,78,75 +16,65,75,19,56,63,71,12,49,42,58 +86,69,57,81,25,61,37,84,45,66,54,21,16,85,46,98,78,89,35,75,19 +79,71,12,17,49,42,58,22,15,23,31,94,34,91,29,86,57 +34,37,23,29,54,57,94,61,84,45,22,69,83 +91,76,29,86,69,57,81,61,37,84,45,66,82,54,21,16,85,46,98,99,78,89,65 +21,79,12,98,42,16,78,11,28 +28,49,86,58,81,69,53,74,17,57,12,91,11,23,25,22,42,76,83,29,31,94,34 +42,58,22,15,23,53,83,31,94,34,91,76,29,86,69,57,81,25,61,37,84,45,66 +84,78,75,35,19,65,69,21,85,81,66,25,99,16,77,98,45 +66,82,54,21,16,85,46,98,99,78,89,65,35,19,77,56,63,71,28,12,17 +77,94,28,49,31 +11,58,74,83,41,34,19,75,42,49,12,23,15,71,94,53,22 +16,46,98,99,78,89,65,35,75,19,77,41,56,79,71,28,12,17,49,11,58 +86,74,49,71,28,22,63,83,15,34,17,58,91,23,53,69,12,31,11,76,42 +98,85,75,99,63,35,16,65,71,37,77,82,79,41,19,54,89,66,21,78,84,45,56 +19,77,41,56,79,28,12,49,42,58,22,23,53,83,74,31,94,34,91 +79,71,28,17,11,42,58,22,23,53,83,74,31,94,91,76,29,69,57 +29,45,85,91,94,78,81 +56,19,46,15,35,22,71 +46,66,29,61,16,65,57,54,76,89,98,21,25,91,45,85,99,78,37 +76,31,94,84,15,61,83,57,58,91,25,34,37,53,66,81,22 +94,29,61,74,69,34,31,91,37,84,86,25,15,83,23,81,21 +74,25,12,58,29,69,61,94,53,42,57,49,11,86,23 +61,37,84,45,66,82,54,21,85,46,98,99,89,65,35,75,19,41,56,63,79 +16,85,46,98,99,78,89,65,35,75,77,41,56,63,79,71,12,17,11,42,58 +12,49,42,58,15,83,74,31,94,34,91,76,29,57,25 +41,84,85,78,45,21,99,35,75,57,54,77,66 +74,31,34,76,29,69,81,61,37,84,45,82,21,46,98 +83,74,31,94,34,76,29,86,69,81,25,61,37,84,45,82,54,21,16,85,46 +79,56,89,77,78 +91,31,66,81,69,46,76,16,82,25,29,21,84,98,85,45,61,74,54 +77,78,17,28,54,35,16,82,99,65,41,89,71,12,63,98,19,46,66,56,79 +54,21,75,63,79,49,11 +49,53,23,69,74 +22,17,41,65,77,31,83,79,19,49,53 +99,78,65,56,79,71,17,11,42,15,53 +77,15,23,17,12,22,42,65,79,71,75,11,89,49,41 +86,81,37,84,82,16,85,46,99,78,89,65,35 +82,21,16,99,65,35,19,77,41,71,12 +78,89,65,35,75,19,77,41,56,63,79,28,12,17,49,11,42,58,22,15,23,53,83 +65,79,58,22,53,74,31 +31,94,34,86,57,81,61,84,66,54,21,46,98 +79,12,17,49,58,53,57 +17,28,77,65,12,71,79,75,31 +99,81,45,21,82,84,57,54,86,78,66,29,25 +22,69,83,31,71,76,17,79,94,86,34,42,63,53,12 +89,65,35,75,41,63,79,15,53 +75,61,69,84,46,16,19,45,35,86,78,54,25,21,82,85,57 +46,98,99,78,65,63,79,12,11,22,15 +79,17,11,58,22,15,74,34,91,29,57 +57,58,23,53,83,42,94,76,61,15,22,45,34,31,29,81,86,37,25,84,66 +99,81,57,69,82,45,89,85,46,61,86,21,78,16,37,76,66,34,29 +83,53,74,41,22,11,58,12,77,79,71,56,65,17,35,49,75,42,19,15,28,89,23 +21,16,46,98,89,65,35,75,19,77,41,56,63,79,71,28,12,17,49,11,42 +56,58,49,83,11,17,71,42,53,76,77,15,63,12,31,79,74,91,41 +25,61,37,84,45,66,82,54,21,16,85,46,98,78,35,75,19,77,41,56,63 +69,23,34,29,66,82,16,25,31,21,57,91,81,54,74,86,94,84,61,45,83,53,37 +45,85,46,21,75,54,63,77,79,56,82,41,71 +16,85,46,98,99,78,89,65,35,75,19,77,41,56,63,79,71,12,17,49,11,42,58 +56,82,46,54,98,99,65,19,35,45,85,41,84,25,16,89,78,37,63 +37,84,82,54,21,46,98,99,78,65,35,75,19,77,41,56,63,79,71 +75,19,77,56,49,11,42,58,22,53,83,31,34 +19,71,42,46,12,85,63,89,56,49,79,41,99,11,77 +74,31,34,91,76,29,86,69,81,25,61,37,84,45,66,82,54,21,16,46,98 +37,84,45,66,82,54,16,85,98,78,89,65,35,75,77,41,56,79,71 +99,65,35,19,77,79,71,49,42,58,22,15,53 +11,42,58,22,15,23,83,74,31,94,34,91,76,29,69,57,25,61,37,84,45 +85,77,78,99,61,41,75,89,57,37,65,25,54 +54,66,57,69,21,78,25,85,81,29,86,61,65,99,37,98,16,89,46,76,45 +99,66,57,89,41,65,16 +37,82,54,21,98,19,63,79,71 +42,35,17,19,28,11,15,74,94,77,71,22,75,83,53 +83,74,31,94,34,91,76,86,69,57,81,25,61,37,84,45,66,82,54,21,16,85,46 +46,29,57,65,45,86,81,61,84,78,98,66,35,69,25,37,82,21,85,89,76,16,99 +23,53,83,74,94,34,81,37,84,45,16 +58,56,31,22,75,15,77,34,11,79,19,17,49,23,71,28,63,12,53,74,83 +41,42,99,65,12 +71,28,12,17,49,11,58,22,15,23,53,74,94,91,76,29,86,69,57 +21,37,16,99,31,82,81,61,85,34,86,29,76,45,57 +45,66,82,54,21,16,85,99,78,89,35,75,41,56,63,79,71,28,12 +22,28,75,74,63,41,65,56,89,15,79 +65,19,63,35,98,12,85,28,21,75,78,17,89,77,46,54,99,16,11 +65,35,75,19,77,41,63,71,49,11,42,58,22,15,23,53,31 +78,35,41,17,49,11,23,53,83 +56,63,79,71,28,12,17,49,11,42,58,22,15,23,53,83,74,94,34,91,76,29,86 +42,49,71,23,76,94,53 +22,23,83,74,94,34,29,69,57,61,37,84,45,82,54 +17,49,11,58,22,23,53,83,31,34,91,29,69,81,25,61,37 +29,86,69,57,81,25,61,37,82,21,16,85,46,99,78,89,65,35,75 +25,84,45,82,54,21,16,46,99,65,35,75,19,56,63 +49,11,42,22,53,83,31,94,34,91,29,57,84 +49,63,76,53,15,28,42,83,58,71,29,11,34,22,94,74,69,31,79,23,12,86,17 +56,63,28,12,17,49,11,58,22,15,23,53,83,74,31,94,34,91,76,29,86 +82,56,45,19,21,79,61,99,89,63,77,85,54 +83,49,74,12,75,77,58,35,53,79,94,17,56 +41,79,71,28,12,17,49,11,42,58,22,15,23,53,83,74,94,34,91,76,29 +63,79,71,28,12,17,49,11,42,22,23,53,83,74,31,94,34,91,76,29,69 +12,49,11,42,22,15,23,53,83,74,31,94,34,91,76,29,86,69,57,81,25 diff --git a/src/main.rs b/src/main.rs index 31560dd..98b590f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,5 @@ +#![feature(int_roundings)] + mod solutions; use std::env; @@ -14,6 +16,8 @@ fn main() -> std::io::Result<()> { Ok(1) => solutions::day_1::run(args)?, Ok(2) => solutions::day_2::run(args)?, Ok(3) => solutions::day_3::run(args)?, + Ok(4) => solutions::day_4::run(args)?, + Ok(5) => solutions::day_5::run(args)?, Ok(_) => eprintln!("Unknown day. Are you from the future?"), Err(_) => eprintln!("Unknown day format. Use integers to specify."), } diff --git a/src/solutions/day_4.rs b/src/solutions/day_4.rs new file mode 100644 index 0000000..8bcf476 --- /dev/null +++ b/src/solutions/day_4.rs @@ -0,0 +1,184 @@ +use std::env; +use std::fs::File; +use std::io::{BufRead, BufReader}; +use std::ops::Add; + +enum State { + ExpectM, + ExpectA, + ExpectS, +} + +#[derive(Debug, Copy, Clone)] +enum Dir { + /// Diagonal up left: x - 1, y - 1 + DiagUL, + /// Up: y - 1 + Up, + /// Diagonal up right: x + 1, y - 1 + DiagUR, + /// Left: x - 1 + Left, + /// Right: x + 1 + Right, + /// Diagonal down right: x - 1, y + 1 + DiagDL, + /// Down: y + 1 + Down, + /// Diagonal down right: x + 1, y + 1 + DiagDR, +} + +#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)] +struct Point { + x: usize, + y: usize, +} + +fn check_direction(map: &Vec>, state: State, pt: Point, direction: Dir) -> bool { + let next_pt = pt + direction; + + let c = map[next_pt.x][next_pt.y]; + + match state { + State::ExpectM => { + if c == 'M' { + check_direction(map, State::ExpectA, next_pt, direction) + } else { + false + } + } + State::ExpectA => { + if c == 'A' { + check_direction(map, State::ExpectS, next_pt, direction) + } else { + false + } + } + State::ExpectS => c == 'S', + } +} + +fn check_all(map: &Vec>, x: usize, y: usize) -> u64 { + let pt = Point { x, y }; + let mut sum = 0; + if x >= 3 { + if y >= 3 && check_direction(map, State::ExpectM, pt, Dir::DiagUL) { + sum += 1; + } + if check_direction(map, State::ExpectM, pt, Dir::Left) { + sum += 1; + } + if (y + 3) < map[0].len() && check_direction(map, State::ExpectM, pt, Dir::DiagDL) { + sum += 1; + } + } + + if y >= 3 && check_direction(map, State::ExpectM, pt, Dir::Up) { + sum += 1; + } + if (y + 3) < map[0].len() && check_direction(map, State::ExpectM, pt, Dir::Down) { + sum += 1; + } + + if (x + 3) < map.len() { + if y >= 3 && check_direction(map, State::ExpectM, pt, Dir::DiagUR) { + sum += 1; + } + if check_direction(map, State::ExpectM, pt, Dir::Right) { + sum += 1; + } + if (y + 3) < map[0].len() && check_direction(map, State::ExpectM, pt, Dir::DiagDR) { + sum += 1; + } + } + + return sum; +} + +fn check_day_2(map: &Vec>, x: usize, y: usize) -> bool { + map[x][y] == 'A' + && x >= 1 + && y >= 1 + && (x + 1) < map.len() + && (y + 1) < map[0].len() + && (map[x - 1][y - 1] == 'M' && map[x + 1][y + 1] == 'S' + || map[x - 1][y - 1] == 'S' && map[x + 1][y + 1] == 'M') + && (map[x - 1][y + 1] == 'M' && map[x + 1][y - 1] == 'S' + || map[x - 1][y + 1] == 'S' && map[x + 1][y - 1] == 'M') +} + +pub fn run(mut args: env::Args) -> std::io::Result<()> { + let filename = args + .next() + .expect("You must provide a filename as argument"); + + let f = File::open(filename)?; + let reader = BufReader::new(f); + + let mut sum = 0; + let mut sum_2 = 0; + let mut map: Vec> = Vec::new(); + + for line in reader.lines() { + let l = line.unwrap(); + if l.is_empty() { + continue; + } + + map.push(l.chars().collect()); + } + + // x: the rows + // y: the columns + for x in 0..map.len() { + for y in 0..map[x].len() { + if map[x][y] == 'X' { + sum += check_all(&map, x, y); + } + + // part 2 + if check_day_2(&map, x, y) { + sum_2 += 1; + } + } + } + + // Task 1 + println!("Number of 'XMAS': {sum}"); + + // Task 2 + println!("Number of 'X-MAS': {sum_2}"); + + Ok(()) +} + +impl Add for Point { + type Output = Self; + + fn add(mut self, other: Dir) -> Self { + match other { + Dir::Up => self.y -= 1, + Dir::Down => self.y += 1, + Dir::Left => self.x -= 1, + Dir::Right => self.x += 1, + Dir::DiagUL => { + self.x -= 1; + self.y -= 1; + } + Dir::DiagUR => { + self.x += 1; + self.y -= 1; + } + Dir::DiagDL => { + self.x -= 1; + self.y += 1; + } + Dir::DiagDR => { + self.x += 1; + self.y += 1; + } + } + self + } +} diff --git a/src/solutions/day_5.rs b/src/solutions/day_5.rs new file mode 100644 index 0000000..96f01f9 --- /dev/null +++ b/src/solutions/day_5.rs @@ -0,0 +1,91 @@ +use std::collections::{HashMap, HashSet}; +use std::env; +use std::fs::File; +use std::io::{BufRead, BufReader}; +use std::str::FromStr; + +enum ParserState { + Restrictions, + Updates, +} + +#[derive(Debug, Default)] +struct NumEntry { + pub less_than: HashSet, + pub greater_than: HashSet, +} + +pub fn run(mut args: env::Args) -> std::io::Result<()> { + let filename = args + .next() + .expect("You must provide a filename as argument"); + + let f = File::open(filename)?; + let reader = BufReader::new(f); + + let mut state = ParserState::Restrictions; + let mut ordering: HashMap = HashMap::new(); + let mut lists: Vec> = Vec::new(); + + for line in reader.lines() { + let l = line.unwrap(); + match state { + ParserState::Restrictions => { + if l.is_empty() { + state = ParserState::Updates; + } else { + let nums: Vec = + l.split("|").map(u8::from_str).map(Result::unwrap).collect(); + assert!(nums.len() == 2); + + ordering + .entry(nums[0]) + .or_default() + .less_than + .insert(nums[1]); + ordering + .entry(nums[1]) + .or_default() + .greater_than + .insert(nums[0]); + } + } + ParserState::Updates => { + if !l.is_empty() { + lists.push(l.split(",").map(u8::from_str).map(Result::unwrap).collect()); + } + } + } + } + + lists.retain(|v| is_compliant(v, &ordering)); + + // Task 1 + let sum = lists.iter().fold(0, |acc, v| { + let idx = v.len().div_floor(2); + acc + v[idx] as u32 + }); + + println!("Sum of middle values: {sum}"); + + // Task 2 + // TBD + + Ok(()) +} + +fn is_compliant(list: &[u8], ordering: &HashMap) -> bool { + for i in 0..list.len() { + // skip numbers that have no associated rules + if let Some(entry) = ordering.get(&list[i]) { + for j in i..list.len() { + if entry.greater_than.contains(&list[j]) { + // that's a violation! + return false; + } + } + } + } + + return true; +} diff --git a/src/solutions/mod.rs b/src/solutions/mod.rs index ee3e040..6bba404 100644 --- a/src/solutions/mod.rs +++ b/src/solutions/mod.rs @@ -1,4 +1,6 @@ pub mod day_1; pub mod day_2; pub mod day_3; +pub mod day_4; +pub mod day_5;