aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2022/04/.gitignore1
-rw-r--r--2022/04/Makefile1
-rw-r--r--2022/04/input1000
-rw-r--r--2022/04/puzzles.awk10
4 files changed, 1012 insertions, 0 deletions
diff --git a/2022/04/.gitignore b/2022/04/.gitignore
new file mode 100644
index 0000000..95a78b1
--- /dev/null
+++ b/2022/04/.gitignore
@@ -0,0 +1 @@
+puzzle-[12].awk
diff --git a/2022/04/Makefile b/2022/04/Makefile
new file mode 100644
index 0000000..3e0defd
--- /dev/null
+++ b/2022/04/Makefile
@@ -0,0 +1 @@
+include ../../Makefiles/awk.mk
diff --git a/2022/04/input b/2022/04/input
new file mode 100644
index 0000000..e2d1be7
--- /dev/null
+++ b/2022/04/input
@@ -0,0 +1,1000 @@
+5-96,6-99
+29-97,80-97
+3-87,3-4
+12-12,6-12
+64-65,24-66
+52-54,1-53
+86-89,85-88
+37-69,38-38
+81-96,47-75
+1-13,18-44
+46-93,46-63
+12-75,65-75
+27-58,27-34
+10-74,83-87
+17-19,18-95
+96-96,10-95
+1-90,7-89
+62-79,90-98
+5-93,6-96
+17-82,31-82
+1-2,1-12
+37-50,49-92
+21-65,20-79
+7-61,8-91
+2-6,1-99
+51-92,51-52
+18-18,20-94
+21-26,27-69
+7-86,6-86
+71-71,72-99
+34-96,95-95
+63-64,11-71
+85-87,42-86
+3-4,4-74
+14-14,13-97
+8-12,9-10
+70-78,65-79
+6-10,5-5
+4-78,46-78
+21-21,22-94
+20-21,19-19
+7-56,6-56
+16-84,84-84
+8-14,15-88
+61-90,60-63
+25-75,42-75
+39-54,50-54
+48-86,48-71
+4-45,5-5
+55-55,57-87
+1-97,1-54
+39-44,39-41
+10-41,40-41
+75-87,4-88
+11-88,87-89
+10-74,75-75
+4-98,5-95
+1-70,5-93
+85-90,85-91
+11-33,8-32
+6-79,5-79
+51-97,50-96
+16-29,16-20
+49-56,9-56
+35-91,34-91
+2-6,10-58
+29-55,54-55
+15-53,15-59
+39-91,44-46
+96-96,95-99
+33-49,33-48
+61-96,61-95
+20-86,18-86
+18-98,17-84
+13-20,8-14
+25-39,24-25
+23-32,27-37
+25-51,5-24
+44-91,45-91
+83-83,37-84
+87-87,17-86
+24-42,23-42
+1-62,49-62
+40-82,88-91
+58-91,59-93
+12-62,11-53
+17-36,37-74
+13-70,71-71
+17-60,17-77
+15-48,63-74
+3-89,10-90
+35-36,35-82
+74-99,23-87
+15-94,15-91
+99-99,23-86
+60-89,88-89
+25-83,33-84
+12-83,12-13
+9-68,8-68
+57-99,18-57
+24-31,24-64
+70-97,71-86
+10-22,15-79
+24-77,16-77
+82-84,66-85
+83-84,50-84
+9-98,8-98
+5-77,76-77
+5-94,6-90
+48-57,34-64
+18-49,25-50
+15-85,1-14
+15-72,15-91
+10-82,9-96
+4-4,3-87
+9-93,10-10
+2-92,2-85
+20-95,21-21
+53-67,66-67
+2-97,1-97
+49-72,12-66
+48-57,47-47
+86-95,95-95
+41-87,41-75
+37-83,62-84
+75-90,38-63
+35-95,22-36
+70-78,42-77
+23-99,98-98
+49-58,2-62
+16-35,10-18
+24-63,91-98
+34-36,35-72
+19-94,88-94
+5-28,3-3
+9-81,10-82
+68-94,99-99
+5-53,3-54
+56-91,2-91
+7-9,10-43
+17-71,72-84
+19-55,18-20
+13-93,85-94
+4-6,5-53
+13-99,69-99
+29-31,29-40
+47-81,48-48
+78-96,79-99
+14-88,89-89
+42-51,43-75
+86-98,84-96
+36-57,29-37
+71-84,83-83
+5-68,5-88
+3-86,29-86
+79-97,7-63
+36-49,47-63
+17-45,4-42
+2-17,16-83
+53-66,54-86
+81-99,17-80
+9-37,29-38
+49-50,22-50
+81-81,43-80
+28-75,37-76
+4-98,3-98
+5-11,11-86
+5-70,69-81
+70-70,69-87
+17-57,16-57
+16-92,14-92
+19-22,13-22
+32-90,5-91
+37-73,8-73
+4-84,1-2
+22-53,22-61
+75-99,74-97
+57-81,13-81
+32-33,12-33
+56-78,56-92
+11-84,85-85
+8-49,49-74
+6-91,7-70
+38-93,93-93
+92-92,35-91
+95-98,10-90
+5-36,4-92
+36-36,14-36
+1-59,42-59
+88-92,8-47
+21-57,6-22
+7-86,12-99
+29-63,97-99
+12-79,80-80
+20-22,24-92
+95-96,25-96
+12-26,13-16
+54-58,32-58
+64-65,60-64
+36-78,35-35
+3-55,1-2
+9-56,4-40
+32-36,76-96
+1-2,3-99
+69-95,14-97
+93-93,78-93
+78-78,59-79
+23-77,10-78
+7-71,70-71
+8-93,2-94
+3-3,4-98
+77-98,5-98
+16-16,16-98
+17-48,16-17
+98-99,3-80
+41-63,41-55
+54-54,53-86
+32-63,40-46
+77-78,18-77
+32-55,33-33
+89-97,66-97
+6-90,90-97
+3-81,3-64
+9-99,3-93
+6-99,5-94
+62-93,86-94
+95-95,11-95
+17-99,8-13
+34-84,35-97
+23-23,22-85
+85-85,22-85
+8-24,7-44
+9-92,9-33
+1-63,1-96
+28-97,30-97
+12-90,8-89
+14-14,2-15
+38-79,38-39
+54-55,55-57
+46-80,34-79
+12-80,11-95
+9-56,8-56
+64-94,28-93
+14-14,15-95
+3-43,44-51
+19-61,5-5
+62-99,15-95
+67-78,77-79
+23-40,24-40
+1-55,9-54
+6-81,1-80
+4-84,4-85
+4-4,6-94
+68-89,20-67
+10-79,9-11
+26-52,26-27
+16-60,12-60
+92-92,7-92
+51-51,56-72
+2-7,6-99
+35-36,36-36
+98-99,8-97
+87-87,4-86
+83-89,68-75
+6-92,6-91
+64-74,65-65
+14-70,15-73
+18-22,18-56
+3-99,2-99
+7-95,2-96
+34-82,34-34
+46-94,45-94
+14-52,1-13
+29-93,28-28
+1-40,2-32
+24-28,23-28
+55-83,18-65
+3-84,1-84
+2-57,7-58
+7-21,3-22
+20-78,20-79
+88-99,32-46
+25-58,57-99
+37-84,37-70
+18-76,18-80
+14-99,31-98
+54-83,54-83
+14-14,2-13
+1-81,1-20
+3-54,4-89
+15-48,14-14
+7-76,75-76
+4-4,3-16
+11-12,11-97
+27-90,28-60
+4-99,1-39
+10-62,41-62
+8-93,9-92
+14-78,27-87
+10-25,24-25
+16-42,15-93
+25-68,76-89
+46-46,2-47
+67-96,65-89
+53-54,53-53
+40-74,15-26
+58-75,57-59
+12-17,16-17
+11-31,30-66
+16-49,17-49
+7-82,15-82
+42-60,41-41
+32-34,3-33
+5-7,6-59
+27-64,94-99
+17-72,34-73
+12-97,12-13
+53-61,52-65
+1-97,1-96
+85-86,27-86
+11-85,10-85
+78-98,19-77
+6-99,98-99
+58-58,10-57
+13-91,12-93
+77-80,76-80
+22-24,23-80
+80-80,28-81
+21-74,5-19
+35-87,36-74
+7-68,82-82
+2-35,10-74
+39-66,40-54
+21-38,29-61
+18-59,41-60
+14-94,97-99
+47-53,54-71
+28-84,49-85
+71-95,70-88
+6-98,6-51
+7-26,27-27
+18-79,2-81
+29-79,28-88
+16-16,16-61
+11-49,48-54
+28-28,27-84
+9-94,94-95
+3-8,2-43
+3-89,89-89
+57-79,60-78
+27-96,28-94
+5-81,61-80
+34-63,64-79
+12-14,15-96
+8-99,24-99
+14-14,15-81
+3-78,12-95
+48-92,48-93
+80-99,1-98
+79-98,87-95
+5-77,77-78
+36-41,36-40
+5-86,1-6
+10-66,11-11
+48-74,76-84
+66-98,19-66
+8-53,52-52
+28-99,19-28
+9-68,63-65
+2-6,1-97
+22-74,22-86
+5-8,7-50
+8-80,7-87
+91-95,77-82
+2-21,97-99
+1-2,3-74
+2-94,1-98
+3-93,94-96
+1-2,1-25
+30-67,30-70
+52-96,96-98
+81-82,71-82
+24-48,4-25
+4-50,6-50
+89-89,88-88
+97-97,18-97
+47-95,46-96
+5-81,4-92
+1-1,2-84
+97-97,1-98
+8-32,2-33
+5-57,4-56
+30-53,25-29
+6-16,4-11
+90-90,33-89
+80-81,80-96
+1-2,1-61
+62-73,62-72
+47-82,47-83
+17-97,17-17
+8-89,2-7
+2-91,67-91
+29-67,29-66
+2-99,3-96
+59-89,88-88
+43-73,43-72
+23-67,23-68
+5-75,75-75
+10-97,9-11
+33-82,33-34
+45-89,46-46
+4-97,4-93
+7-16,16-79
+17-21,20-36
+65-95,96-96
+36-63,37-37
+3-78,77-77
+4-96,5-76
+21-72,20-20
+46-73,46-72
+70-98,71-99
+48-99,8-99
+1-98,1-65
+69-69,20-70
+10-37,38-55
+45-46,36-46
+35-47,35-48
+8-86,7-86
+12-77,38-77
+9-26,5-26
+12-89,12-88
+11-68,29-69
+72-72,5-73
+50-83,10-82
+3-67,3-67
+12-97,12-89
+14-99,15-95
+17-67,18-39
+4-88,4-87
+28-28,22-29
+31-38,31-32
+6-46,6-16
+48-48,47-54
+24-95,25-40
+73-89,73-91
+13-17,11-20
+29-51,30-52
+12-86,12-85
+36-52,35-52
+6-99,7-7
+6-6,2-5
+41-74,73-86
+31-87,73-87
+20-90,20-87
+47-76,46-76
+36-37,38-78
+74-97,73-73
+63-85,62-93
+1-95,97-98
+5-90,5-93
+19-65,52-65
+4-54,21-54
+8-8,7-86
+94-98,2-85
+46-46,47-49
+53-53,52-61
+15-94,13-15
+56-73,27-74
+95-95,3-95
+61-63,7-62
+29-85,97-99
+39-74,73-75
+6-95,43-94
+3-3,3-16
+3-98,99-99
+35-94,36-94
+14-75,76-77
+39-45,38-38
+6-6,7-94
+3-56,7-55
+92-96,36-81
+17-85,18-85
+87-90,10-86
+19-91,18-96
+61-72,60-60
+62-86,85-87
+87-87,23-86
+36-89,37-37
+1-94,1-95
+5-60,5-61
+96-97,96-99
+23-31,15-30
+14-52,52-52
+44-87,43-87
+25-99,20-26
+53-85,55-85
+44-62,43-98
+77-78,64-78
+85-86,85-90
+25-43,41-43
+32-65,64-66
+18-87,18-81
+6-60,7-7
+32-79,78-80
+13-18,13-13
+14-92,14-14
+1-98,1-97
+21-23,22-98
+19-61,18-18
+1-98,3-97
+6-64,14-64
+2-7,33-96
+75-77,11-76
+40-52,31-77
+21-35,15-36
+31-64,13-32
+89-90,51-90
+14-77,34-78
+51-85,52-96
+73-73,20-74
+36-44,41-44
+8-36,32-40
+44-94,93-98
+5-54,5-53
+45-97,4-42
+28-50,25-27
+58-76,58-76
+6-78,77-78
+19-96,20-90
+85-86,1-86
+12-70,11-11
+9-85,86-86
+45-46,44-70
+43-74,10-73
+60-91,11-91
+1-65,64-87
+13-14,14-79
+46-46,45-45
+58-89,59-59
+3-98,1-98
+23-53,8-53
+9-99,8-10
+12-75,12-74
+8-70,24-71
+57-94,8-94
+78-92,77-92
+3-54,1-36
+89-99,87-92
+2-86,86-86
+76-84,83-93
+17-70,18-72
+11-89,10-82
+8-99,9-18
+39-53,39-53
+13-46,13-57
+2-95,49-56
+52-54,52-57
+30-58,31-58
+10-45,10-46
+9-75,8-72
+5-75,1-75
+2-67,4-66
+9-93,10-10
+1-99,75-99
+24-90,24-25
+15-91,15-93
+49-58,64-92
+33-73,73-74
+10-76,12-77
+16-88,87-87
+60-91,50-61
+40-61,39-75
+61-62,2-62
+7-88,7-8
+22-97,21-94
+61-61,25-60
+21-81,9-36
+66-95,16-94
+3-97,1-1
+22-81,21-21
+36-48,35-74
+19-57,29-56
+81-82,14-82
+31-73,73-76
+4-92,8-92
+16-17,16-17
+9-97,10-99
+62-64,63-95
+10-18,3-17
+63-63,63-94
+13-88,8-88
+45-48,7-47
+2-65,3-98
+6-17,5-13
+54-79,53-79
+58-63,58-58
+42-64,8-49
+58-91,2-57
+25-98,12-26
+11-17,10-81
+23-23,18-22
+34-98,33-58
+28-56,29-57
+46-99,16-98
+16-78,17-17
+41-42,37-42
+15-31,14-14
+20-60,61-61
+29-48,23-26
+24-88,5-47
+17-86,4-16
+31-95,31-96
+15-62,22-62
+36-46,7-45
+13-94,9-10
+67-67,3-66
+33-33,21-34
+1-94,3-94
+5-99,6-97
+85-92,19-43
+67-90,81-90
+1-8,9-96
+30-30,31-53
+8-37,7-25
+8-82,4-28
+17-18,17-76
+59-69,34-58
+5-93,20-93
+3-97,99-99
+20-88,94-96
+14-94,92-99
+21-99,22-97
+24-91,23-23
+27-66,28-67
+98-99,1-96
+61-76,18-80
+30-86,85-85
+21-96,20-98
+47-83,10-47
+37-40,36-58
+80-81,21-80
+25-74,4-87
+4-68,67-68
+17-22,5-7
+17-67,25-67
+1-99,1-2
+88-96,84-93
+5-93,97-98
+4-89,90-93
+41-45,42-42
+16-80,15-83
+23-94,23-88
+1-1,2-80
+28-58,59-59
+35-36,36-36
+1-48,1-75
+1-5,14-99
+44-60,44-77
+97-97,6-98
+24-61,3-68
+23-35,24-35
+91-91,92-93
+30-48,29-58
+20-83,13-82
+17-88,18-99
+2-3,2-98
+63-63,59-64
+94-94,1-93
+40-47,5-46
+16-88,16-88
+26-84,25-99
+32-88,31-33
+29-80,30-75
+98-99,14-94
+10-34,35-35
+74-85,75-80
+43-88,42-89
+3-93,17-94
+5-10,4-43
+89-99,81-85
+45-71,46-46
+7-89,6-82
+2-2,2-88
+32-85,5-97
+55-91,54-56
+72-97,21-96
+18-97,18-19
+18-73,19-74
+92-99,7-88
+35-81,36-36
+3-59,60-99
+3-4,3-87
+36-97,28-97
+16-51,38-52
+5-25,4-18
+49-92,28-46
+2-3,4-92
+85-85,47-85
+4-77,78-78
+45-70,71-78
+93-99,79-99
+84-98,48-99
+1-1,1-99
+14-94,13-95
+21-44,22-45
+87-88,6-88
+52-96,95-95
+12-87,11-91
+47-72,11-52
+64-72,34-63
+25-78,26-26
+84-87,82-86
+55-63,23-62
+8-60,59-60
+9-40,3-10
+43-97,80-97
+8-95,3-95
+56-58,57-90
+14-52,15-52
+11-11,11-35
+20-56,21-57
+2-89,2-76
+1-72,3-73
+25-27,26-59
+35-97,35-42
+24-88,1-67
+71-83,71-75
+30-33,32-33
+2-97,2-2
+12-56,5-55
+18-67,23-94
+42-67,68-68
+70-89,18-58
+71-82,27-71
+24-69,25-50
+9-64,8-10
+68-83,9-83
+17-95,98-98
+8-17,16-18
+12-43,15-97
+30-76,30-96
+41-52,10-51
+29-95,2-95
+1-91,90-91
+10-89,8-90
+1-99,31-99
+62-83,33-82
+54-56,11-55
+4-54,53-55
+69-69,26-70
+47-93,46-46
+8-85,9-85
+48-61,48-97
+33-79,32-97
+1-47,9-48
+29-63,64-64
+32-93,27-90
+70-70,67-69
+66-97,67-68
+28-68,28-67
+21-92,4-91
+1-87,3-88
+25-76,21-75
+69-76,72-76
+88-89,40-89
+37-38,37-97
+41-61,60-61
+39-76,75-77
+14-28,3-13
+56-96,56-92
+85-86,9-85
+82-82,68-81
+46-78,40-78
+45-68,44-44
+70-83,30-83
+93-95,20-92
+18-33,29-30
+24-91,66-91
+1-77,14-97
+24-72,73-73
+15-71,15-16
+8-93,7-24
+14-44,43-43
+15-66,15-65
+4-58,9-61
+15-49,33-61
+1-59,1-60
+39-97,38-96
+91-92,4-92
+6-79,3-96
+9-94,95-95
+12-60,23-75
+51-59,40-50
+19-30,20-99
+72-97,97-98
+33-60,58-61
+3-10,3-9
+21-34,20-98
+3-65,53-78
+7-48,7-7
+61-71,59-60
+5-10,4-4
+87-88,8-88
+1-19,12-26
+6-89,26-89
+74-96,74-74
+16-40,10-12
+87-87,9-86
+5-7,8-92
+7-89,6-6
+44-95,45-59
+87-92,4-85
+62-63,43-63
+4-22,4-93
+22-71,21-38
+46-57,56-57
+39-90,39-92
+3-28,2-86
+35-84,84-84
+4-69,9-69
+34-34,35-95
+67-96,1-90
+10-54,45-95
+4-85,3-88
+26-97,25-99
+14-21,22-22
+52-66,24-86
+7-53,8-91
+99-99,7-61
+1-3,4-99
+24-87,24-94
+17-89,16-18
+13-55,30-42
+2-48,21-48
+31-38,37-37
+1-98,1-97
+4-21,1-3
+7-7,6-10
+14-77,68-77
+45-98,50-98
+4-96,5-96
+43-77,15-78
+32-51,24-60
+99-99,1-98
+41-41,42-67
+7-73,9-72
+16-77,15-15
+9-44,43-43
+13-76,14-61
+14-16,15-56
+1-65,8-66
+18-57,18-19
+24-24,31-46
+7-90,90-90
+1-81,13-81
+39-88,40-59
+2-95,1-1
+48-48,22-49
+12-90,11-91
+4-96,1-65
+13-63,36-64
+4-90,5-86
+24-93,96-97
+11-90,89-89
+30-91,30-31
+99-99,28-94
+18-55,14-94
+79-89,10-90
+98-98,27-97
+12-71,4-11
+89-97,21-92
+19-80,18-91
+51-58,13-55
+42-56,41-79
+57-75,57-70
+19-63,33-62
+77-82,7-85
+45-95,96-96
+97-98,11-98
+6-87,6-7
+3-85,67-86
+50-97,50-50
+26-50,50-68
+37-53,12-54
+8-29,8-29
+82-98,1-97
+16-16,17-98
+93-93,91-92
+5-99,4-76
+2-56,2-3
+6-7,6-61
+68-81,3-69
+6-84,7-84
+13-65,64-64
+92-98,5-91
+31-70,32-92
+1-51,51-51
+3-30,3-92
+68-77,53-69
+43-52,46-48
+82-96,69-81
+13-36,12-74
+28-75,61-76
+7-61,8-8
+20-80,20-51
+33-89,83-90
+13-13,14-92
+1-1,1-99
+8-16,15-97
+26-28,26-41
+62-80,62-62
+1-76,35-75
+7-56,7-98
+33-76,32-38
+8-9,8-50
+1-61,61-61
+14-73,14-96
+62-89,89-89
+9-9,8-99
+3-4,4-95
+9-72,8-10
+37-37,36-36
+18-79,24-80
+92-92,9-91
+29-50,29-30
+68-68,65-67
+39-83,79-83
+60-82,39-51
+13-96,95-96
+4-85,68-85
+44-49,48-48
+31-42,30-73
+10-74,9-73
+65-65,32-65
+91-92,8-92
+14-85,84-85
+34-41,14-40
+1-32,1-88
+78-80,74-79
+29-85,86-93
+24-27,28-97
+85-86,57-79
+22-46,41-54
+74-99,5-31
+8-11,11-85
+25-71,24-24
+29-95,11-96
+65-65,66-92
+9-53,4-53
+18-98,19-75
+32-39,35-86
+4-98,2-2
+10-69,1-70
+55-93,94-97
+6-99,2-7
+62-90,70-74
+48-74,26-97
+5-80,15-37
+1-97,84-98
+2-98,68-79
+96-97,46-97
+34-99,98-98
+66-73,65-67
+42-43,25-44
+5-99,5-98
+4-5,4-58
+78-91,6-91
+91-95,16-90
+32-88,88-88
+56-89,55-93
+5-25,4-4
+60-98,61-96
+58-61,57-62
+13-60,59-60
+19-29,20-44
+15-29,14-94
+4-4,5-11
+46-78,6-78
+29-29,29-72
+1-95,68-94
+36-51,50-51
+10-85,9-9
+15-60,16-93
+3-60,5-61
+7-70,11-69
+6-68,5-6
+49-84,40-54
+63-89,76-90
+6-13,9-72
+98-99,5-97
+71-71,33-73
+19-63,18-64
+32-76,20-77
+11-97,12-93
+11-11,3-11
+29-65,19-48
+63-64,13-64
+2-91,92-92
+85-91,86-91
+10-85,11-64
diff --git a/2022/04/puzzles.awk b/2022/04/puzzles.awk
new file mode 100644
index 0000000..8ba715d
--- /dev/null
+++ b/2022/04/puzzles.awk
@@ -0,0 +1,10 @@
+#!/usr/bin/awk -f
+
+BEGIN { FS = "[,-]" }
+# START PART 1
+($1 <= $3 && $2 >= $4) || ($1 >= $3 && $2 <= $4) { c++ }
+# END PART 1 START PART 2
+($3 >= $1 && $3 <= $2) || ($4 >= $1 && $4 <= $2) ||
+ ($1 >= $3 && $1 <= $4) || ($2 >= $3 && $2 <= $4) { c++ }
+# END PART 2
+END { print c }