diff --git a/day4/Cargo.lock b/day4/Cargo.lock new file mode 100644 index 0000000..ba800e1 --- /dev/null +++ b/day4/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "advent_of_code_day4" +version = "0.0.1" diff --git a/day4/Cargo.toml b/day4/Cargo.toml new file mode 100644 index 0000000..a79f33b --- /dev/null +++ b/day4/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "advent_of_code_day4" +version = "0.0.1" +authors = ["Peery"] +edition = "2021" + +[dependencies] diff --git a/day4/input/debug.lst b/day4/input/debug.lst new file mode 100644 index 0000000..bb35171 --- /dev/null +++ b/day4/input/debug.lst @@ -0,0 +1 @@ +2-4,6-8 diff --git a/day4/input/example_sections.lst b/day4/input/example_sections.lst new file mode 100644 index 0000000..99a66c5 --- /dev/null +++ b/day4/input/example_sections.lst @@ -0,0 +1,6 @@ +2-4,6-8 +2-3,4-5 +5-7,7-9 +2-8,3-7 +6-6,4-6 +2-6,4-8 \ No newline at end of file diff --git a/day4/input/input.lst b/day4/input/input.lst new file mode 100644 index 0000000..f1311b8 --- /dev/null +++ b/day4/input/input.lst @@ -0,0 +1,1000 @@ +31-31,32-40 +26-92,13-91 +9-90,29-91 +72-72,25-73 +28-79,79-79 +52-77,53-53 +17-54,17-54 +11-47,4-10 +1-96,1-97 +38-99,39-63 +19-54,18-53 +1-73,1-73 +17-34,18-34 +93-93,25-94 +96-98,7-95 +58-97,73-98 +7-64,8-64 +87-91,67-90 +42-78,77-85 +24-96,24-97 +71-78,72-97 +5-28,27-29 +19-86,86-90 +19-85,20-20 +64-65,1-64 +28-78,27-81 +79-91,80-95 +32-89,32-82 +3-96,2-4 +70-83,15-70 +5-90,8-91 +16-60,16-61 +38-97,39-90 +25-56,6-55 +12-14,13-13 +11-95,11-96 +13-16,12-22 +15-29,14-72 +68-88,67-69 +23-95,94-97 +63-77,62-64 +19-69,20-85 +23-63,61-62 +7-47,6-47 +39-86,39-86 +98-99,4-98 +4-6,5-88 +41-89,88-89 +14-95,96-98 +6-62,3-62 +1-68,6-68 +25-90,40-90 +11-81,10-12 +2-91,1-91 +35-62,27-61 +14-28,14-28 +13-78,14-79 +51-52,46-52 +6-77,77-78 +98-99,50-98 +7-23,24-85 +38-56,38-62 +96-99,1-97 +32-32,31-31 +5-89,4-6 +22-84,21-85 +14-40,39-89 +40-91,40-91 +3-6,4-60 +48-59,60-60 +2-92,2-92 +34-35,7-34 +32-64,33-64 +36-56,36-55 +95-96,44-96 +91-99,37-92 +10-98,11-96 +24-68,69-94 +98-99,37-98 +99-99,6-87 +11-90,11-12 +76-87,36-77 +19-97,10-99 +47-77,78-93 +96-96,21-96 +50-97,99-99 +3-50,2-81 +18-69,19-69 +17-92,16-16 +18-72,19-72 +1-76,5-77 +14-97,98-99 +28-90,19-89 +19-47,47-48 +10-97,9-97 +11-96,11-85 +20-22,20-97 +1-94,1-95 +49-52,48-53 +3-3,3-34 +12-97,85-96 +49-84,48-84 +3-89,89-90 +68-96,41-96 +69-80,2-65 +16-81,16-81 +1-96,95-99 +49-99,49-94 +28-92,91-95 +2-95,1-99 +12-30,8-31 +21-68,26-69 +6-31,2-31 +49-66,49-65 +55-67,55-68 +21-50,20-44 +14-42,15-43 +70-89,70-89 +3-99,1-3 +7-86,6-37 +58-71,68-71 +55-83,55-82 +61-99,11-99 +83-83,3-84 +25-82,25-81 +14-48,15-54 +97-98,13-96 +25-63,63-63 +4-81,37-82 +12-98,98-98 +31-34,33-56 +3-83,1-82 +33-99,99-99 +96-99,39-97 +82-84,43-77 +95-99,1-96 +83-84,6-83 +58-60,58-58 +51-92,92-93 +93-93,33-93 +1-93,92-97 +16-16,16-31 +10-55,54-55 +56-64,63-70 +18-88,10-19 +55-95,5-95 +62-77,48-61 +3-65,56-65 +54-55,55-56 +22-70,23-70 +18-91,18-18 +91-98,2-99 +9-56,8-56 +84-92,17-83 +98-98,25-99 +22-63,66-84 +4-50,2-5 +12-13,12-49 +30-85,31-79 +57-83,57-87 +13-79,13-79 +30-38,17-87 +64-65,5-64 +99-99,29-99 +28-75,7-27 +3-79,3-67 +10-90,24-89 +10-53,83-91 +39-74,35-39 +52-78,53-78 +2-87,3-95 +58-68,57-68 +6-32,31-51 +18-36,18-35 +3-99,3-99 +8-81,7-80 +50-53,51-52 +91-92,84-92 +19-91,5-18 +40-68,68-69 +30-90,52-91 +20-27,19-26 +98-99,99-99 +27-58,28-58 +61-61,45-62 +67-75,60-77 +69-70,68-72 +1-96,4-93 +2-95,38-96 +56-57,11-56 +54-84,6-53 +65-85,5-66 +22-84,21-84 +50-64,51-53 +7-75,74-81 +34-69,34-70 +35-35,6-35 +8-96,69-96 +13-98,13-97 +80-80,55-81 +16-62,6-98 +2-87,63-87 +84-91,7-92 +3-3,4-98 +3-80,52-80 +80-94,11-79 +2-95,1-71 +31-96,95-95 +9-65,64-65 +61-69,60-97 +2-99,2-98 +18-73,19-21 +80-80,80-82 +47-70,47-71 +13-30,23-30 +16-41,17-41 +3-13,12-79 +72-75,73-87 +13-13,13-81 +29-74,30-73 +24-43,7-42 +1-93,92-93 +4-47,4-93 +8-10,9-96 +2-87,5-88 +51-61,50-64 +60-64,60-63 +26-66,27-73 +13-85,14-86 +42-43,42-92 +45-72,44-44 +83-83,84-99 +3-5,6-97 +10-92,10-10 +43-69,44-69 +49-50,15-50 +4-91,4-91 +51-52,20-51 +7-84,1-96 +6-76,5-76 +15-19,14-14 +57-68,46-69 +80-80,3-81 +4-93,7-92 +37-40,38-41 +8-49,16-49 +6-86,86-87 +71-85,71-85 +35-68,69-96 +57-96,2-56 +13-33,5-32 +14-97,14-97 +83-98,60-99 +4-24,10-25 +1-84,2-84 +75-86,70-74 +22-79,1-78 +94-94,10-93 +6-70,7-70 +25-56,16-20 +2-87,1-88 +50-52,51-92 +2-68,3-42 +3-93,92-92 +8-97,96-96 +90-93,77-94 +61-98,6-99 +30-47,16-47 +27-92,26-26 +18-32,19-32 +23-76,19-21 +8-43,23-44 +9-93,10-93 +64-85,84-86 +2-88,88-89 +51-77,32-78 +53-83,25-52 +74-97,74-99 +99-99,7-98 +3-96,3-96 +67-67,68-69 +3-96,2-99 +18-95,17-19 +41-43,42-59 +3-5,5-5 +4-98,3-98 +41-69,70-88 +21-90,20-89 +76-78,77-81 +12-47,46-46 +33-85,34-84 +12-14,13-91 +46-59,45-59 +73-79,72-94 +7-18,6-8 +35-94,94-95 +15-18,15-18 +22-94,23-68 +15-16,15-81 +71-71,39-72 +61-61,11-62 +38-69,84-98 +76-80,76-79 +8-71,71-72 +27-94,28-71 +5-34,5-69 +48-62,35-61 +30-30,31-95 +45-96,95-99 +27-86,28-87 +72-72,44-72 +3-90,2-96 +31-98,30-71 +77-77,8-78 +19-99,18-20 +96-96,88-97 +10-30,7-8 +46-94,46-94 +9-34,33-96 +34-79,7-78 +31-77,32-76 +25-50,26-49 +37-70,36-38 +31-58,32-58 +12-97,12-98 +85-91,7-86 +57-77,4-78 +18-64,64-64 +73-74,72-74 +1-42,1-2 +30-99,37-98 +35-97,31-97 +17-57,57-58 +65-86,19-85 +27-95,50-97 +16-75,3-74 +44-87,86-94 +4-52,3-8 +31-96,95-95 +13-39,1-40 +29-95,71-95 +8-93,6-6 +1-97,2-98 +2-9,10-90 +22-24,19-23 +12-95,31-87 +1-77,7-78 +10-83,3-9 +60-88,60-87 +46-76,41-75 +21-57,20-57 +70-86,70-99 +46-56,55-72 +4-80,14-20 +14-55,13-71 +4-21,3-22 +2-91,2-92 +10-54,9-55 +1-3,2-98 +2-94,1-97 +3-89,3-4 +3-91,10-90 +11-13,10-68 +70-79,69-71 +42-77,42-77 +16-97,1-97 +18-82,82-86 +8-51,8-60 +21-70,20-70 +4-93,5-92 +46-46,6-45 +9-88,8-88 +26-92,15-91 +16-17,16-66 +58-65,7-65 +19-21,20-54 +48-93,48-93 +42-86,43-85 +28-44,28-44 +13-13,14-97 +10-72,73-73 +94-94,15-95 +44-67,26-66 +16-97,15-94 +74-74,9-75 +8-43,1-51 +33-58,34-57 +25-29,54-79 +21-77,29-76 +30-31,30-93 +88-96,42-87 +11-92,10-93 +25-72,2-73 +1-99,4-99 +33-56,33-80 +16-93,15-94 +36-39,34-38 +31-68,31-31 +20-89,88-90 +87-87,43-87 +12-14,11-14 +5-27,5-28 +28-70,71-71 +16-98,25-97 +13-89,12-12 +27-33,10-34 +97-99,54-95 +12-84,85-89 +39-58,40-57 +43-44,43-54 +92-94,93-95 +47-48,47-87 +10-31,9-30 +5-96,4-97 +67-70,67-71 +20-52,53-72 +44-65,38-66 +34-55,34-94 +1-98,6-89 +4-83,57-82 +94-95,4-93 +57-58,17-58 +8-38,5-9 +5-88,87-87 +17-76,75-77 +5-9,5-10 +31-36,28-31 +50-50,44-51 +19-89,19-89 +34-54,35-96 +54-60,32-64 +56-78,56-77 +39-39,39-39 +21-22,20-21 +52-76,51-53 +62-89,63-71 +40-85,40-70 +5-15,16-90 +42-83,41-46 +40-98,4-98 +29-94,28-54 +62-92,91-98 +8-94,9-93 +83-88,51-88 +4-60,7-60 +41-72,41-49 +31-57,51-56 +49-99,49-94 +79-79,10-80 +21-86,57-87 +42-44,23-43 +7-94,8-94 +24-32,24-33 +32-51,39-52 +12-28,27-82 +50-63,50-97 +58-64,64-64 +72-72,73-77 +51-65,51-51 +41-98,42-98 +97-98,1-97 +5-76,5-75 +83-93,42-92 +87-87,2-88 +26-41,26-27 +68-71,67-70 +61-62,36-62 +6-66,1-31 +57-73,15-72 +11-97,96-97 +4-99,4-98 +22-54,22-54 +18-43,43-43 +2-39,3-7 +24-91,99-99 +98-98,48-97 +3-70,3-71 +71-85,81-84 +93-98,2-92 +79-86,9-80 +30-61,60-83 +31-37,23-36 +25-95,26-95 +43-56,42-69 +18-28,5-27 +11-87,12-86 +58-99,59-97 +3-3,3-70 +31-41,17-30 +14-27,14-15 +2-70,3-94 +2-93,1-93 +38-90,39-79 +57-99,1-79 +70-95,70-78 +24-89,23-88 +4-84,19-83 +46-70,5-47 +10-70,71-73 +13-95,14-95 +48-52,49-52 +20-22,21-21 +88-88,1-88 +39-84,45-83 +28-75,28-75 +17-17,17-95 +3-98,97-97 +9-21,9-97 +28-37,27-34 +32-47,32-46 +13-28,27-72 +43-65,5-43 +22-48,47-48 +8-90,91-95 +51-53,10-52 +34-65,30-65 +1-98,1-2 +65-79,13-79 +74-74,13-75 +31-33,32-99 +4-95,38-94 +10-90,90-91 +62-62,4-61 +14-24,24-46 +4-85,10-84 +15-83,14-83 +1-85,3-86 +12-12,13-13 +15-89,14-90 +72-94,23-73 +11-69,8-68 +20-90,16-17 +5-95,32-96 +49-71,49-91 +22-89,22-89 +4-43,5-5 +51-98,15-97 +85-85,28-85 +18-61,18-81 +88-89,56-88 +71-79,72-79 +3-84,19-85 +18-18,19-85 +15-15,4-15 +46-71,44-71 +56-88,7-89 +37-50,36-51 +84-84,55-83 +14-27,15-26 +74-76,22-75 +77-99,77-95 +13-44,20-45 +6-95,12-96 +11-41,10-12 +10-76,17-77 +8-84,9-85 +14-64,13-15 +5-82,3-3 +43-53,42-44 +14-74,2-75 +12-97,12-98 +59-93,93-94 +17-81,15-82 +87-91,24-92 +8-84,9-84 +20-94,93-99 +46-97,97-98 +87-97,52-97 +2-90,3-91 +36-74,38-73 +55-59,55-55 +49-69,48-59 +54-62,54-96 +49-74,10-48 +27-78,26-26 +31-31,29-30 +2-76,1-90 +10-98,7-97 +14-15,14-93 +24-95,95-98 +13-23,22-23 +6-66,5-5 +85-86,66-86 +3-97,96-99 +1-93,1-90 +27-77,27-28 +51-64,51-51 +13-83,6-83 +40-54,53-54 +3-94,1-4 +15-29,15-28 +6-83,84-95 +62-62,8-63 +12-76,13-76 +3-7,5-7 +10-93,11-98 +28-28,28-63 +11-34,10-98 +6-8,7-49 +8-22,6-34 +29-47,29-49 +97-97,53-80 +20-99,21-75 +3-56,7-57 +43-63,43-64 +3-99,2-99 +24-99,24-25 +40-41,40-59 +60-63,60-60 +13-87,3-14 +70-88,25-88 +39-96,96-97 +11-53,12-52 +35-48,48-49 +11-53,9-25 +65-75,74-91 +74-80,80-80 +10-12,12-13 +46-73,74-84 +4-80,81-99 +4-84,83-91 +6-86,40-79 +46-82,22-81 +15-40,16-39 +5-86,45-93 +4-31,3-5 +40-84,31-83 +6-88,5-88 +8-79,12-80 +10-94,9-95 +81-81,23-81 +9-28,1-9 +47-99,46-83 +24-41,24-85 +10-67,9-35 +28-61,16-61 +6-6,7-71 +42-87,10-99 +97-97,2-97 +38-43,37-44 +15-86,15-87 +3-93,3-4 +85-86,84-87 +3-94,1-3 +32-47,47-47 +47-47,28-48 +4-97,4-98 +11-18,37-61 +31-38,30-38 +1-37,3-37 +23-60,61-99 +93-98,37-94 +8-97,9-97 +59-95,59-59 +81-87,13-80 +6-97,4-16 +15-27,27-73 +12-95,4-96 +54-96,22-55 +72-76,71-81 +5-94,6-92 +24-78,25-78 +55-64,52-63 +51-65,59-64 +32-87,32-58 +7-58,34-58 +29-83,29-82 +3-94,3-95 +84-84,71-85 +4-98,3-5 +17-36,18-37 +38-49,37-50 +14-61,94-99 +61-82,96-96 +25-98,98-99 +63-78,64-64 +43-49,42-50 +43-47,43-47 +14-62,23-63 +7-97,9-64 +49-82,49-90 +2-59,2-60 +53-85,53-86 +1-99,56-99 +26-92,26-60 +70-83,2-52 +54-55,54-85 +37-71,70-77 +87-91,15-92 +11-61,12-61 +9-9,7-10 +22-53,20-54 +88-89,1-88 +9-80,79-91 +43-85,43-59 +34-88,35-87 +9-98,24-97 +80-85,7-79 +9-38,38-39 +56-56,56-67 +79-90,79-89 +29-61,60-61 +1-95,1-96 +60-66,60-66 +41-75,74-74 +18-55,54-77 +4-98,3-97 +5-14,2-13 +9-51,9-55 +26-62,35-63 +85-97,84-96 +2-99,98-98 +67-94,67-94 +10-18,17-96 +12-99,13-13 +8-99,10-99 +20-28,21-27 +77-87,58-78 +38-51,38-59 +19-90,19-59 +24-98,37-74 +49-88,28-89 +18-85,84-85 +36-48,37-48 +70-92,91-93 +45-50,45-91 +82-93,44-50 +1-97,97-99 +45-58,44-59 +4-21,20-78 +56-83,57-57 +92-92,25-92 +33-36,35-35 +17-86,22-74 +12-86,86-87 +36-41,2-40 +34-34,35-35 +12-95,94-98 +88-89,32-99 +13-90,12-31 +3-90,1-1 +9-96,9-99 +8-60,13-61 +91-96,97-97 +19-58,18-20 +4-4,4-76 +2-57,2-75 +97-99,18-93 +15-37,38-86 +55-94,54-87 +15-35,16-94 +15-57,59-97 +14-90,14-91 +25-53,54-54 +87-97,86-97 +8-13,48-75 +5-80,3-3 +65-79,65-78 +1-73,72-73 +67-69,46-67 +50-67,49-67 +23-59,22-59 +2-27,1-96 +14-33,1-32 +30-82,16-30 +8-18,14-19 +30-30,27-30 +99-99,11-56 +25-26,25-38 +61-66,65-65 +44-77,93-97 +36-36,37-93 +11-45,10-10 +32-57,31-56 +98-99,41-96 +98-99,11-99 +6-8,7-79 +18-87,45-87 +22-84,22-92 +3-91,9-81 +5-78,6-78 +1-83,82-95 +54-61,54-61 +67-86,66-94 +17-85,17-86 +41-41,41-66 +57-68,14-67 +6-7,7-96 +10-96,72-98 +21-73,20-74 +35-98,9-97 +98-98,12-99 +6-48,5-96 +18-96,97-98 +19-21,20-52 +10-71,1-72 +2-35,2-2 +13-85,85-86 +29-81,81-82 +5-77,78-96 +40-41,28-41 +2-92,1-91 +7-81,28-82 +38-72,37-39 +58-85,25-85 +3-43,2-4 +30-58,31-79 +73-76,22-74 +43-73,44-74 +47-83,46-82 +64-92,63-69 +49-90,90-90 +11-98,11-97 +45-83,44-64 +18-65,38-65 +7-97,6-98 +9-67,11-77 +10-99,9-98 +11-41,10-58 +91-91,20-44 +2-99,2-98 +69-77,70-81 +45-73,46-55 +16-17,16-17 +13-76,75-81 +9-38,9-18 +42-64,3-41 +2-8,7-54 +53-58,28-59 +86-87,2-86 +93-93,13-94 +99-99,17-98 +55-63,60-60 +9-54,8-54 +89-95,94-95 +30-87,86-86 +14-16,15-96 +9-90,8-8 +41-95,40-94 +75-91,88-91 +9-13,8-10 +5-93,93-93 +19-41,19-41 +58-65,57-59 +56-99,55-70 +76-76,3-68 +98-98,46-92 +73-89,74-76 +78-93,26-78 +26-26,27-77 +57-76,75-75 +64-82,64-98 +64-91,21-80 +30-65,64-64 +43-43,43-87 +29-93,28-92 +94-95,13-95 +23-95,22-86 +18-85,84-84 +23-34,22-99 +82-84,77-84 +11-30,11-31 +6-34,33-34 +19-59,19-60 +4-66,65-72 +57-75,24-58 +26-55,34-54 +23-62,17-61 +1-89,3-92 +20-38,20-37 +10-98,10-11 +5-93,58-87 +89-90,62-90 +69-70,38-69 +36-63,62-63 +38-49,39-92 +86-87,22-87 +99-99,52-78 +16-99,16-92 +62-64,63-64 +87-88,69-87 +55-78,69-78 +5-15,15-72 +52-60,16-61 +4-97,1-96 +2-85,19-85 +5-10,1-22 +37-81,31-82 +21-91,12-90 +70-71,37-70 +64-64,65-92 +40-93,94-98 +38-84,83-85 +44-97,44-98 +31-31,10-31 +28-96,27-27 +32-79,35-78 +72-93,8-88 +7-77,7-58 +8-93,2-8 +5-91,28-90 +2-96,1-96 +52-56,51-54 +8-85,6-85 +4-84,6-49 +9-98,2-8 +61-97,46-60 +95-96,66-94 +98-98,86-99 +27-28,27-97 +54-85,55-86 +91-91,35-90 +4-89,10-88 +6-97,5-80 +34-57,35-37 +6-98,6-98 +12-67,31-68 +35-93,34-36 +11-60,39-61 +66-81,40-96 +57-57,8-56 +15-79,10-80 +78-79,27-79 +45-62,46-63 +14-35,35-71 +12-49,11-13 +51-67,67-67 +67-68,54-68 +55-93,13-41 +22-91,21-23 +92-95,88-96 +82-94,82-94 +99-99,2-97 +6-46,6-46 +39-75,1-40 +8-54,54-55 +78-93,77-93 +67-95,95-95 +2-4,3-98 +17-95,94-94 +36-51,42-50 +1-95,1-94 +67-96,67-95 +7-78,3-77 +18-48,17-47 +76-96,5-95 +45-45,21-46 +48-76,47-76 +36-38,33-38 +17-33,13-70 +78-93,78-78 +3-50,2-50 +8-8,8-84 +33-97,33-96 +51-53,52-87 +21-42,22-42 +98-99,2-98 +8-99,8-97 +41-51,41-51 +20-75,68-74 +2-98,98-99 +46-95,68-88 +16-69,68-97 +41-96,95-97 +1-98,1-98 +35-93,35-97 +54-66,1-97 +29-98,29-97 +44-44,44-67 +7-69,69-69 +3-74,73-73 +8-78,9-75 +43-51,51-52 +13-49,48-48 +42-76,3-76 +16-50,9-55 +62-71,62-71 +79-98,7-66 +43-58,58-58 +25-30,25-54 +2-17,16-27 +88-99,15-87 +33-94,94-94 +9-11,10-43 +38-97,39-95 +17-58,18-57 +25-97,17-62 +9-19,10-26 +87-88,86-87 +23-58,22-59 +49-96,49-49 +64-81,31-70 +3-85,2-86 +10-10,9-28 +9-51,5-9 +49-57,48-57 +1-65,3-66 +54-70,70-71 +2-61,1-60 +90-98,57-91 diff --git a/day4/src/main.rs b/day4/src/main.rs new file mode 100644 index 0000000..6e711ea --- /dev/null +++ b/day4/src/main.rs @@ -0,0 +1,84 @@ +#![crate_name = "advent_of_code_day4"] + +//use std::env; +use std::fs; +use std::path::{Path}; + +fn parse_sectors(input: &str) -> Vec>> { + /// Parse the given string for the sector starts and ends. + /// + /// # Arguments + /// * `input` - A string directly read from the file + assert!(!input.is_empty()); + let lines: Vec<&str> = input.split("\n").collect(); + + let mut sector_groups: Vec>> = Vec::new(); // <[<1,2,3>, <3,4,5>]> + for line in &lines { + let secs_str: Vec<&str> = line.split(",").collect(); // splitting into sector ranges, ["1-3", "3-5"] + if secs_str.len() != 2 { + continue + } + let mut line_vector: Vec> = Vec::new(); + + // str_range_exp = "1-3" + + let str_range_params: Vec<&str> = secs_str[0].split("-").collect(); + let mut range: Vec = Vec::new(); + for i in str_range_params[0].parse::().unwrap()..(str_range_params[1].parse::().unwrap()+1) { + range.push(i); + } + line_vector.push(range.clone()); + + let str_range_params: Vec<&str> = secs_str[1].split("-").collect(); + let mut range: Vec = Vec::new(); + for i in str_range_params[0].parse::().unwrap()..(str_range_params[1].parse::().unwrap()+1) { + range.push(i); + } + line_vector.push(range.clone()); + + sector_groups.push(line_vector); + } + //println!("My Ranges are: {:?}", sector_groups); + + return sector_groups; +} + +fn check_for_overlaps(pair: &Vec>) -> Vec { + /// Checks the given two lust of values for overlaps in each other. + /// If there are overlaps a vector of them is returned. + /// If not an empty array is returned + assert!(pair.len() == 2); + + let mut overlaps: Vec = Vec::new(); + + for value in &pair[0] { + if pair[1].contains(value) { + overlaps.push(*value); + } + } + + return overlaps; +} + +fn main() { + let input_path = Path::new("./input/input.lst"); + + let contents = fs::read_to_string(input_path).unwrap(); + //println!("My given file: \n{}", contents); + + let sector_pairs: Vec>> = parse_sectors(&contents); + let mut complete_overlap_count = 0; + + for pair in §or_pairs { + let overlaps: Vec = check_for_overlaps(&pair); + //println!("Overlap is: {:?}", overlaps); + + if overlaps.len() == pair[0].len() || overlaps.len() == pair[1].len() { + println!("Found a complete overlap in the following pair: {:?}", pair); + complete_overlap_count += 1; + } + } + + println!(); + println!("Found {} pairs with complete overlaps!", complete_overlap_count); +} \ No newline at end of file