diff --git a/README.md b/README.md index 68fb244..1f89620 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ These are my attempts on [AoC 2022](https://adventofcode.com/2022/) | [01](day01) | ⭐ | ⭐ | Python | | [02](day02) | ⭐ | ⭐ | C | | [03](day03) | ⭐ | ⭐ | Rust | -| 04 | | | | +| [04](day04) | ⭐ | ⭐ | Haskell | | 05 | | | | | 06 | | | | | 07 | | | | diff --git a/day04/input.txt b/day04/input.txt new file mode 100644 index 0000000..c5ca046 --- /dev/null +++ b/day04/input.txt @@ -0,0 +1,1000 @@ +60-60,45-60 +36-57,7-36 +2-32,1-55 +1-30,6-75 +12-13,13-90 +48-98,48-98 +29-29,29-51 +5-8,7-92 +39-91,38-90 +3-41,16-86 +64-64,65-95 +4-4,5-96 +8-43,9-22 +82-88,20-46 +19-20,9-20 +73-74,10-74 +23-29,22-23 +21-82,22-83 +36-36,36-84 +34-35,35-74 +3-98,8-98 +42-51,50-50 +44-93,45-94 +65-88,78-90 +37-76,43-76 +46-63,8-63 +2-91,58-92 +8-8,8-74 +50-50,46-50 +11-75,10-76 +16-95,17-94 +81-94,80-89 +7-76,9-75 +99-99,1-99 +3-52,4-53 +48-81,40-80 +13-65,14-14 +96-99,2-95 +7-98,1-98 +24-93,23-42 +28-29,29-64 +34-86,33-87 +71-84,70-71 +24-29,28-82 +22-87,15-21 +62-70,45-69 +45-48,44-52 +34-63,35-62 +14-14,15-83 +1-40,10-39 +45-97,46-98 +36-58,18-57 +24-92,23-93 +15-65,5-15 +80-81,80-81 +8-97,97-97 +18-27,17-28 +35-35,36-53 +46-51,47-56 +43-64,42-63 +31-88,89-93 +44-96,97-97 +3-9,8-56 +48-58,16-47 +13-89,12-90 +3-98,4-99 +20-32,20-90 +20-96,97-97 +27-93,28-93 +23-49,22-48 +44-75,44-44 +15-15,15-87 +84-90,61-82 +2-97,97-99 +25-82,24-25 +29-29,15-29 +23-23,24-47 +34-98,4-97 +37-72,36-73 +61-66,55-65 +66-70,70-70 +81-87,82-93 +97-97,17-97 +3-47,4-84 +83-92,46-87 +8-51,9-55 +5-86,14-45 +46-74,75-94 +60-61,61-86 +57-66,60-84 +75-78,52-74 +14-89,93-93 +1-93,1-1 +24-30,23-31 +80-85,79-84 +71-71,30-70 +46-90,70-90 +11-11,11-79 +56-84,55-74 +11-86,12-87 +72-86,49-59 +37-87,77-88 +27-74,27-66 +31-63,30-31 +59-89,58-90 +4-48,5-5 +56-63,62-63 +15-87,1-31 +11-57,10-63 +43-55,24-42 +27-79,28-78 +32-79,3-80 +22-56,21-55 +4-91,3-94 +41-49,49-58 +18-77,12-13 +6-74,7-75 +38-97,96-97 +24-89,23-88 +25-91,91-91 +65-66,66-78 +62-90,63-85 +60-74,73-73 +52-59,53-58 +15-77,16-78 +23-48,47-48 +18-53,37-47 +8-10,5-9 +31-63,19-27 +3-39,4-4 +44-77,45-77 +80-84,2-79 +1-81,16-69 +7-7,7-7 +25-81,6-82 +80-90,23-90 +3-83,5-81 +14-74,13-73 +7-64,8-63 +54-73,55-74 +6-76,5-5 +63-67,60-66 +12-62,12-13 +9-82,16-82 +3-94,4-95 +34-63,33-35 +14-15,15-99 +95-97,3-58 +13-76,20-77 +7-87,6-88 +74-97,40-83 +14-93,94-94 +4-86,1-89 +2-91,1-90 +69-96,3-96 +22-96,22-97 +80-91,33-79 +33-83,32-33 +96-96,26-95 +5-96,37-93 +22-83,22-98 +22-93,21-94 +14-88,87-89 +21-74,22-73 +53-87,1-54 +22-96,98-98 +54-75,9-53 +1-97,8-97 +27-57,26-56 +4-42,43-43 +95-95,4-95 +84-84,65-84 +13-22,12-23 +12-57,11-46 +13-13,12-16 +9-74,10-74 +4-96,5-98 +5-94,4-77 +81-98,7-81 +14-95,13-75 +38-73,39-74 +16-49,34-73 +8-89,9-88 +1-73,74-90 +11-97,5-93 +17-80,10-80 +51-57,50-83 +3-22,20-27 +5-91,6-92 +45-80,23-34 +56-57,5-57 +2-61,1-3 +35-64,34-63 +16-77,77-86 +85-86,1-85 +50-89,49-49 +32-55,55-55 +39-79,80-96 +25-66,95-98 +45-57,23-37 +52-97,34-83 +7-8,8-28 +1-85,1-72 +8-86,9-87 +80-91,2-80 +40-78,41-74 +16-82,16-17 +55-78,78-79 +26-95,19-27 +50-53,49-51 +16-63,63-89 +6-73,5-74 +3-43,5-97 +17-97,35-98 +17-18,38-45 +67-85,15-66 +9-20,10-90 +2-33,8-98 +28-91,24-90 +65-78,64-66 +24-25,19-24 +21-70,9-70 +25-68,9-69 +39-75,38-92 +77-78,57-78 +63-89,62-63 +52-52,53-78 +9-94,10-95 +17-62,52-61 +30-32,31-97 +8-67,56-65 +58-77,4-57 +85-85,13-86 +12-98,11-99 +5-95,4-96 +10-84,9-85 +1-8,7-41 +8-66,65-67 +1-98,98-99 +9-32,10-10 +5-84,3-83 +32-38,16-41 +17-34,33-69 +3-98,2-96 +13-80,90-90 +21-79,20-20 +2-17,1-96 +29-99,28-29 +64-72,73-73 +3-92,2-95 +3-7,6-61 +33-89,6-88 +18-19,10-19 +89-91,13-90 +4-95,3-3 +98-98,9-99 +43-62,29-99 +39-47,38-46 +10-88,2-11 +6-78,2-22 +9-28,27-74 +18-93,41-94 +91-95,92-95 +38-38,17-38 +15-56,14-15 +68-69,65-67 +30-30,30-38 +54-58,49-57 +64-65,65-66 +8-89,7-8 +28-93,94-94 +31-71,70-71 +3-99,2-98 +49-87,50-88 +60-62,62-76 +57-83,82-82 +70-70,31-70 +7-90,19-83 +36-50,35-46 +7-68,6-96 +58-58,41-57 +13-41,40-59 +28-28,30-73 +25-27,8-26 +1-85,85-85 +2-12,11-83 +62-76,61-75 +21-78,20-77 +20-95,19-96 +25-25,25-38 +52-97,97-98 +24-86,87-98 +25-93,93-95 +23-96,22-98 +26-50,56-60 +26-82,26-86 +73-80,74-74 +66-92,92-92 +34-51,35-52 +36-48,35-47 +10-99,9-11 +35-35,36-38 +5-89,10-90 +73-74,15-74 +16-86,98-99 +63-83,84-98 +8-23,2-22 +5-38,3-3 +6-93,2-3 +32-93,8-92 +60-61,32-61 +6-99,3-7 +11-90,10-89 +37-78,37-51 +48-84,48-53 +75-89,53-92 +6-27,27-27 +24-31,63-83 +39-52,38-40 +20-99,14-95 +8-92,9-93 +23-69,22-68 +22-56,23-50 +4-62,3-84 +1-98,2-98 +3-77,8-99 +20-90,90-90 +37-44,38-38 +44-73,72-73 +12-65,13-64 +65-92,93-98 +5-83,15-84 +3-83,2-2 +71-98,31-97 +9-82,82-82 +29-81,28-71 +59-92,92-93 +18-54,12-55 +14-65,14-64 +56-56,56-56 +16-28,16-24 +38-85,85-86 +46-64,47-66 +20-93,21-21 +2-92,2-97 +2-55,21-55 +21-42,20-21 +5-5,4-97 +14-83,15-84 +6-95,5-96 +2-83,82-84 +47-47,3-47 +54-85,11-53 +20-20,20-78 +33-93,32-92 +19-68,19-68 +25-90,24-25 +29-90,68-91 +7-82,83-83 +6-22,9-22 +6-97,10-98 +23-97,98-99 +80-81,30-80 +25-75,24-25 +27-27,26-79 +78-80,39-79 +42-84,42-42 +93-98,12-90 +35-36,36-78 +56-97,75-86 +7-30,27-31 +64-66,3-65 +2-50,2-80 +58-92,59-93 +20-33,19-32 +54-55,4-55 +3-25,4-23 +50-78,51-51 +29-62,28-29 +10-23,22-24 +59-99,2-98 +55-97,19-95 +4-61,60-81 +25-43,44-91 +4-86,2-93 +12-96,75-97 +68-92,69-91 +23-46,23-23 +23-43,22-42 +40-40,40-74 +25-37,38-38 +23-89,90-95 +3-92,3-59 +52-83,91-97 +7-35,34-36 +62-90,89-91 +58-75,57-74 +98-99,60-97 +18-72,7-11 +64-64,33-64 +7-79,79-79 +45-75,75-90 +76-80,75-81 +8-94,10-87 +10-10,9-17 +13-98,97-97 +13-85,85-93 +22-68,21-23 +33-33,33-37 +3-51,21-52 +71-81,17-70 +10-68,49-70 +72-93,72-74 +84-97,60-85 +20-61,20-60 +80-99,80-83 +6-89,7-88 +86-86,27-88 +66-83,61-67 +80-82,11-81 +89-95,49-86 +1-90,2-18 +4-44,5-68 +2-59,1-60 +6-64,6-6 +94-97,26-94 +85-86,86-90 +16-64,47-65 +19-97,3-99 +13-86,12-85 +6-97,1-1 +7-42,43-45 +57-57,28-57 +58-72,72-73 +12-12,11-80 +14-75,13-75 +13-89,3-14 +7-96,6-7 +57-96,59-99 +20-21,21-50 +23-23,24-52 +35-96,34-35 +2-33,7-93 +3-60,7-60 +19-56,20-57 +16-66,56-85 +15-81,14-80 +76-98,57-97 +70-92,50-69 +5-9,7-16 +52-67,66-66 +94-97,43-88 +6-36,35-36 +6-6,5-96 +15-37,16-16 +37-77,37-37 +25-85,16-84 +77-96,24-77 +66-83,31-66 +36-89,36-36 +25-68,69-99 +12-51,52-52 +28-99,10-29 +7-16,2-17 +9-82,82-90 +42-98,41-83 +50-72,48-72 +23-97,22-98 +32-44,43-44 +3-91,1-95 +5-46,2-3 +31-90,4-84 +22-45,21-95 +20-68,8-21 +90-90,69-90 +6-74,4-17 +56-94,57-95 +11-61,61-62 +56-68,57-69 +6-75,5-6 +51-64,26-49 +3-79,3-78 +23-54,22-22 +32-95,32-94 +85-87,49-86 +2-64,3-66 +3-10,11-58 +17-20,20-20 +38-68,39-39 +27-77,28-76 +22-82,23-91 +17-74,18-75 +32-42,25-75 +25-25,25-56 +7-18,8-19 +78-95,78-96 +37-45,31-46 +11-99,7-8 +35-98,97-97 +21-54,22-53 +46-48,2-47 +2-94,1-94 +3-99,2-98 +18-96,95-97 +3-99,3-99 +19-77,76-78 +32-48,31-47 +30-43,27-42 +20-36,21-23 +68-81,61-73 +39-71,40-72 +91-99,31-71 +8-85,9-86 +70-70,21-69 +95-99,18-94 +19-67,67-67 +49-49,64-68 +25-54,55-55 +21-66,20-65 +2-90,7-89 +82-82,22-81 +22-53,22-36 +90-97,61-90 +36-87,35-88 +88-95,12-87 +96-98,7-97 +5-84,2-6 +68-68,67-87 +29-58,59-59 +74-75,3-75 +25-94,15-26 +44-45,45-84 +40-56,57-82 +30-97,26-30 +6-87,87-91 +7-75,7-46 +4-4,5-12 +18-23,18-18 +1-2,2-21 +14-85,15-86 +12-91,43-79 +21-66,65-73 +51-85,95-98 +55-79,42-84 +25-90,26-26 +28-91,27-29 +4-96,10-95 +35-88,26-26 +32-67,31-67 +21-21,21-80 +51-65,29-52 +61-73,62-72 +5-36,5-32 +3-97,97-98 +43-79,42-80 +20-39,31-32 +36-51,19-51 +20-20,21-66 +25-77,6-24 +34-36,35-47 +15-98,5-15 +3-32,2-48 +28-29,29-90 +4-99,2-5 +6-86,7-85 +15-97,15-96 +13-79,2-79 +3-83,2-97 +1-47,11-82 +50-56,24-49 +79-80,48-79 +42-57,43-58 +3-88,88-89 +13-44,14-43 +7-24,8-25 +14-86,13-13 +26-85,27-97 +13-63,15-64 +30-93,31-31 +95-95,61-94 +48-86,51-89 +86-86,8-86 +36-78,37-37 +16-26,15-27 +79-94,7-79 +12-12,11-63 +72-82,24-82 +84-89,48-83 +54-63,55-55 +50-50,50-86 +67-98,4-40 +87-99,99-99 +24-52,23-91 +40-41,41-58 +24-92,5-93 +25-61,26-62 +75-90,59-89 +3-50,49-77 +33-45,32-33 +64-67,64-64 +22-77,23-92 +4-4,4-99 +36-60,35-87 +4-89,2-3 +23-55,24-54 +7-98,4-97 +4-49,1-1 +62-80,61-81 +20-75,20-41 +39-41,40-57 +16-34,34-47 +89-89,7-90 +7-13,7-11 +98-98,1-98 +14-91,14-14 +34-57,58-58 +5-95,94-96 +5-42,6-6 +17-18,18-62 +79-79,64-79 +28-73,64-99 +4-98,99-99 +4-77,3-78 +4-87,19-86 +79-79,19-78 +32-32,32-97 +77-99,11-57 +7-92,6-93 +1-83,11-78 +37-97,36-37 +17-67,17-74 +1-90,2-39 +10-86,9-9 +1-95,93-96 +4-97,3-98 +42-70,43-70 +39-90,4-90 +22-43,6-84 +14-41,13-93 +67-79,49-66 +10-48,45-99 +9-98,98-99 +4-94,7-95 +6-12,14-61 +44-93,23-94 +17-17,18-18 +24-89,88-88 +17-69,18-49 +19-89,18-30 +31-74,75-99 +2-44,21-43 +1-3,2-98 +4-99,5-98 +74-74,42-73 +95-96,3-96 +39-61,40-62 +9-11,19-94 +1-92,4-91 +20-82,18-20 +1-8,4-51 +42-45,13-50 +7-38,67-95 +14-85,84-84 +3-5,6-93 +10-59,11-53 +65-83,2-66 +14-97,97-97 +2-99,3-97 +51-95,44-88 +30-47,29-48 +7-36,15-76 +8-8,9-43 +2-93,1-84 +29-29,30-36 +13-30,44-71 +8-98,7-94 +5-67,6-97 +99-99,1-99 +80-80,23-80 +82-82,6-81 +91-92,20-91 +25-28,37-43 +7-94,8-96 +25-44,24-26 +42-88,24-69 +5-82,9-20 +63-98,63-82 +86-87,2-86 +4-58,4-75 +98-98,2-97 +43-66,17-43 +33-61,61-61 +14-15,15-98 +18-96,5-17 +17-39,11-39 +95-95,11-45 +7-88,6-98 +27-27,24-27 +5-93,6-97 +12-33,32-42 +14-83,83-86 +5-7,4-8 +16-86,15-85 +29-99,99-99 +64-64,19-63 +1-99,1-37 +90-90,42-89 +74-78,44-67 +70-85,54-84 +13-99,9-98 +16-18,20-54 +5-65,1-6 +72-72,9-71 +4-4,7-97 +9-96,2-10 +5-6,6-39 +52-65,51-52 +13-77,16-76 +71-88,72-89 +5-6,3-6 +35-46,45-47 +45-87,38-88 +6-76,40-77 +67-72,66-94 +11-62,8-8 +4-9,3-10 +24-33,56-92 +5-82,83-83 +59-59,59-79 +23-87,22-23 +90-93,54-87 +9-35,35-35 +6-96,96-96 +2-9,8-84 +25-34,28-35 +52-93,53-97 +25-90,90-93 +86-94,86-93 +18-48,17-47 +4-45,4-98 +3-69,4-4 +3-93,3-34 +4-59,3-37 +20-87,19-86 +26-76,77-84 +19-97,9-20 +11-99,2-11 +4-25,26-52 +7-99,4-8 +4-88,1-94 +31-41,40-63 +10-73,72-74 +91-95,23-95 +27-85,85-86 +48-69,38-47 +69-69,68-82 +6-91,91-91 +5-59,59-59 +18-61,5-19 +62-76,61-77 +87-88,85-87 +76-76,8-76 +11-83,10-10 +35-66,12-48 +63-96,64-92 +41-94,40-42 +98-98,19-98 +45-91,46-90 +7-25,8-26 +38-84,37-85 +3-74,2-93 +14-25,25-38 +27-93,45-98 +9-52,8-53 +61-77,34-77 +6-96,33-86 +1-72,2-71 +46-93,35-39 +10-55,22-55 +55-78,54-77 +25-26,26-27 +7-17,18-95 +1-83,34-82 +73-73,60-73 +68-83,82-84 +8-9,9-84 +10-82,3-82 +13-94,7-14 +3-7,8-98 +25-52,24-24 +27-41,26-42 +27-69,25-25 +35-86,87-89 +9-29,1-28 +17-32,17-95 +8-95,9-95 +29-58,52-65 +10-10,9-61 +27-28,13-30 +89-89,18-88 +91-91,6-91 +49-60,59-61 +12-95,11-11 +6-97,97-97 +2-99,2-2 +1-47,3-99 +85-96,4-84 +73-74,74-89 +29-97,98-99 +66-79,61-78 +6-24,3-36 +69-69,8-69 +20-92,19-95 +18-31,28-91 +23-60,24-59 +50-51,3-51 +79-89,39-78 +15-87,4-87 +1-36,37-57 +8-94,7-8 +58-61,34-42 +18-97,14-42 +30-62,63-63 +83-98,82-96 +19-67,14-18 +35-39,40-81 +2-97,1-96 +11-93,14-83 +3-86,1-20 +8-48,1-8 +84-96,29-83 +55-91,54-91 +36-64,35-66 +22-60,22-55 +14-91,13-86 +3-58,57-58 +6-10,17-66 +18-61,62-62 +11-98,61-71 +49-74,34-73 +32-85,33-84 +70-78,61-72 +66-66,66-69 +10-97,62-91 +17-24,18-23 +92-94,3-93 +4-32,11-33 +45-49,49-71 +1-48,4-49 +21-85,11-84 +2-2,1-96 +55-81,81-81 +13-64,25-64 +61-78,74-79 +9-97,10-81 +40-45,41-44 +74-74,37-74 +86-95,86-95 +40-57,40-99 +34-74,33-75 +96-96,29-97 +8-11,10-34 +5-64,63-63 +1-95,2-94 +13-28,13-56 +10-10,9-13 +1-90,91-91 +15-98,54-98 +10-10,9-78 +14-37,18-55 +25-76,76-77 +98-99,39-96 +39-43,38-42 +97-97,37-96 +33-50,15-49 +15-15,16-19 +24-59,1-73 +43-92,21-99 +31-70,69-86 +40-88,9-87 +10-72,11-73 +7-55,12-71 +9-69,8-9 +34-41,35-44 +15-16,2-97 +32-45,4-33 +7-66,6-26 +57-66,65-97 +17-29,16-28 +7-32,19-91 +6-6,6-65 +30-49,30-40 +2-4,4-82 +18-79,80-80 +3-31,1-1 +63-94,63-95 +2-54,42-54 +57-73,57-57 +16-92,15-93 +29-49,30-35 +18-35,25-35 +27-87,1-88 +9-59,60-60 +31-82,30-88 +9-61,10-37 +65-65,42-64 +45-45,1-44 +15-34,9-16 +9-40,34-99 +18-94,94-95 +6-36,35-97 +5-74,4-99 +66-66,20-66 +47-69,48-68 +16-99,8-98 +22-36,35-37 +13-71,43-71 +98-98,1-99 +17-17,16-79 +16-16,15-89 +82-90,81-91 +11-11,10-94 +47-47,47-90 +7-9,8-60 +11-98,12-96 +37-74,74-75 +41-88,41-41 +97-98,53-96 +4-64,1-2 +43-92,44-94 +9-86,10-86 +14-28,13-37 +1-63,3-63 +81-81,80-88 +37-55,38-54 +25-80,26-79 +16-92,15-17 +14-14,13-48 +19-90,18-19 +68-87,8-67 +6-89,3-89 +9-97,10-98 +53-71,52-52 +74-95,74-74 +33-82,81-83 +40-47,39-40 +50-50,10-50 +15-17,16-76 +12-77,77-78 +58-65,64-82 +6-96,5-95 +7-91,8-90 +14-15,21-71 +36-99,99-99 +5-92,4-50 +39-41,40-59 +48-97,47-98 +31-42,30-41 +66-79,9-66 +30-30,30-82 +15-96,16-16 +67-98,68-99 +25-27,26-96 +19-67,20-66 +28-54,55-57 +66-82,66-81 +10-42,1-62 +4-7,5-6 +20-21,10-21 +54-98,97-98 +7-97,96-97 +2-3,2-52 +58-74,19-58 +11-95,21-87 +16-50,2-44 +2-87,1-94 +52-58,5-51 +7-13,6-23 +37-38,34-38 +2-94,1-95 +62-62,63-81 +34-97,34-69 +24-90,23-90 +49-69,49-49 +15-16,16-49 +10-89,9-90 +2-91,7-90 +20-94,17-93 +4-90,4-4 +48-65,66-66 +57-76,55-75 +19-95,96-97 +63-78,5-88 +43-43,43-86 +57-61,1-60 +1-99,51-75 +1-24,1-23 +65-83,64-83 +78-78,27-77 +9-76,3-77 diff --git a/day04/input_demo.txt b/day04/input_demo.txt new file mode 100644 index 0000000..9f9e9cf --- /dev/null +++ b/day04/input_demo.txt @@ -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 diff --git a/day04/main.hs b/day04/main.hs new file mode 100644 index 0000000..2863145 --- /dev/null +++ b/day04/main.hs @@ -0,0 +1,67 @@ +import Data.Char + +main = do + let list = [] + file <- readFile "input.txt" + let inputLines = lines file + let pairs = map (splitWhen (==',')) inputLines + + -- Each pair is a set of two numbers separated by a dash + let limits = map (map parseRange) pairs + + let containedWithin = map rangeListIsContained limits + + let containedCount = length $ filter (==True) containedWithin + print "Part 1: " + print containedCount + + let overlap = map rangeListOverlap limits + let overlapCount = length $ filter (==True) overlap + print "Part 2: " + print overlapCount + + +parseRange :: String -> (Int, Int) +parseRange pair = do + let numbers = splitWhen (=='-') pair + let first = read (numbers !! 0) :: Int + let second = read (numbers !! 1) :: Int + (first, second) + + +-- True if the first range is entirely contained in the second range, or vice versa +rangeIsContained :: (Int, Int) -> (Int, Int) -> Bool +rangeIsContained (lo1, hi1) (lo2, hi2) + | lo1 <= lo2 && hi1 >= hi2 = True + | lo1 >= lo2 && hi1 <= hi2 = True + | otherwise = False + +-- True if any endpoint of a range is within the other range +rangeOverlaps :: (Int, Int) -> (Int, Int) -> Bool +rangeOverlaps (lo1, hi1) (lo2, hi2) + | rangeIsContained (lo1, lo1) (lo2, hi2) = True + | lo2 >= lo1 && lo2 <= hi1 = True + | hi2 >= lo1 && hi2 <= hi1 = True + | otherwise = False + + +-- This is mega dirty, should probably be replaced with a smart map. +rangeListIsContained :: [(Int, Int)] -> Bool +rangeListIsContained ranges = do + let first = ranges !! 0 + let second = ranges !! 1 + rangeIsContained first second + +rangeListOverlap :: [(Int, Int)] -> Bool +rangeListOverlap ranges = do + let first = ranges !! 0 + let second = ranges !! 1 + rangeOverlaps first second + +-- Modified from Prelude.words +splitWhen :: (Char -> Bool) -> String -> [String] +splitWhen p s = case dropWhile p s of + "" -> [] + s' -> w : splitWhen p s'' + where (w, s'') = break p s' +