From e93c708e8f986045a1dfa4442c8454a11e627d38 Mon Sep 17 00:00:00 2001 From: Greg Burri Date: Sun, 4 Dec 2022 19:02:40 +0100 Subject: [PATCH] Day 4 --- data/day04.input | 1000 ++++++++++++++++++++++++++++++++++++++++++++++ src/day04.rs | 54 +++ src/main.rs | 7 + 3 files changed, 1061 insertions(+) create mode 100644 data/day04.input create mode 100644 src/day04.rs diff --git a/data/day04.input b/data/day04.input new file mode 100644 index 0000000..3c07591 --- /dev/null +++ b/data/day04.input @@ -0,0 +1,1000 @@ +71-97,71-72 +60-97,20-95 +20-59,58-59 +24-83,3-82 +48-96,33-47 +49-49,10-50 +48-86,6-85 +71-72,27-72 +46-83,29-84 +10-52,1-53 +38-84,37-39 +48-48,39-48 +42-87,43-96 +1-99,78-98 +23-39,1-38 +30-30,13-30 +8-37,7-38 +13-85,57-84 +1-97,2-98 +7-99,6-98 +14-99,13-91 +2-87,8-88 +51-66,66-66 +66-98,97-98 +41-73,84-85 +37-95,36-94 +4-22,11-38 +25-90,25-50 +50-97,51-89 +10-86,9-86 +78-93,56-77 +56-84,56-79 +43-48,43-49 +43-96,98-98 +66-76,59-68 +12-15,11-59 +3-85,12-84 +50-74,50-75 +1-7,2-6 +10-11,11-58 +15-96,16-99 +20-87,23-88 +39-79,39-78 +96-98,7-97 +14-74,13-14 +3-99,98-99 +43-47,43-62 +79-83,75-84 +10-13,15-15 +8-91,8-9 +68-74,47-97 +74-88,75-79 +48-97,49-97 +58-96,58-98 +28-60,61-73 +3-99,28-87 +89-90,91-91 +10-40,4-10 +2-97,1-97 +22-24,22-24 +75-76,55-76 +42-83,42-82 +35-95,25-95 +10-27,9-11 +12-83,13-37 +37-97,36-38 +3-30,4-30 +31-51,31-32 +26-28,27-46 +44-46,45-90 +19-82,27-77 +44-92,43-85 +22-54,5-53 +6-98,4-99 +4-4,4-40 +30-99,30-31 +59-59,60-90 +21-95,19-94 +22-43,21-67 +69-72,72-72 +70-94,71-93 +13-15,13-14 +23-90,22-89 +93-94,4-94 +1-21,3-20 +4-68,5-69 +27-29,28-95 +47-47,47-48 +26-54,25-55 +16-81,80-80 +31-33,32-60 +25-82,26-51 +16-73,72-72 +95-95,33-95 +12-72,13-43 +36-95,35-36 +19-94,9-43 +7-7,5-15 +9-96,9-99 +9-91,8-8 +46-62,34-85 +83-84,31-84 +52-56,46-63 +44-85,59-86 +43-70,43-70 +21-38,39-78 +58-58,6-57 +1-99,99-99 +12-90,40-89 +34-67,35-73 +15-97,14-96 +46-98,46-96 +52-70,42-77 +4-23,3-23 +55-82,81-83 +48-84,25-83 +31-92,92-98 +6-93,5-98 +14-39,15-38 +17-58,17-18 +7-16,24-94 +16-71,85-97 +1-95,16-86 +32-60,57-68 +74-96,55-97 +36-95,97-97 +76-78,27-77 +47-84,59-75 +15-37,4-16 +1-97,1-98 +27-78,28-77 +97-98,10-94 +37-97,97-97 +89-89,4-90 +21-28,21-94 +41-90,4-41 +1-93,93-96 +99-99,6-99 +11-13,12-95 +16-22,4-22 +7-89,90-90 +4-58,19-79 +9-84,68-84 +80-85,34-84 +1-70,71-84 +64-74,74-74 +58-80,58-70 +7-59,7-8 +17-19,9-17 +22-34,34-84 +66-76,66-66 +97-99,17-95 +47-97,39-45 +35-36,35-88 +9-79,41-80 +10-11,10-41 +4-14,15-90 +95-96,1-96 +36-92,69-93 +1-7,8-84 +32-39,32-39 +8-94,7-9 +34-50,7-52 +71-94,71-96 +2-47,1-95 +4-5,8-93 +34-66,21-65 +26-95,26-97 +60-82,59-61 +39-96,39-98 +15-22,22-50 +12-82,13-13 +15-63,62-62 +1-99,2-55 +11-26,16-91 +24-76,76-77 +3-6,7-92 +62-93,61-92 +33-83,32-84 +4-99,2-2 +11-21,22-98 +45-46,45-64 +26-30,21-35 +78-99,29-77 +55-73,5-91 +3-4,14-98 +3-93,92-92 +51-77,77-77 +7-90,90-90 +4-67,4-68 +10-95,10-96 +79-89,80-83 +3-86,17-87 +32-77,32-78 +31-72,10-25 +48-50,2-53 +29-58,28-59 +75-77,15-76 +2-76,1-75 +15-15,14-63 +75-85,76-96 +42-97,15-28 +20-98,97-98 +21-64,21-64 +11-95,95-96 +68-96,69-79 +5-89,6-90 +38-72,73-90 +43-97,42-98 +67-83,74-84 +69-87,69-87 +10-12,11-60 +12-67,11-85 +1-3,6-88 +8-80,17-81 +3-47,2-58 +74-74,37-75 +47-99,47-48 +21-78,6-51 +86-87,16-87 +3-86,87-87 +92-96,17-91 +54-85,54-87 +23-24,23-87 +62-91,62-92 +14-49,14-50 +29-93,94-97 +2-3,2-91 +53-57,57-57 +15-44,43-44 +1-37,2-37 +8-19,23-24 +19-20,6-20 +1-7,6-46 +3-26,1-77 +3-6,3-47 +30-80,96-96 +23-70,69-69 +51-52,52-89 +42-82,83-89 +86-97,13-86 +16-45,1-1 +14-77,4-13 +15-81,81-81 +87-87,30-88 +89-89,30-88 +21-22,21-95 +90-94,23-89 +67-67,1-66 +19-99,43-99 +2-97,5-98 +6-78,6-62 +8-9,8-9 +1-13,1-9 +91-95,92-95 +68-86,69-96 +4-26,25-68 +17-96,18-96 +65-65,64-65 +2-99,3-98 +24-97,25-68 +36-57,7-35 +52-89,87-88 +3-96,3-3 +2-34,2-18 +82-96,82-98 +29-30,4-30 +32-73,31-73 +72-98,99-99 +12-32,11-57 +11-86,7-9 +81-82,5-82 +8-94,93-94 +45-68,57-61 +49-50,24-50 +8-78,44-91 +28-29,29-98 +50-82,4-48 +71-71,20-70 +6-17,23-58 +61-73,23-70 +74-90,36-95 +6-14,9-12 +16-78,2-9 +2-92,2-90 +32-40,39-41 +69-69,44-69 +22-59,21-50 +30-66,30-67 +17-97,54-98 +89-97,84-96 +11-93,11-96 +55-80,80-84 +59-87,59-95 +4-81,9-80 +4-96,1-95 +21-95,21-94 +7-40,39-40 +5-98,5-92 +30-32,31-53 +10-88,11-88 +5-36,36-36 +97-98,16-98 +12-83,10-13 +19-68,20-67 +42-42,11-42 +9-11,10-67 +10-88,9-10 +12-70,12-13 +30-69,37-66 +1-95,2-6 +97-98,12-98 +40-46,41-47 +28-91,29-73 +1-5,6-82 +82-92,4-82 +10-91,11-92 +21-93,92-92 +14-58,57-58 +8-79,7-9 +27-94,26-27 +13-22,23-99 +11-11,17-64 +19-71,18-88 +1-13,1-3 +50-68,49-67 +13-14,13-37 +40-90,40-61 +21-95,22-95 +38-39,38-46 +44-95,64-81 +56-57,2-57 +64-85,7-63 +4-99,3-99 +32-90,90-98 +43-63,42-44 +58-58,43-57 +79-80,27-78 +27-72,1-26 +89-91,39-90 +31-43,43-43 +71-90,71-90 +13-95,14-96 +17-77,77-77 +60-62,59-65 +33-35,7-50 +2-8,5-5 +24-61,24-25 +6-74,73-73 +18-18,20-94 +29-54,41-55 +4-43,5-43 +39-69,43-70 +47-48,47-79 +5-6,6-85 +12-12,12-12 +12-91,12-90 +44-64,66-69 +47-58,46-58 +60-99,79-99 +56-86,86-86 +8-98,1-7 +59-59,10-58 +19-41,42-97 +76-94,6-95 +20-69,68-99 +36-63,35-36 +2-15,3-14 +16-28,15-17 +75-92,40-71 +4-61,11-62 +14-66,14-15 +6-70,29-69 +95-96,9-96 +68-89,68-69 +2-75,1-74 +97-97,12-97 +58-86,22-87 +3-4,3-97 +21-68,49-69 +88-88,32-87 +45-93,46-89 +12-92,12-93 +51-75,71-71 +24-29,28-29 +5-6,5-71 +33-34,33-80 +55-94,94-94 +50-64,50-63 +55-92,82-86 +32-34,33-47 +9-13,12-78 +5-99,35-57 +25-53,6-24 +7-85,6-96 +27-72,15-73 +61-74,36-95 +27-62,59-61 +4-82,4-86 +23-79,24-26 +24-43,17-44 +43-74,42-44 +39-84,38-99 +55-85,54-57 +2-78,1-3 +20-71,19-46 +25-38,25-26 +49-77,49-76 +1-2,1-68 +12-21,11-65 +17-82,17-56 +8-92,14-93 +1-52,4-51 +78-78,2-70 +9-42,8-41 +33-64,32-67 +22-68,22-61 +7-82,4-8 +24-42,36-37 +96-96,30-95 +68-68,14-67 +13-78,78-78 +39-70,17-38 +62-93,63-93 +19-64,19-64 +15-83,16-44 +33-34,34-49 +2-65,58-64 +5-53,4-84 +53-54,53-74 +3-58,1-65 +2-5,9-15 +3-39,21-40 +54-57,54-56 +25-62,25-61 +12-94,10-10 +74-75,74-89 +14-85,13-29 +4-76,3-88 +5-55,4-55 +55-93,54-93 +13-48,9-12 +23-56,23-24 +32-71,32-40 +23-94,22-24 +1-99,98-98 +22-75,31-44 +7-96,7-97 +11-12,14-34 +4-98,3-5 +58-94,59-94 +13-70,13-88 +38-40,20-39 +2-88,58-87 +35-81,4-81 +31-82,81-81 +24-93,8-25 +19-96,95-98 +18-64,19-65 +22-40,31-39 +43-75,81-82 +16-27,1-28 +7-28,6-28 +71-79,71-72 +1-99,11-98 +11-12,11-97 +2-75,3-76 +21-79,80-91 +5-49,5-6 +54-55,16-55 +12-97,12-96 +42-83,73-82 +61-84,83-84 +33-82,83-83 +42-85,43-86 +27-71,26-71 +39-39,8-38 +20-25,17-24 +98-99,15-96 +4-92,4-92 +34-82,34-99 +39-43,9-44 +17-29,30-91 +1-98,97-98 +25-92,24-92 +44-68,45-67 +7-22,7-62 +56-95,97-99 +41-79,41-42 +48-89,48-96 +46-96,95-97 +18-88,18-19 +86-87,9-87 +1-1,1-97 +91-97,65-92 +15-80,15-26 +46-98,60-82 +45-70,44-46 +16-83,16-83 +37-55,54-60 +7-57,8-16 +9-27,70-88 +8-72,7-28 +90-91,17-83 +2-64,3-93 +21-46,10-38 +33-88,33-89 +89-90,87-90 +58-59,57-61 +26-94,25-93 +35-48,35-70 +4-75,5-75 +19-22,18-31 +4-94,4-98 +11-74,20-75 +40-67,17-36 +21-22,21-96 +7-43,22-35 +21-89,88-89 +3-44,44-45 +41-62,41-42 +34-60,37-59 +14-69,13-15 +28-76,22-22 +12-51,35-52 +13-98,59-70 +62-91,62-96 +7-88,87-89 +31-32,31-47 +4-99,5-99 +6-9,10-54 +16-33,33-33 +5-97,4-98 +10-52,52-56 +7-8,5-9 +39-66,39-46 +10-45,10-45 +37-89,37-92 +30-31,30-90 +49-82,25-48 +59-71,61-66 +73-87,19-72 +14-97,14-97 +4-63,62-84 +3-97,2-4 +7-64,8-65 +15-16,15-96 +19-66,20-60 +19-35,34-47 +10-10,9-59 +7-9,8-9 +62-99,62-80 +7-92,7-88 +11-42,41-41 +2-2,2-70 +2-68,69-69 +41-81,41-82 +67-96,99-99 +91-93,45-86 +5-87,86-91 +9-13,1-4 +1-97,98-98 +5-27,5-26 +68-86,68-68 +30-40,31-40 +40-81,81-92 +1-91,3-63 +11-96,37-84 +18-61,14-17 +12-75,15-82 +31-52,23-53 +2-74,6-82 +94-95,10-95 +54-54,50-53 +37-68,37-50 +27-75,26-76 +9-30,8-10 +46-74,68-68 +26-39,18-50 +44-45,39-39 +96-97,67-95 +30-90,75-89 +30-85,6-86 +90-92,58-91 +33-36,32-36 +65-96,65-66 +35-69,59-63 +27-47,26-27 +16-86,74-90 +46-78,78-79 +22-85,22-86 +95-95,14-94 +58-59,17-59 +33-58,33-72 +75-75,41-75 +15-35,36-49 +20-90,27-91 +8-69,9-70 +64-99,65-84 +5-80,1-80 +1-2,2-99 +23-32,28-29 +54-56,53-61 +13-56,55-56 +86-87,5-67 +6-88,6-72 +26-95,26-96 +75-85,4-75 +1-44,1-44 +4-7,20-50 +5-96,99-99 +19-69,18-69 +38-91,92-98 +99-99,17-97 +11-22,10-27 +14-76,12-97 +3-54,2-53 +46-81,82-91 +14-15,33-99 +34-35,17-35 +5-79,2-63 +10-57,9-74 +16-38,39-89 +83-86,30-82 +9-72,8-35 +10-70,69-70 +51-86,81-91 +4-72,4-71 +31-91,20-28 +33-98,30-32 +27-87,86-87 +45-45,47-88 +5-57,5-47 +16-90,15-89 +21-99,18-85 +2-34,33-68 +44-58,35-57 +8-65,8-66 +15-39,16-40 +47-67,3-48 +18-84,19-84 +4-98,99-99 +34-77,34-76 +50-50,50-63 +98-99,2-99 +41-95,41-42 +34-48,35-48 +85-94,95-96 +13-38,22-38 +81-82,18-81 +8-86,22-86 +62-97,34-70 +26-73,25-73 +53-58,35-53 +58-80,79-81 +14-41,7-13 +2-21,4-22 +12-98,11-97 +7-73,6-73 +1-94,1-96 +26-82,25-27 +23-76,45-77 +7-78,7-78 +29-72,72-72 +7-8,7-37 +12-24,13-25 +88-91,32-89 +17-76,16-23 +23-40,2-14 +99-99,15-88 +8-85,2-86 +10-89,18-90 +8-97,7-93 +8-98,8-97 +2-12,3-63 +90-90,4-90 +7-23,15-22 +50-96,9-26 +10-80,4-9 +1-85,84-85 +20-22,21-70 +20-83,4-21 +8-32,7-33 +25-45,34-46 +5-34,34-97 +19-91,90-91 +16-96,78-95 +9-64,10-63 +7-8,8-55 +32-50,2-31 +4-16,16-16 +8-99,44-97 +48-73,58-74 +50-80,49-49 +57-58,29-58 +72-76,72-74 +59-75,75-85 +19-98,34-97 +7-94,99-99 +2-95,3-95 +61-78,61-79 +96-98,13-97 +27-82,50-90 +98-99,4-99 +2-95,1-88 +5-66,3-70 +13-26,23-42 +25-55,24-55 +56-56,56-56 +50-98,97-97 +33-85,3-32 +6-45,46-64 +6-57,59-88 +64-72,64-65 +30-92,30-92 +5-46,1-5 +5-89,4-70 +16-69,16-68 +4-88,4-81 +4-94,3-93 +44-47,44-46 +21-38,21-46 +81-86,80-86 +41-96,64-87 +37-73,37-73 +15-75,1-99 +2-36,2-35 +3-94,1-2 +3-87,87-88 +9-9,7-9 +12-97,96-98 +42-89,88-89 +29-85,30-50 +3-4,3-94 +57-92,58-93 +16-95,2-8 +1-98,10-90 +31-65,31-72 +5-87,4-5 +40-45,46-75 +88-95,46-98 +26-87,8-17 +24-27,23-27 +12-99,12-97 +5-99,6-99 +68-77,31-42 +68-91,68-87 +35-35,5-35 +2-66,2-3 +20-32,20-33 +8-88,6-88 +8-82,9-81 +10-97,11-97 +12-59,13-59 +17-32,23-63 +14-15,15-19 +99-99,21-89 +94-99,36-93 +60-65,43-67 +8-97,9-58 +10-52,27-32 +85-91,84-90 +34-88,5-87 +18-43,15-17 +4-99,3-99 +2-97,18-79 +16-56,40-84 +5-5,7-91 +11-97,11-99 +76-77,77-77 +11-90,94-97 +22-23,1-23 +6-43,5-99 +7-85,84-85 +11-12,12-92 +8-89,6-75 +44-64,45-63 +51-95,8-29 +21-54,20-77 +20-87,20-84 +11-25,24-24 +52-54,52-55 +15-16,19-66 +54-91,13-53 +35-98,35-41 +47-48,6-48 +83-89,82-83 +27-83,26-28 +38-92,93-96 +51-76,51-63 +1-3,7-13 +10-96,11-47 +58-98,2-95 +69-69,61-73 +4-89,2-3 +7-58,3-15 +76-93,8-94 +5-20,4-19 +16-23,16-17 +30-85,31-85 +16-70,15-16 +67-67,52-68 +30-99,29-31 +49-71,55-70 +32-94,94-94 +82-93,24-83 +31-94,32-40 +62-79,62-80 +9-84,9-9 +8-97,1-97 +36-37,36-51 +76-77,53-77 +47-49,17-48 +73-75,55-77 +50-85,51-86 +63-63,53-62 +5-15,5-5 +19-99,19-90 +2-63,2-22 +21-75,22-22 +18-97,19-69 +79-92,11-91 +13-23,23-23 +4-94,3-3 +6-82,19-83 +34-50,35-37 +15-99,15-96 +5-58,4-57 +19-56,46-93 +11-73,12-78 +37-42,26-41 +53-65,30-39 +46-47,45-47 +56-99,55-97 +82-86,44-83 +49-55,37-48 +3-96,96-96 +46-52,45-52 +2-36,9-37 +99-99,1-99 +11-70,18-91 +60-75,74-75 +6-97,6-96 +33-66,4-95 +15-58,34-59 +19-86,18-19 +25-43,30-81 +11-66,10-65 +2-49,1-99 +55-77,76-78 +61-87,75-79 +3-93,2-92 +2-2,5-56 +5-99,9-98 +34-46,46-84 +35-36,35-86 +15-17,16-43 +46-51,50-55 +8-8,7-17 +5-98,4-87 +44-58,43-58 +5-41,5-42 +6-27,10-16 +78-78,40-79 +17-88,29-87 +12-69,12-69 +26-78,26-58 +77-95,95-95 +42-49,46-48 +19-69,19-97 +33-77,76-76 +47-49,48-76 +3-99,3-4 +7-34,33-34 +61-91,92-99 +67-83,9-83 +10-91,90-91 +42-83,42-43 +29-31,35-90 +8-80,8-74 +8-95,8-99 +7-80,5-8 +5-12,11-12 +8-89,7-93 +42-93,42-94 +29-85,28-84 +72-72,72-90 +59-77,77-77 +96-99,23-97 +16-30,30-84 +8-69,8-68 +2-98,2-98 +44-98,43-98 +5-6,5-98 +9-90,11-51 +1-3,2-98 +15-69,55-70 +6-94,6-94 +88-89,21-89 +62-79,78-78 +2-71,47-72 +53-61,22-60 +93-97,10-92 +64-64,65-70 +10-10,6-13 +21-78,81-95 +88-94,2-88 +13-62,13-14 +67-67,58-67 +33-38,13-39 +40-51,4-39 +18-86,86-92 +10-97,10-97 +5-13,10-40 +4-94,3-5 +11-71,10-12 +27-31,25-27 +6-95,4-4 +5-99,14-98 +12-71,57-72 +39-76,39-76 +57-76,48-81 +20-64,20-94 +25-25,24-26 +14-74,8-13 +5-92,5-91 +1-96,1-96 +8-51,4-56 +5-95,15-96 +24-80,30-45 +31-98,31-94 +1-33,33-56 +38-54,23-39 +61-83,43-77 +30-38,13-37 +10-71,10-11 +41-59,42-60 +4-49,5-50 +14-14,2-85 +4-7,1-2 +91-92,3-91 +3-78,23-77 +13-74,85-96 +53-86,14-33 +67-95,66-94 +12-13,12-93 +4-99,3-47 +19-86,20-85 +5-98,5-90 +3-89,3-90 +66-67,63-67 +55-72,14-71 +4-5,5-80 +17-94,16-94 +18-71,36-70 +45-49,44-49 +27-90,27-82 +15-31,15-30 +8-57,28-98 +1-41,1-42 +19-20,19-41 +15-92,91-92 +37-73,10-36 +26-63,63-71 +27-30,28-81 +22-87,22-23 +56-56,1-56 +59-89,27-58 +88-89,56-87 +32-39,32-66 +96-96,2-97 +25-56,24-56 +3-94,4-95 +20-93,5-92 +16-70,42-71 +4-89,8-90 +20-83,20-82 +31-88,30-88 +73-73,3-72 +11-97,9-99 +3-23,22-52 +21-96,20-83 +4-65,5-21 +37-37,8-37 +4-95,2-4 +10-71,11-73 +35-81,36-81 +1-5,6-79 +28-39,27-39 +2-92,1-85 +12-97,62-96 +20-91,21-91 +88-98,3-70 +20-66,74-76 +84-99,47-84 +17-95,18-93 +57-78,49-78 +15-17,16-81 +51-84,41-54 +49-74,22-92 diff --git a/src/day04.rs b/src/day04.rs new file mode 100644 index 0000000..42302fd --- /dev/null +++ b/src/day04.rs @@ -0,0 +1,54 @@ +use regex::Regex; + +type Pair = ((i32, i32), (i32, i32)); + +pub fn parse(s: &str) -> Vec { + let mut sections = Vec::new(); + let r = Regex::new(r"^(\d+)-(\d+),(\d+)-(\d+)$").unwrap(); + for l in s.lines() { + let cap = r.captures(l).unwrap(); + sections.push(((cap[1].parse::().unwrap(), cap[2].parse::().unwrap()), (cap[3].parse::().unwrap(), cap[4].parse::().unwrap()))); + } + return sections; +} + +pub fn number_fully_contain(pairs: &[Pair]) -> i32 { + pairs.iter().filter_map(|((a1, a2), (b1, b2))| { + if a1 <= b1 && a2 >= b2 || b1 <= a1 && b2 >= a2 { Some(1) } else { None } + }).sum() +} + +pub fn number_overlaps(pairs: &[Pair]) -> i32 { + pairs.iter().filter_map(|((a1, a2), (b1, b2))| { + if a2 >= b1 && a1 <= b2 { Some(1) } else { None } + }).sum() +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn part1() { + let pairs ="2-4,6-8 +2-3,4-5 +5-7,7-9 +2-8,3-7 +6-6,4-6 +2-6,4-8"; + + assert_eq!(number_fully_contain(&parse(pairs)), 2); + } + + #[test] + fn part2() { + let pairs ="2-4,6-8 +2-3,4-5 +5-7,7-9 +2-8,3-7 +6-6,4-6 +2-6,4-8"; + + assert_eq!(number_overlaps(&parse(pairs)), 4); + } +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index e7b4bed..014c31d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ mod common; mod day01; mod day02; mod day03; +mod day04; fn day01() -> String { let f = fs::File::open("data/day01.input").unwrap(); @@ -24,6 +25,11 @@ fn day03() -> String { format!("part1: {}, part2: {}", day03::priority_sum(&rucksacks), day03::badge_sum(&rucksacks)) } +fn day04() -> String { + let pairs = day04::parse(&fs::read_to_string("data/day04.input").unwrap()); + format!("part1: {}, part2: {}", day04::number_fully_contain(&pairs), day04::number_overlaps(&pairs)) +} + fn format_micros(t: u128) -> String { if t < 10_000 { format!("{} μs", t) @@ -46,6 +52,7 @@ fn main() { day01, day02, day03, + day04, ); let args: Vec = env::args().skip(1).collect(); -- 2.45.2