From 6596b48113ced669b206d2e1f1e8ba6edcba88a2 Mon Sep 17 00:00:00 2001 From: Orangerot Date: Sat, 17 Dec 2022 01:16:18 +0100 Subject: adv2022 first 8 days --- 2022/day04/input1.txt | 6 + 2022/day04/input2.txt | 1000 +++++++++++++++++++++++++++++++++++++++++++++++++ 2022/day04/main | Bin 0 -> 20672 bytes 2022/day04/main.c | 15 + 2022/day04/main2.c | 18 + 5 files changed, 1039 insertions(+) create mode 100644 2022/day04/input1.txt create mode 100644 2022/day04/input2.txt create mode 100755 2022/day04/main create mode 100644 2022/day04/main.c create mode 100644 2022/day04/main2.c (limited to '2022/day04') diff --git a/2022/day04/input1.txt b/2022/day04/input1.txt new file mode 100644 index 0000000..9f9e9cf --- /dev/null +++ b/2022/day04/input1.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/2022/day04/input2.txt b/2022/day04/input2.txt new file mode 100644 index 0000000..0f2f19d --- /dev/null +++ b/2022/day04/input2.txt @@ -0,0 +1,1000 @@ +23-33,24-65 +10-24,23-88 +71-92,18-71 +2-2,10-95 +24-26,25-66 +19-93,36-99 +12-99,5-13 +13-88,14-94 +4-85,5-84 +78-88,79-87 +13-82,13-83 +3-98,3-99 +27-69,28-89 +24-47,23-66 +43-48,29-49 +2-99,2-98 +3-77,21-65 +10-90,89-93 +64-75,63-75 +97-99,1-97 +48-65,49-64 +18-26,25-28 +85-86,26-85 +82-89,69-83 +21-93,93-98 +73-79,46-81 +33-52,32-51 +1-99,99-99 +11-36,34-40 +31-88,32-89 +9-19,18-35 +9-84,83-83 +34-82,4-83 +33-33,24-33 +34-83,83-90 +11-86,10-86 +48-48,3-50 +8-92,9-91 +16-38,15-37 +4-84,5-93 +70-75,41-79 +40-48,47-92 +37-41,52-89 +3-3,4-91 +27-77,27-77 +64-90,33-52 +28-40,9-64 +2-73,3-95 +17-94,7-75 +6-71,7-71 +11-69,10-70 +4-40,4-40 +9-54,30-44 +92-93,4-92 +62-63,63-67 +7-34,16-34 +54-55,31-54 +12-90,11-91 +11-13,12-53 +10-73,9-64 +13-18,13-84 +6-82,16-81 +52-78,18-53 +22-82,23-74 +90-91,3-90 +92-93,70-93 +18-44,19-45 +20-20,20-67 +31-93,76-93 +25-86,86-86 +6-73,5-94 +75-84,74-86 +50-51,50-51 +56-86,57-86 +18-81,13-18 +3-9,8-93 +31-36,34-34 +19-88,18-87 +10-95,54-79 +83-85,66-86 +32-68,31-49 +14-97,12-99 +42-42,42-53 +27-32,28-69 +96-98,15-96 +25-49,25-48 +71-81,15-92 +19-83,15-19 +14-99,6-14 +52-90,53-94 +5-98,85-96 +18-30,10-15 +4-86,4-98 +54-55,30-78 +85-99,62-86 +10-99,10-98 +4-96,5-95 +6-59,7-18 +6-86,1-7 +28-85,5-84 +3-82,2-82 +73-92,87-87 +2-3,2-89 +4-5,4-8 +21-96,69-97 +89-90,4-89 +28-79,29-80 +35-58,40-48 +96-96,3-97 +17-27,16-96 +7-99,8-94 +26-92,25-92 +17-24,17-25 +44-44,40-47 +57-64,57-65 +60-91,59-79 +23-79,22-71 +34-37,31-70 +22-60,22-59 +44-99,98-98 +9-57,49-55 +61-64,33-62 +15-68,4-15 +53-55,34-55 +13-13,9-15 +2-43,3-81 +17-56,16-99 +1-4,3-92 +76-77,73-83 +2-97,2-96 +44-45,44-55 +8-89,8-97 +23-73,22-88 +23-90,79-93 +23-87,86-91 +3-45,17-44 +7-99,8-98 +92-97,14-92 +85-89,59-90 +7-8,7-89 +5-90,49-89 +28-30,29-63 +38-61,38-60 +32-98,5-75 +22-87,71-76 +5-85,5-88 +16-96,18-88 +39-51,40-90 +21-21,19-23 +22-55,15-56 +1-75,35-59 +13-84,12-85 +11-83,23-27 +11-98,11-97 +35-92,34-92 +8-96,8-30 +48-72,33-60 +9-83,10-82 +97-97,10-98 +5-7,9-98 +1-44,3-43 +7-85,8-85 +12-32,12-52 +1-86,86-86 +3-63,4-63 +3-83,83-91 +74-88,38-74 +92-95,6-98 +11-19,10-20 +6-94,7-94 +39-90,38-42 +60-92,61-92 +43-94,44-98 +23-98,22-99 +31-41,27-32 +9-79,9-78 +63-64,11-64 +82-82,83-98 +78-79,77-78 +19-63,4-27 +26-62,27-44 +91-91,91-93 +16-94,31-93 +23-25,24-99 +78-79,11-78 +30-30,29-31 +34-85,35-84 +4-78,4-5 +42-84,43-85 +39-87,40-86 +49-84,50-84 +67-67,7-67 +38-38,62-67 +2-83,3-82 +14-33,32-68 +18-76,17-75 +68-77,68-76 +4-97,53-73 +53-97,54-96 +53-55,54-98 +35-95,75-83 +2-3,2-78 +3-97,15-96 +26-87,26-92 +4-10,9-48 +3-89,22-96 +10-85,10-84 +1-93,2-2 +24-37,37-62 +32-68,48-53 +33-96,95-97 +9-26,14-31 +16-66,13-14 +85-86,78-85 +65-82,64-81 +5-85,31-49 +47-88,59-91 +34-71,70-76 +14-14,14-14 +45-46,45-97 +63-73,63-64 +16-54,17-53 +87-88,51-87 +20-79,19-98 +3-96,2-95 +86-86,60-86 +82-82,67-82 +12-35,11-35 +15-31,26-52 +1-2,1-99 +3-96,2-2 +91-97,11-92 +41-89,42-96 +62-64,41-65 +54-54,16-55 +28-41,40-97 +15-89,89-90 +50-71,55-70 +30-66,30-93 +89-92,84-89 +25-27,26-84 +59-91,60-91 +4-11,4-98 +5-48,10-44 +53-80,77-79 +20-21,10-20 +14-86,14-85 +32-70,33-69 +94-94,26-95 +5-57,5-97 +38-50,38-92 +48-50,49-51 +13-98,12-98 +90-95,24-88 +90-94,67-91 +1-11,10-91 +48-59,59-91 +26-68,31-55 +15-56,21-57 +6-69,7-69 +6-8,5-95 +32-93,33-94 +13-73,14-42 +1-4,3-98 +30-62,29-62 +57-64,61-99 +12-27,11-46 +28-99,98-98 +7-83,8-92 +56-77,56-76 +30-89,31-51 +69-83,37-72 +11-78,11-65 +61-61,60-62 +38-65,65-66 +20-44,21-97 +39-76,40-75 +10-94,11-93 +33-90,89-96 +23-77,22-78 +63-86,62-73 +42-81,35-43 +34-91,34-55 +12-97,4-13 +1-98,1-97 +23-72,24-73 +14-99,13-99 +17-97,18-96 +65-85,14-66 +68-77,67-69 +8-96,9-9 +28-57,29-56 +14-26,14-26 +6-72,6-72 +49-49,1-48 +4-65,65-65 +53-92,54-91 +48-87,15-48 +51-54,20-72 +65-75,64-64 +4-92,3-93 +42-70,30-98 +15-71,14-15 +29-62,28-63 +6-92,6-93 +37-84,83-83 +1-99,23-98 +23-82,24-88 +2-60,61-74 +3-5,17-93 +50-63,51-62 +51-55,52-52 +30-82,5-83 +5-77,4-42 +44-99,3-99 +18-81,5-18 +2-32,32-32 +50-59,58-87 +23-30,24-40 +70-70,9-71 +40-62,49-62 +2-29,1-3 +48-69,48-49 +48-48,47-93 +5-42,17-41 +11-95,12-92 +9-66,8-65 +32-84,33-84 +16-69,15-99 +12-96,9-12 +69-91,68-70 +14-69,15-81 +96-99,50-96 +35-62,35-61 +6-22,22-60 +20-76,73-74 +4-21,4-22 +22-30,21-76 +5-90,1-6 +82-96,82-95 +18-31,19-71 +29-56,50-59 +11-21,1-61 +15-76,30-81 +1-1,2-83 +11-90,90-91 +40-90,40-41 +68-83,68-83 +25-81,25-81 +87-88,22-87 +31-65,32-64 +17-90,16-90 +11-65,11-12 +35-60,36-93 +5-93,4-94 +28-29,27-75 +12-38,37-45 +39-46,32-44 +12-89,12-97 +4-54,52-52 +5-94,94-94 +30-31,29-31 +18-82,74-76 +80-80,59-81 +3-65,54-54 +20-31,19-23 +82-87,32-82 +41-41,41-42 +6-6,6-81 +2-98,98-98 +84-94,6-95 +29-89,28-92 +27-30,28-34 +5-86,4-86 +32-96,50-96 +28-93,69-90 +75-75,27-82 +9-30,30-36 +76-76,61-77 +74-80,11-74 +48-61,48-60 +64-98,64-99 +83-87,5-88 +23-25,25-98 +55-55,39-55 +5-36,5-36 +45-57,46-85 +4-86,3-85 +19-58,20-58 +25-83,14-26 +27-74,27-27 +17-18,17-45 +81-88,62-84 +84-96,21-85 +3-81,1-2 +54-93,1-94 +1-1,3-66 +69-78,49-78 +47-93,47-93 +13-13,13-66 +18-78,18-73 +11-20,15-18 +52-99,51-99 +2-57,1-58 +9-97,10-97 +80-80,24-80 +33-77,34-47 +68-75,67-73 +20-95,19-95 +4-99,5-98 +8-85,7-85 +42-80,66-82 +22-47,31-47 +22-26,24-24 +4-98,38-44 +92-94,92-95 +82-92,71-94 +6-10,1-5 +3-92,1-92 +72-76,71-74 +6-69,7-69 +25-75,26-66 +15-51,15-63 +14-99,14-98 +7-89,6-70 +58-66,62-85 +7-11,15-23 +42-62,42-63 +1-4,4-91 +1-3,3-97 +49-79,48-80 +15-95,16-77 +6-99,5-99 +6-79,8-27 +47-69,46-68 +20-21,24-96 +13-71,60-92 +69-94,36-69 +66-86,33-67 +34-47,34-47 +4-4,4-93 +22-68,68-68 +42-90,43-90 +74-74,74-94 +3-72,3-62 +63-75,64-67 +16-48,7-48 +2-89,3-99 +2-98,3-97 +41-94,42-95 +45-93,44-98 +16-18,17-64 +69-70,47-69 +2-93,93-94 +65-94,66-95 +54-56,55-57 +5-92,2-92 +48-92,28-45 +67-68,48-67 +7-12,6-8 +7-8,6-8 +94-99,16-95 +13-49,14-48 +25-48,48-48 +6-51,7-18 +46-83,15-97 +34-57,34-58 +16-89,9-17 +41-74,41-42 +13-32,13-97 +90-99,99-99 +7-99,7-98 +78-79,63-78 +4-98,64-79 +49-75,50-80 +40-75,40-52 +14-72,6-14 +5-91,91-91 +27-55,27-27 +20-22,27-37 +35-71,34-96 +2-52,1-1 +3-87,2-87 +2-70,36-69 +38-90,39-89 +67-79,67-80 +5-77,77-78 +26-32,2-34 +10-43,43-85 +55-84,84-85 +24-59,24-58 +43-49,44-48 +60-81,59-80 +52-91,91-92 +44-62,42-63 +3-96,3-97 +29-45,30-45 +64-92,6-93 +89-96,4-90 +71-91,71-90 +50-64,60-63 +49-88,49-89 +18-98,18-90 +30-74,72-77 +32-88,4-76 +22-58,22-23 +5-71,5-18 +8-90,7-98 +4-78,4-79 +54-87,54-55 +3-91,3-92 +14-92,89-91 +41-95,42-42 +74-75,53-77 +12-90,3-12 +5-50,3-51 +27-67,66-68 +10-42,24-38 +20-79,20-81 +10-78,78-97 +26-47,35-46 +34-82,34-63 +2-94,3-98 +19-87,19-87 +4-42,6-90 +13-49,12-14 +75-75,3-76 +55-70,54-56 +86-92,85-93 +31-38,28-46 +7-90,6-91 +33-72,32-50 +22-46,45-99 +45-53,46-51 +90-91,6-90 +13-87,14-45 +41-95,14-42 +90-95,76-95 +51-70,15-89 +15-49,25-95 +15-15,15-98 +20-88,14-33 +2-67,67-70 +88-93,78-96 +77-91,53-84 +53-88,52-98 +24-96,25-25 +40-40,26-40 +3-15,9-25 +35-99,36-97 +61-61,4-62 +5-95,6-6 +52-56,52-95 +22-30,23-23 +40-44,43-63 +13-16,5-14 +18-90,89-89 +5-88,4-88 +78-83,82-82 +6-80,1-1 +15-31,14-32 +13-96,13-13 +68-76,68-69 +56-67,67-90 +24-92,92-93 +16-29,17-90 +2-99,1-90 +12-75,1-13 +21-91,20-90 +1-99,11-97 +94-94,25-95 +2-91,3-92 +95-95,2-95 +2-99,1-97 +28-98,27-29 +6-26,2-67 +20-58,19-71 +32-87,49-86 +13-57,14-56 +2-55,11-44 +13-61,12-61 +33-81,80-80 +39-91,41-44 +40-93,39-47 +83-95,40-93 +20-79,24-78 +52-93,6-94 +96-96,3-97 +44-55,36-87 +43-44,13-43 +19-99,19-98 +6-17,17-97 +91-99,88-91 +31-51,52-77 +1-97,1-2 +26-86,26-87 +50-53,40-81 +40-89,89-93 +78-83,1-79 +9-89,8-73 +6-38,7-21 +19-20,18-21 +97-97,35-97 +28-57,20-28 +3-86,86-87 +53-53,2-52 +59-99,60-99 +75-84,76-95 +20-93,21-94 +29-29,29-30 +34-92,15-58 +11-58,11-59 +11-11,10-98 +19-77,77-77 +38-56,38-71 +83-86,12-88 +8-73,5-6 +5-7,7-93 +18-79,19-72 +4-99,2-2 +5-82,5-81 +24-37,37-95 +11-63,9-12 +6-99,7-98 +92-92,91-91 +58-91,2-95 +23-98,24-59 +2-90,3-89 +54-71,1-81 +22-98,48-97 +14-49,13-76 +5-52,6-89 +6-88,76-86 +3-85,6-97 +87-94,86-88 +30-46,31-45 +63-95,9-97 +19-94,94-98 +71-75,72-74 +48-89,49-89 +27-52,52-54 +21-99,41-94 +5-96,3-5 +40-69,38-40 +74-99,73-98 +6-31,22-85 +13-76,12-75 +29-74,29-74 +10-86,11-86 +40-41,33-40 +63-94,29-94 +55-85,55-55 +14-20,18-19 +52-78,1-79 +92-96,7-92 +12-89,14-57 +32-49,49-82 +36-63,43-62 +20-94,41-93 +79-95,7-97 +5-60,5-22 +29-93,28-93 +18-68,18-67 +12-37,13-36 +12-64,12-46 +1-99,2-2 +61-92,61-82 +14-16,15-68 +68-83,67-77 +24-93,93-93 +33-99,32-33 +93-93,11-94 +27-37,26-37 +7-31,6-31 +1-45,2-67 +5-99,5-99 +20-21,18-22 +22-89,23-88 +53-58,53-56 +48-91,48-86 +11-11,10-12 +33-50,50-81 +11-47,7-20 +51-71,71-72 +15-89,15-88 +6-90,2-15 +7-88,18-91 +4-98,4-98 +9-19,3-19 +29-58,57-83 +16-34,15-33 +13-50,12-89 +17-60,17-17 +90-94,91-98 +52-77,52-76 +97-99,5-97 +42-86,53-76 +4-7,19-56 +23-63,2-41 +15-43,43-44 +19-23,22-97 +47-48,45-49 +31-73,32-73 +57-72,21-38 +54-97,53-96 +2-29,3-64 +53-79,13-77 +63-77,4-63 +94-94,4-95 +5-44,4-98 +5-99,4-98 +31-96,32-96 +44-89,43-90 +1-63,2-63 +31-60,8-32 +48-88,55-62 +36-85,35-85 +7-98,97-97 +3-52,4-99 +19-57,1-20 +65-96,66-97 +61-95,43-62 +4-94,93-93 +14-97,58-96 +26-46,6-47 +79-96,81-95 +30-88,30-87 +27-97,26-96 +24-88,24-25 +27-95,28-51 +22-24,23-76 +40-44,44-52 +4-37,3-38 +6-7,4-8 +22-24,16-25 +59-73,58-73 +2-14,3-40 +20-65,65-65 +58-87,58-86 +99-99,26-98 +10-17,16-91 +52-71,59-70 +3-87,2-87 +22-95,95-96 +55-55,10-54 +52-84,82-96 +5-82,81-81 +9-95,7-7 +53-88,88-90 +5-6,5-63 +11-68,10-85 +8-12,10-11 +40-92,43-49 +19-35,20-34 +44-46,45-85 +10-25,12-26 +63-85,54-80 +10-97,91-94 +41-50,40-42 +7-72,8-71 +1-15,12-92 +22-93,54-99 +82-94,30-83 +7-89,6-89 +6-69,5-7 +8-25,24-24 +8-47,8-47 +21-25,24-92 +81-81,81-86 +6-15,44-68 +82-82,34-82 +29-86,2-87 +37-54,20-57 +56-97,1-96 +65-65,6-65 +4-81,5-82 +78-85,37-78 +18-99,19-97 +31-97,34-96 +41-58,40-77 +11-96,10-97 +18-35,7-24 +5-75,3-74 +2-53,15-47 +9-17,9-85 +20-26,21-26 +23-70,67-68 +23-72,23-73 +36-81,9-93 +25-76,25-26 +77-77,46-77 +78-98,78-87 +91-91,14-92 +22-92,21-93 +3-3,3-87 +99-99,61-99 +18-28,19-29 +44-45,19-44 +17-60,11-17 +35-97,36-36 +58-58,11-58 +24-62,23-63 +18-56,55-81 +7-31,8-30 +60-61,1-65 +8-99,7-31 +2-4,5-6 +4-93,48-92 +2-87,1-98 +3-75,3-4 +1-53,53-54 +57-73,57-68 +11-60,2-61 +51-70,43-52 +4-33,3-34 +29-68,67-68 +75-86,28-71 +4-84,3-83 +12-96,51-96 +30-98,71-94 +54-62,60-62 +13-66,14-86 +14-42,12-43 +47-69,48-69 +58-89,86-96 +27-96,27-95 +6-66,6-16 +2-30,1-37 +27-91,27-38 +46-52,45-49 +9-64,8-75 +53-92,54-93 +35-91,35-72 +66-91,91-97 +46-81,49-81 +3-90,1-3 +53-54,52-56 +4-92,3-5 +42-84,42-77 +1-3,2-95 +8-73,9-90 +17-69,16-70 +9-20,2-10 +97-99,96-97 +1-86,2-91 +17-66,9-95 +9-10,9-97 +19-40,39-54 +5-94,5-91 +33-33,18-34 +2-3,2-3 +22-66,21-84 +37-90,37-81 +6-93,6-93 +64-81,65-78 +57-59,57-67 +69-94,68-68 +39-97,38-98 +74-79,71-79 +2-80,41-80 +5-91,28-89 +1-97,2-97 +24-61,25-94 +76-81,76-97 +48-56,48-49 +25-81,7-12 +42-99,41-41 +45-60,46-59 +19-85,57-84 +8-8,7-98 +14-53,13-54 +17-82,69-84 +73-86,24-90 +78-80,6-78 +2-76,3-26 +1-33,33-89 +12-48,48-75 +25-87,21-88 +22-68,22-71 +2-91,1-91 +59-79,7-60 +6-70,4-4 +47-94,27-94 +23-50,10-49 +2-85,2-83 +2-96,7-96 +21-93,22-92 +27-67,28-67 +32-38,32-33 +15-94,93-94 +36-74,36-37 +33-84,43-83 +5-98,2-2 +1-93,2-92 +37-97,42-70 +81-82,21-81 +14-94,13-15 +5-45,4-87 +44-96,45-95 +2-7,6-14 +14-73,25-77 +83-83,84-99 +13-62,21-73 +91-98,22-91 +19-96,86-93 +5-78,6-77 +3-97,4-98 +8-54,17-83 +9-94,10-10 +36-96,35-37 +8-93,7-98 +48-60,48-61 +17-97,9-18 +73-87,74-88 +19-63,19-63 +21-73,20-74 +1-89,26-89 +44-50,48-55 +43-70,70-71 +5-14,6-63 +23-82,22-94 +20-67,18-94 +36-52,47-51 +10-84,9-83 +18-96,18-71 +3-64,4-65 +4-7,6-89 +62-89,73-99 +4-92,3-5 +3-62,45-59 +9-98,10-97 +12-80,12-89 +14-15,18-85 +7-18,6-23 +14-70,15-24 +24-52,21-78 +63-92,32-93 +47-91,42-48 +16-91,91-95 +31-66,30-65 +52-91,5-91 +85-85,11-86 +22-69,68-68 +11-58,10-21 +47-76,42-47 +63-64,43-66 +17-29,4-66 +19-19,18-86 +33-70,33-70 +33-38,32-38 +3-5,4-99 +14-55,13-55 +4-48,4-4 +80-96,79-98 +99-99,5-29 +48-72,49-72 +5-91,3-92 +10-25,10-26 +9-11,10-28 +29-39,28-38 +19-55,55-56 +1-14,1-2 +21-81,21-81 +32-89,38-86 +31-79,31-39 +66-72,67-73 +3-3,2-29 +9-67,10-10 +24-96,23-25 +90-94,90-93 +91-91,7-92 +45-98,44-93 +1-76,3-75 +14-59,22-60 +12-70,4-21 +30-93,25-98 +18-30,9-19 +1-4,3-90 +9-95,9-22 +92-96,59-92 +26-67,22-25 +7-9,8-30 +74-82,82-83 +92-92,4-93 +14-76,2-63 +52-86,51-82 +11-98,10-12 +2-97,96-96 +18-91,18-99 +15-36,17-92 +14-90,13-91 +14-88,87-99 +47-92,48-92 +3-97,10-93 +9-87,80-98 +4-96,3-5 +89-99,3-89 +11-65,10-66 +4-52,52-93 +29-31,12-28 diff --git a/2022/day04/main b/2022/day04/main new file mode 100755 index 0000000..498303f Binary files /dev/null and b/2022/day04/main differ diff --git a/2022/day04/main.c b/2022/day04/main.c new file mode 100644 index 0000000..8233265 --- /dev/null +++ b/2022/day04/main.c @@ -0,0 +1,15 @@ +#include + +int main() +{ + int a1,a2,b1,b2; + int overlaps = 0; + while (scanf("%d-%d,%d-%d", &a1, &a2, &b1, &b2) != EOF) + { + // printf("%d-%d,%d-%d", a1, a2, b1, b2); + if ( ((a1 >= b1) && (a2 <= b2)) || ((b1 >= a1) && (b2 <= a2))) { + overlaps++; + } + } + printf("%d\n", overlaps); +} diff --git a/2022/day04/main2.c b/2022/day04/main2.c new file mode 100644 index 0000000..d26bdb6 --- /dev/null +++ b/2022/day04/main2.c @@ -0,0 +1,18 @@ +#include + +int main() +{ + int a1,a2,b1,b2; + int overlaps = 0; + while (scanf("%d-%d,%d-%d", &a1, &a2, &b1, &b2) != EOF) + { + // printf("%d-%d,%d-%d", a1, a2, b1, b2); + if ( + ((a1 >= b1) && (a2 <= b2)) || ((b1 >= a1) && (b2 <= a2)) || + ((a1 <= b1) && (a2 >= b1) || (a1 <= b2) && (a2 >= b2) ) + ) { + overlaps++; + } + } + printf("%d\n", overlaps); +} -- cgit v1.2.3