From 394e3c175ce6ed665535266b549e39837b6f8f4d Mon Sep 17 00:00:00 2001 From: Kalle Struik Date: Sun, 4 Dec 2022 23:29:55 +0100 Subject: [PATCH] Day 4 --- input/04.txt | 1000 +++++++++++++++++++++++++++++++++++++++++++++++ src/bin/04_1.rs | 41 ++ src/bin/04_2.rs | 41 ++ 3 files changed, 1082 insertions(+) create mode 100644 input/04.txt create mode 100644 src/bin/04_1.rs create mode 100644 src/bin/04_2.rs diff --git a/input/04.txt b/input/04.txt new file mode 100644 index 0000000..c84044f --- /dev/null +++ b/input/04.txt @@ -0,0 +1,1000 @@ +7-96,6-95 +36-41,35-40 +35-84,83-91 +95-96,5-95 +3-3,4-99 +12-21,21-22 +10-28,10-28 +6-11,10-12 +12-91,76-98 +17-69,18-69 +26-81,7-27 +26-42,57-80 +32-38,33-38 +4-83,5-83 +33-85,34-86 +14-95,6-78 +79-84,78-87 +12-61,11-62 +56-92,55-92 +34-63,9-34 +33-44,33-85 +5-17,16-26 +21-43,21-32 +12-60,59-60 +10-48,10-49 +94-94,71-94 +45-46,24-46 +81-97,82-98 +5-27,27-57 +3-96,2-22 +5-92,2-97 +53-87,76-90 +68-83,82-82 +55-67,55-73 +39-79,78-78 +81-86,87-97 +3-25,2-67 +50-63,62-62 +5-96,5-97 +27-88,28-88 +19-53,20-53 +55-89,55-90 +43-46,43-99 +82-95,56-96 +8-57,8-8 +90-95,2-90 +56-78,34-81 +53-81,54-81 +20-30,9-62 +12-83,11-16 +64-65,63-69 +15-95,15-94 +6-94,4-93 +36-93,8-92 +67-74,68-74 +4-89,5-89 +23-24,22-23 +44-53,45-80 +43-60,43-83 +61-69,62-78 +77-77,25-77 +43-65,43-66 +12-65,13-84 +54-56,54-97 +13-34,33-60 +20-55,55-56 +34-93,35-92 +26-85,27-96 +51-97,9-97 +18-41,17-40 +3-14,14-80 +55-66,8-56 +4-89,64-98 +20-98,20-63 +1-16,15-22 +20-93,41-92 +9-86,8-10 +5-27,27-28 +29-51,30-48 +44-64,44-44 +29-96,2-96 +1-98,13-97 +6-84,18-84 +28-81,27-72 +7-95,6-95 +43-84,78-84 +2-62,35-98 +46-88,9-88 +11-19,10-18 +21-81,22-89 +98-99,78-98 +26-57,25-57 +12-31,10-30 +31-84,32-85 +93-93,91-93 +10-89,8-76 +6-36,7-36 +51-96,95-99 +14-32,5-17 +23-37,34-38 +14-15,22-82 +95-96,72-95 +38-52,53-53 +25-94,25-96 +38-74,37-74 +73-94,41-73 +72-85,35-84 +15-98,14-16 +81-94,82-94 +85-89,85-87 +3-87,3-83 +84-93,4-91 +42-57,42-50 +42-80,23-42 +18-26,18-27 +44-58,44-99 +35-68,3-67 +40-97,41-53 +11-99,12-12 +7-51,12-59 +13-71,68-71 +5-12,4-97 +8-20,20-79 +13-91,12-14 +33-62,18-32 +3-94,5-94 +26-98,26-93 +31-38,30-85 +13-83,14-82 +6-74,73-74 +73-73,45-62 +38-38,38-38 +9-21,4-20 +14-60,13-83 +83-90,83-89 +73-73,6-74 +1-3,3-94 +3-84,3-85 +61-90,81-97 +93-93,23-94 +31-81,81-81 +26-76,75-75 +95-96,94-94 +70-72,71-89 +95-95,4-95 +10-70,9-11 +3-99,4-98 +26-99,26-92 +77-95,78-90 +47-82,48-83 +4-83,82-88 +51-51,42-50 +10-86,11-96 +9-46,39-49 +20-78,20-79 +1-62,2-61 +57-59,58-75 +4-90,28-90 +4-4,4-52 +34-81,35-96 +32-68,67-83 +83-87,84-88 +71-96,71-71 +61-96,95-99 +3-99,1-4 +13-94,12-95 +13-86,14-95 +36-89,35-88 +8-12,12-96 +34-55,33-55 +43-55,56-95 +38-39,7-38 +3-48,47-98 +86-86,5-86 +4-64,4-4 +80-97,41-98 +16-16,30-54 +3-94,4-94 +16-90,15-91 +7-19,7-84 +64-79,8-79 +29-94,94-95 +25-86,24-85 +91-95,90-93 +3-54,3-96 +4-92,6-95 +14-14,14-70 +65-82,83-83 +5-80,18-35 +63-88,44-52 +3-65,1-21 +34-87,49-49 +92-94,48-93 +3-96,3-95 +52-70,51-75 +64-64,7-64 +20-53,21-63 +3-9,6-10 +49-93,50-94 +38-97,38-94 +91-95,92-96 +38-43,38-45 +73-74,19-73 +26-83,82-83 +71-72,71-71 +6-97,6-98 +67-93,90-94 +39-97,40-97 +10-33,33-40 +35-84,34-93 +5-72,73-73 +15-98,14-66 +24-66,25-84 +23-49,11-50 +35-79,34-36 +15-78,16-94 +87-89,6-88 +5-8,7-39 +13-82,2-5 +70-70,14-70 +47-86,87-94 +10-98,9-94 +2-63,1-62 +26-67,26-26 +67-68,66-68 +51-58,49-57 +29-44,41-45 +33-95,34-95 +4-18,4-17 +75-89,75-75 +12-87,11-87 +29-60,31-61 +35-37,36-44 +11-62,10-73 +12-36,12-30 +67-67,67-77 +9-96,10-98 +15-71,12-72 +87-90,15-86 +37-76,37-77 +74-75,73-74 +32-71,31-72 +14-29,29-60 +47-94,36-79 +19-89,16-84 +84-85,77-84 +38-80,7-80 +24-36,25-52 +47-48,47-48 +95-96,34-95 +72-80,72-76 +13-75,12-75 +6-89,5-88 +61-90,21-90 +98-98,1-99 +41-84,41-52 +11-44,11-43 +25-97,25-96 +36-99,35-89 +24-53,23-56 +12-12,12-91 +52-88,52-87 +5-10,5-9 +94-96,7-95 +10-94,9-93 +30-32,31-60 +83-83,9-83 +73-97,60-72 +60-81,38-81 +20-59,19-21 +1-93,74-93 +64-86,17-85 +37-40,37-70 +53-87,24-54 +21-81,20-81 +53-93,54-94 +35-73,39-74 +5-74,6-73 +13-97,24-98 +80-87,81-90 +13-41,42-42 +40-40,40-61 +30-53,31-52 +73-97,74-95 +77-93,78-94 +42-81,43-98 +29-49,18-57 +93-99,97-99 +12-64,12-99 +25-99,46-98 +5-70,11-88 +7-65,7-99 +32-89,31-88 +6-92,1-61 +1-9,10-56 +57-96,97-98 +51-97,98-99 +15-81,14-81 +9-28,10-51 +4-99,4-98 +49-55,49-49 +51-77,43-78 +18-55,19-54 +22-22,22-85 +38-83,37-82 +20-89,4-13 +58-89,1-90 +94-95,55-94 +38-83,69-93 +29-53,52-52 +9-99,10-99 +37-67,37-66 +39-97,19-49 +10-96,9-63 +23-98,75-98 +15-96,15-93 +5-10,9-56 +7-84,3-8 +84-86,73-85 +64-84,39-75 +23-41,22-23 +18-20,16-18 +69-82,69-97 +42-76,43-74 +27-29,16-29 +52-63,55-64 +22-91,96-99 +13-74,12-75 +76-81,76-80 +23-54,20-53 +85-87,47-86 +23-33,22-30 +3-19,19-19 +36-43,43-53 +2-89,1-99 +9-31,8-15 +92-94,64-94 +36-88,35-70 +70-73,68-72 +44-70,33-38 +40-91,40-99 +77-77,15-76 +21-37,30-77 +82-86,61-82 +3-77,3-92 +49-60,15-60 +9-85,65-86 +2-13,12-65 +39-48,47-49 +37-77,37-37 +53-54,54-81 +43-72,42-71 +4-4,5-85 +54-85,85-85 +39-79,40-80 +9-83,8-84 +12-79,3-80 +62-92,61-90 +4-64,62-63 +82-82,9-82 +31-85,43-86 +5-51,4-52 +95-98,98-99 +61-89,89-90 +5-57,30-69 +6-46,6-50 +6-43,12-42 +33-58,32-57 +55-55,56-91 +92-94,42-93 +3-98,98-98 +12-68,3-13 +77-77,78-78 +33-92,91-91 +12-13,13-44 +2-93,1-3 +42-49,41-47 +16-86,3-16 +13-26,26-32 +1-95,46-95 +36-58,37-38 +15-17,18-98 +57-83,70-84 +23-85,5-23 +50-99,8-96 +76-76,75-82 +4-97,98-98 +3-24,11-30 +27-27,13-28 +25-55,23-24 +26-48,26-86 +15-42,14-42 +50-61,50-62 +39-96,3-39 +28-52,43-56 +20-90,61-91 +79-99,99-99 +8-23,8-29 +12-78,12-77 +39-41,27-40 +8-90,5-7 +8-32,20-33 +21-89,22-90 +3-36,3-99 +37-60,36-63 +28-42,5-42 +44-57,40-56 +52-69,43-69 +9-10,8-9 +1-98,1-99 +8-21,3-12 +1-82,1-56 +16-16,5-15 +37-56,38-75 +20-53,19-31 +54-97,97-97 +11-93,10-38 +18-60,7-41 +96-99,8-97 +42-63,63-92 +12-51,50-51 +45-45,44-87 +62-63,16-63 +36-81,36-36 +4-45,1-4 +12-14,7-13 +64-64,60-64 +68-68,67-68 +9-95,94-98 +56-72,55-74 +34-57,34-46 +33-69,33-70 +65-78,64-66 +3-64,63-65 +6-79,6-69 +66-93,93-94 +55-56,36-55 +8-96,7-95 +33-83,33-93 +54-96,55-96 +1-73,5-90 +76-78,61-77 +10-90,9-94 +27-81,16-57 +85-96,86-96 +48-48,11-49 +47-63,48-48 +18-27,18-48 +40-93,40-46 +31-44,32-43 +21-41,34-40 +44-53,44-54 +28-95,7-95 +2-97,1-97 +20-97,96-99 +71-82,20-72 +4-32,4-98 +56-56,23-55 +10-74,73-73 +22-78,21-77 +57-65,56-65 +45-95,12-87 +62-67,62-77 +33-78,31-79 +33-51,32-50 +21-99,26-87 +11-94,98-99 +15-49,15-50 +2-9,10-83 +39-39,16-40 +15-73,40-74 +98-99,6-98 +46-84,46-81 +9-97,9-96 +56-66,36-55 +65-81,66-93 +14-97,70-96 +47-92,46-92 +12-46,13-19 +5-57,25-86 +44-84,45-83 +14-39,31-39 +46-68,32-69 +13-90,17-80 +14-64,15-78 +3-5,4-57 +6-7,13-57 +75-75,6-75 +46-92,45-64 +17-45,16-45 +8-94,52-99 +94-95,6-94 +37-76,36-75 +55-56,6-65 +40-64,28-50 +12-20,21-95 +28-50,47-51 +99-99,7-98 +37-63,33-89 +14-99,13-13 +7-80,7-19 +19-47,18-18 +37-46,47-47 +17-73,4-86 +9-43,10-43 +26-71,25-26 +14-91,1-10 +31-58,30-31 +44-44,22-45 +59-59,59-60 +9-9,9-64 +44-65,45-46 +10-96,96-96 +2-52,2-84 +35-36,35-35 +94-95,81-94 +12-89,13-90 +4-86,4-93 +13-96,4-96 +52-54,53-72 +6-90,5-91 +10-34,10-75 +22-31,22-30 +23-97,9-96 +7-91,83-95 +8-12,8-18 +34-39,35-38 +2-22,3-87 +6-15,7-54 +37-84,36-62 +51-93,51-94 +4-4,5-97 +17-55,33-56 +48-53,50-89 +17-90,18-99 +8-8,29-60 +18-40,32-87 +3-88,3-89 +14-14,15-53 +55-62,55-61 +5-96,58-97 +50-59,50-98 +37-86,38-86 +1-56,11-68 +65-75,66-69 +66-84,73-92 +99-99,2-99 +99-99,13-99 +65-88,6-93 +13-89,90-90 +41-64,40-63 +21-66,22-66 +57-92,56-93 +57-78,78-92 +94-98,11-94 +10-53,27-54 +37-42,38-42 +17-97,1-17 +39-86,39-85 +6-6,7-43 +20-55,21-55 +93-93,7-94 +73-74,75-95 +29-88,28-72 +40-90,22-86 +75-75,20-76 +15-72,4-74 +69-82,64-81 +21-23,21-59 +56-70,68-73 +9-94,95-95 +4-6,8-53 +7-20,19-45 +25-41,26-40 +62-72,61-74 +79-95,49-79 +2-96,1-95 +19-33,25-59 +8-90,7-91 +28-91,90-92 +11-20,19-88 +5-30,6-10 +8-99,8-8 +90-99,94-99 +19-77,19-94 +37-58,37-63 +23-44,3-45 +6-98,5-98 +9-42,6-9 +66-75,71-76 +58-87,86-88 +40-48,40-49 +17-24,17-48 +3-97,2-32 +37-88,37-89 +3-89,5-25 +19-61,13-20 +5-67,3-6 +72-73,15-72 +36-78,75-79 +6-92,7-91 +28-97,27-98 +56-56,14-56 +2-92,1-92 +1-7,7-82 +34-71,11-72 +5-96,5-83 +23-71,67-73 +25-93,25-94 +2-99,1-2 +21-73,11-73 +57-63,56-62 +30-33,33-34 +77-77,31-77 +13-78,14-96 +17-80,46-93 +17-46,1-17 +42-50,41-87 +31-84,4-31 +39-80,18-79 +13-31,14-84 +2-96,3-94 +8-98,9-67 +22-60,22-22 +16-97,15-99 +82-93,82-82 +57-77,22-70 +96-97,13-96 +17-41,41-85 +17-72,17-98 +12-96,4-96 +15-18,17-19 +33-53,33-59 +34-41,35-64 +94-98,27-93 +98-98,1-98 +57-69,32-70 +67-89,66-67 +66-72,73-73 +5-43,5-73 +26-98,27-68 +16-80,15-81 +2-65,2-55 +82-92,82-93 +16-16,16-21 +2-19,4-48 +82-82,56-81 +2-97,1-97 +53-54,38-53 +20-87,21-88 +45-60,44-56 +4-4,5-92 +95-95,79-95 +21-71,7-72 +57-83,58-83 +4-66,11-67 +57-57,58-92 +17-91,17-76 +14-15,15-56 +4-4,4-98 +7-98,15-68 +28-94,94-94 +3-47,27-47 +4-33,12-69 +48-56,48-57 +3-26,5-65 +46-71,46-72 +9-98,37-99 +60-76,18-75 +26-26,26-27 +31-56,31-57 +96-96,4-96 +55-82,55-83 +25-26,26-48 +59-71,54-56 +69-70,7-69 +2-98,98-98 +24-74,75-92 +61-96,61-86 +1-73,1-1 +57-86,56-67 +9-94,94-94 +52-52,53-98 +4-7,2-8 +35-63,34-60 +29-94,29-71 +43-89,44-90 +13-17,12-15 +52-58,51-79 +51-94,12-93 +24-52,24-26 +14-53,53-54 +26-91,26-64 +18-78,65-79 +27-64,55-87 +40-67,68-68 +25-70,24-70 +1-82,81-94 +17-19,18-89 +18-18,17-18 +33-60,57-72 +51-73,52-99 +41-98,42-98 +8-25,14-34 +2-17,1-62 +26-40,21-40 +2-21,3-16 +72-85,72-98 +41-86,14-58 +14-16,30-60 +96-97,22-96 +12-57,12-58 +16-74,15-75 +8-61,7-36 +37-56,36-67 +6-99,6-87 +60-75,60-60 +96-98,67-97 +15-26,25-27 +14-88,87-87 +31-95,32-96 +75-91,53-76 +16-49,17-38 +40-82,41-77 +3-59,2-59 +20-44,20-45 +10-76,9-76 +11-13,12-91 +16-18,17-95 +47-62,33-61 +34-69,19-70 +72-92,91-99 +27-34,28-29 +6-86,2-5 +25-75,25-40 +34-68,35-68 +16-95,16-94 +37-96,37-93 +20-62,20-61 +5-86,4-85 +37-49,35-36 +48-59,48-60 +38-42,39-49 +36-89,37-97 +24-26,25-69 +8-93,21-93 +24-83,23-83 +38-68,37-39 +11-70,34-86 +14-88,13-93 +86-86,47-87 +33-67,32-34 +1-80,80-80 +81-82,8-81 +53-97,5-98 +11-30,1-18 +4-99,3-98 +1-99,77-98 +8-14,15-56 +3-70,2-87 +19-34,34-62 +56-57,57-91 +3-64,2-4 +80-83,84-89 +58-59,1-58 +4-77,5-86 +5-97,3-97 +48-94,26-95 +10-96,7-95 +4-4,6-41 +5-23,4-6 +5-91,90-93 +13-88,89-89 +1-97,90-97 +69-80,69-91 +8-11,11-72 +24-45,36-44 +20-20,20-46 +64-73,65-94 +46-90,47-77 +7-61,61-74 +16-25,25-26 +16-16,15-22 +60-89,61-89 +51-99,52-84 +22-85,22-93 +46-71,45-72 +9-65,10-66 +65-69,60-66 +24-43,23-75 +15-30,3-31 +44-93,26-65 +8-35,8-34 +68-82,2-79 +67-71,18-67 +93-97,93-98 +6-83,2-2 +26-84,27-50 +2-50,49-52 +39-80,40-65 +3-3,4-68 +27-84,36-85 +21-86,20-39 +10-82,9-71 +18-86,40-60 +55-80,23-46 +24-30,23-23 +29-68,30-45 +41-48,42-59 +85-94,88-93 +2-99,98-99 +33-94,94-95 +78-80,3-79 +94-94,16-94 +1-4,3-97 +71-96,52-72 +94-96,95-98 +71-72,72-81 +20-33,32-33 +15-55,15-15 +21-33,33-65 +28-33,27-33 +1-93,57-92 +23-64,63-93 +5-89,4-89 +66-71,68-78 +7-80,2-7 +10-86,9-71 +2-99,2-98 +6-15,5-14 +83-88,60-84 +34-37,33-36 +49-82,82-83 +68-75,61-69 +40-87,16-41 +61-67,64-67 +8-67,7-68 +31-61,30-88 +16-77,16-16 +1-62,63-63 +7-67,2-6 +39-67,8-57 +7-94,11-95 +41-93,73-85 +39-54,47-98 +28-90,2-83 +1-6,6-57 +10-11,9-16 +28-82,27-81 +4-95,5-96 +31-95,8-94 +73-91,33-84 +34-92,15-35 +49-94,6-50 +3-99,2-98 +59-60,34-59 +22-76,22-86 +9-11,10-93 +67-78,77-86 +16-83,15-47 +73-81,72-73 +72-88,2-73 +26-62,27-72 +5-81,5-89 +19-69,20-69 +32-97,32-96 +63-86,32-75 +7-97,7-96 +84-92,91-93 +72-96,2-96 +19-22,19-19 +66-82,65-81 +81-96,65-82 +71-83,35-88 +99-99,1-99 +22-97,22-96 +29-97,29-83 +13-85,84-84 +23-67,23-34 +14-81,13-81 +55-98,16-97 +58-78,38-78 +6-16,3-16 +47-78,46-77 +16-53,15-25 +84-90,83-91 +32-32,31-47 +2-21,4-57 +17-56,49-55 +12-67,67-67 +19-71,42-97 +82-82,63-83 +39-46,18-46 +6-97,1-97 +42-88,43-89 +19-19,19-95 +17-95,4-95 +50-96,50-90 +3-81,1-2 +4-47,7-18 +12-17,7-95 +23-92,23-58 +40-91,91-92 +3-69,69-70 +47-50,46-50 +9-92,9-97 +7-71,4-16 +27-38,74-96 +11-30,30-89 +23-46,22-46 +2-6,5-98 +36-93,35-93 +9-19,19-99 +25-33,32-34 +13-36,14-35 +5-97,4-5 +19-99,20-95 +43-79,54-83 +21-99,20-47 +71-74,70-72 +90-90,3-90 +71-99,71-71 +5-6,6-98 +74-84,74-83 +19-95,19-94 +34-81,38-83 +13-34,5-14 +15-80,15-79 +6-23,5-90 +67-76,67-70 +39-91,14-90 +65-96,64-95 +8-88,52-89 +61-94,89-94 +32-66,66-66 +10-28,15-55 +9-93,8-90 +38-97,39-98 +78-84,77-79 +5-85,3-29 +21-80,80-80 +84-89,88-90 +45-85,12-66 +99-99,1-98 +45-49,48-74 +6-98,3-68 +13-95,94-95 +49-52,51-53 +18-43,6-18 +85-85,20-85 +62-65,61-65 +8-92,9-92 +23-83,22-83 +15-77,77-77 +56-74,55-78 +23-78,22-79 +32-80,33-34 +4-99,11-96 +27-91,16-91 +8-82,8-81 +3-39,28-39 +39-47,39-46 +16-21,34-70 +65-98,65-97 +16-86,16-85 +8-99,33-73 +24-94,19-93 +48-57,56-58 +4-96,3-40 +73-83,17-82 +1-3,2-55 +83-96,96-97 +35-83,66-91 +27-44,16-34 +33-82,31-60 +46-88,45-88 +45-78,58-78 +41-47,40-80 +5-95,4-95 +9-65,10-67 +51-82,68-82 +52-98,36-94 +36-38,37-41 +19-33,9-33 +22-98,21-23 +12-96,11-97 +75-77,11-76 +91-92,12-91 +92-93,4-93 +18-18,17-18 +20-45,44-55 +94-95,61-94 +38-99,39-73 +6-11,11-84 +29-49,9-29 +24-91,24-44 +72-72,28-72 +49-53,49-51 +9-85,8-85 +26-80,26-90 diff --git a/src/bin/04_1.rs b/src/bin/04_1.rs new file mode 100644 index 0000000..394824f --- /dev/null +++ b/src/bin/04_1.rs @@ -0,0 +1,41 @@ +use std::fs; + +use anyhow::Result; +use itertools::Itertools; + + +fn main() -> Result<()> { + let input = fs::read_to_string("input/04.txt")?; + + let lines: Vec<&str> = input + .split("\n") + .filter(|s| *s != "") + .collect_vec(); + + + // ........fl........fu...... + // ......sl............su.... + // + // ..fl.....fu............... + // ...........sl....su....... + // + // ........fl........fu...... + // ..........sl....su........ + // + // ................fl....fu.. + // ..sl......su.............. + + + let result = lines + .into_iter() + .map(|s| s.split(",")) + .map(|mut i| (i.next().unwrap(), i.next().unwrap())) + .map(|(f, s)| (f.split("-"), s.split("-"))) + .map(|(mut f, mut s)| (f.next().unwrap().parse::().ok(), f.next().unwrap().parse::().ok(), s.next().unwrap().parse::().ok(), s.next().unwrap().parse::().ok())) + .filter(|(fl, fu, sl, su)| (fl >= sl && fu <= su && fu >= sl) || (fl <= sl && fu >= su && fl <= su)) + .count(); + + println!("{result}"); + + return Ok(()); +} diff --git a/src/bin/04_2.rs b/src/bin/04_2.rs new file mode 100644 index 0000000..bbe7610 --- /dev/null +++ b/src/bin/04_2.rs @@ -0,0 +1,41 @@ +use std::fs; + +use anyhow::Result; +use itertools::Itertools; + + +fn main() -> Result<()> { + let input = fs::read_to_string("input/04.txt")?; + + let lines: Vec<&str> = input + .split("\n") + .filter(|s| *s != "") + .collect_vec(); + + + // ........fl........fu...... + // ......sl............su.... + // + // ..fl.....fu............... + // .......sl....su......... + // + // ........fl........fu...... + // ..........sl....su........ + // + // ........fl....fu.......... + // ..sl......su.............. + + + let result = lines + .into_iter() + .map(|s| s.split(",")) + .map(|mut i| (i.next().unwrap(), i.next().unwrap())) + .map(|(f, s)| (f.split("-"), s.split("-"))) + .map(|(mut f, mut s)| (f.next().unwrap().parse::().ok(), f.next().unwrap().parse::().ok(), s.next().unwrap().parse::().ok(), s.next().unwrap().parse::().ok())) + .filter(|(fl, fu, sl, su)| (fl >= sl && fl <= su) || (fu >= sl && fu <= su ) || (sl >= fl && sl <= fu) || (su >= fl && su <= fu)) + .count(); + + println!("{result}"); + + return Ok(()); +}