aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--2022/04-camp-cleanup/example6
-rw-r--r--2022/04-camp-cleanup/first.zig26
-rw-r--r--2022/04-camp-cleanup/input1000
-rw-r--r--2022/04-camp-cleanup/second.zig26
4 files changed, 1058 insertions, 0 deletions
diff --git a/2022/04-camp-cleanup/example b/2022/04-camp-cleanup/example
new file mode 100644
index 0000000..9f9e9cf
--- /dev/null
+++ b/2022/04-camp-cleanup/example
@@ -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/04-camp-cleanup/first.zig b/2022/04-camp-cleanup/first.zig
new file mode 100644
index 0000000..6a5bf52
--- /dev/null
+++ b/2022/04-camp-cleanup/first.zig
@@ -0,0 +1,26 @@
+const std = @import("std");
+
+const example = @embedFile("example");
+const input = @embedFile("input");
+
+pub fn main() anyerror!void {
+ try std.testing.expectEqual(solve(example), 2);
+ const result = try solve(input);
+ try std.io.getStdOut().writer().print("{}\n", .{result});
+}
+
+fn solve(puzzle: []const u8) !u64 {
+ var it = std.mem.tokenize(u8, puzzle, "\n");
+ var tot: u64 = 0;
+ while (it.next()) |line| {
+ var it2 = std.mem.tokenize(u8, line, "-,");
+ const a = try std.fmt.parseInt(u64, it2.next() orelse unreachable, 10);
+ const b = try std.fmt.parseInt(u64, it2.next() orelse unreachable, 10);
+ const c = try std.fmt.parseInt(u64, it2.next() orelse unreachable, 10);
+ const d = try std.fmt.parseInt(u64, it2.next() orelse unreachable, 10);
+ if (a <= c and b >= d or a >= c and b <= d) {
+ tot += 1;
+ }
+ }
+ return tot;
+}
diff --git a/2022/04-camp-cleanup/input b/2022/04-camp-cleanup/input
new file mode 100644
index 0000000..ee102df
--- /dev/null
+++ b/2022/04-camp-cleanup/input
@@ -0,0 +1,1000 @@
+14-28,13-28
+72-81,82-91
+4-4,6-95
+47-49,48-59
+26-36,37-76
+2-99,98-99
+26-36,19-35
+85-85,13-84
+14-94,15-95
+26-89,16-27
+84-89,29-88
+2-61,1-60
+80-92,2-81
+35-47,19-36
+68-70,69-86
+59-97,12-92
+56-65,12-49
+18-18,18-55
+7-98,7-98
+61-94,32-93
+88-98,2-96
+39-39,44-84
+62-62,62-83
+7-30,8-60
+47-90,46-64
+22-73,21-41
+15-78,14-14
+52-72,53-98
+83-85,68-84
+61-73,63-74
+8-9,9-94
+5-97,46-98
+35-99,3-94
+68-95,67-83
+41-55,56-56
+10-90,9-11
+14-48,14-47
+57-65,64-93
+33-51,33-50
+15-79,13-16
+38-41,39-42
+1-15,6-16
+6-96,81-98
+32-42,35-43
+20-52,9-51
+5-67,66-68
+56-56,2-55
+13-59,14-60
+10-86,9-86
+4-45,5-46
+76-80,75-79
+1-98,1-97
+23-48,15-45
+8-21,20-99
+20-68,21-86
+21-28,22-27
+25-42,15-26
+5-88,98-99
+5-56,14-34
+98-99,33-99
+2-84,83-98
+43-69,42-67
+3-3,3-62
+72-83,74-84
+10-12,11-91
+19-74,53-75
+10-98,9-99
+30-96,29-30
+32-68,67-83
+24-33,32-92
+29-60,30-61
+12-19,14-39
+34-96,95-97
+15-18,14-89
+44-50,45-53
+78-81,2-78
+7-89,71-90
+5-36,27-44
+2-95,9-96
+4-63,3-98
+10-57,9-56
+42-91,41-60
+30-75,82-99
+56-98,99-99
+7-45,45-46
+32-95,31-89
+99-99,2-97
+60-98,24-98
+2-69,70-86
+74-97,7-98
+4-68,5-63
+27-65,7-83
+1-74,62-76
+24-65,25-78
+15-98,20-95
+8-50,49-82
+98-99,20-98
+3-89,6-90
+66-85,66-86
+64-96,63-63
+3-19,1-81
+7-94,93-95
+45-88,95-96
+7-12,11-83
+35-70,34-71
+3-98,2-2
+41-92,40-42
+2-94,1-1
+75-97,78-96
+46-68,68-91
+34-35,33-48
+97-97,68-95
+73-73,31-72
+18-61,17-60
+8-95,9-96
+9-64,29-67
+68-70,32-82
+34-66,34-65
+48-97,96-96
+4-81,3-48
+12-80,8-13
+10-33,11-34
+31-74,20-54
+47-97,46-67
+42-99,43-98
+75-75,50-74
+6-95,2-5
+2-96,3-95
+15-60,45-61
+7-52,7-52
+16-76,17-77
+37-95,38-94
+59-76,75-76
+79-90,26-80
+25-60,60-92
+75-77,37-76
+56-91,57-92
+25-68,67-76
+94-98,2-92
+2-94,1-3
+2-24,3-84
+58-93,92-94
+38-97,38-99
+32-95,31-33
+27-47,23-28
+73-90,61-72
+60-60,61-94
+2-51,12-51
+37-85,40-86
+98-98,17-97
+5-99,1-1
+6-16,15-75
+93-94,57-94
+78-96,77-91
+27-28,28-77
+95-97,61-96
+1-67,66-68
+80-93,11-79
+7-7,6-8
+5-93,14-89
+23-49,3-49
+10-60,19-61
+32-77,31-32
+4-50,3-4
+19-26,20-57
+18-23,22-85
+59-71,16-72
+81-99,51-82
+14-44,13-43
+46-90,24-91
+2-3,3-98
+3-99,6-97
+68-77,29-69
+94-98,30-94
+46-98,10-97
+13-75,12-74
+60-81,59-67
+16-90,15-15
+12-85,4-10
+82-99,1-98
+2-92,64-92
+75-97,1-94
+5-71,3-70
+23-63,24-64
+44-78,19-79
+60-65,60-66
+29-84,28-83
+21-86,20-28
+1-42,6-43
+30-63,30-63
+50-84,61-93
+6-74,5-73
+40-93,39-57
+1-99,1-31
+14-88,75-87
+50-83,50-50
+2-94,1-1
+24-81,23-89
+82-92,93-93
+32-84,83-98
+7-74,7-7
+34-96,96-99
+9-22,10-98
+56-95,21-57
+14-30,15-78
+11-36,35-37
+79-85,73-86
+65-68,64-67
+12-18,15-67
+42-84,41-43
+52-52,3-51
+80-82,27-81
+5-24,5-23
+38-38,39-61
+10-33,33-34
+7-83,9-82
+39-71,36-72
+82-82,2-81
+10-20,20-76
+21-71,20-20
+55-66,55-65
+2-3,4-54
+41-54,25-40
+10-25,24-26
+49-97,96-99
+9-58,9-57
+88-88,3-89
+5-94,4-93
+38-58,12-37
+1-6,31-79
+4-96,87-92
+10-62,1-61
+23-53,22-23
+6-93,6-93
+73-81,19-67
+49-50,29-50
+68-97,67-96
+23-60,44-91
+20-65,4-5
+53-82,52-53
+5-95,5-5
+45-55,27-54
+3-80,1-79
+29-38,28-28
+63-68,68-78
+13-73,10-72
+26-85,26-85
+65-98,28-60
+56-56,57-59
+21-99,14-53
+13-77,14-77
+67-99,54-68
+14-98,13-13
+54-91,55-90
+56-58,57-97
+74-88,74-88
+92-93,2-93
+2-95,1-94
+33-52,43-53
+25-64,26-88
+24-86,9-25
+13-76,5-14
+31-80,30-32
+97-99,47-98
+2-92,2-2
+6-54,2-53
+5-89,4-95
+1-76,78-78
+54-69,53-59
+20-76,21-77
+78-79,18-78
+35-96,97-97
+6-71,72-79
+1-3,2-88
+31-88,32-88
+89-91,69-90
+39-41,3-40
+28-95,94-96
+9-69,57-68
+5-89,6-88
+8-20,32-82
+62-96,63-96
+71-94,71-71
+51-80,42-62
+45-96,97-98
+15-89,89-99
+23-94,34-44
+4-64,63-63
+53-64,53-65
+16-99,4-98
+40-41,41-69
+43-95,94-95
+45-55,46-65
+17-19,2-18
+13-58,13-55
+64-90,65-91
+80-82,81-83
+5-87,88-88
+16-96,22-79
+2-61,1-59
+10-45,10-10
+46-46,46-68
+71-75,70-73
+6-8,11-84
+31-38,37-38
+16-65,16-85
+8-56,7-55
+11-36,35-37
+62-85,29-86
+46-67,66-67
+92-92,30-91
+58-66,58-63
+22-40,12-39
+57-68,57-57
+19-72,71-88
+98-98,1-97
+3-97,6-84
+37-88,23-51
+6-92,93-93
+13-86,1-86
+8-62,9-63
+15-41,14-31
+92-95,45-94
+5-13,18-87
+20-37,21-37
+8-93,99-99
+97-97,93-98
+44-73,43-72
+73-80,67-81
+23-79,23-38
+10-12,11-38
+1-14,10-56
+31-31,12-30
+32-56,56-92
+90-98,1-87
+42-72,41-72
+48-60,48-59
+68-69,70-70
+25-95,94-97
+55-55,13-54
+55-65,55-55
+5-91,3-90
+1-95,9-91
+66-66,67-80
+26-95,27-94
+3-11,2-2
+56-81,55-72
+19-84,52-91
+14-96,15-97
+4-70,3-69
+60-84,59-84
+11-34,11-33
+8-93,96-98
+50-95,49-77
+10-51,50-79
+7-35,34-34
+20-25,24-92
+25-27,26-50
+87-88,76-86
+8-85,8-25
+63-78,64-84
+95-98,70-96
+94-99,94-99
+29-92,30-92
+33-80,33-88
+67-71,68-72
+2-3,3-93
+11-71,12-72
+12-57,57-57
+3-4,4-95
+42-90,43-91
+85-86,85-98
+4-78,1-77
+6-99,6-6
+6-83,82-84
+4-79,4-79
+4-42,32-41
+80-85,4-81
+1-40,39-68
+2-78,78-79
+20-69,24-70
+36-61,37-62
+82-84,13-83
+35-36,19-35
+3-3,4-67
+12-20,21-21
+18-24,24-56
+92-94,93-95
+30-83,30-70
+4-81,2-82
+4-22,23-88
+64-64,37-63
+9-41,29-62
+48-95,69-96
+52-68,52-69
+12-81,13-82
+5-6,6-84
+14-84,15-84
+61-61,61-91
+18-26,27-31
+15-83,14-82
+46-70,7-84
+1-41,40-46
+60-62,4-61
+34-92,33-91
+38-64,39-65
+8-94,8-94
+31-84,62-97
+31-32,31-46
+69-97,40-56
+24-35,35-72
+37-85,36-84
+63-65,9-64
+34-51,35-57
+5-96,95-96
+26-86,29-86
+4-80,2-81
+53-62,53-62
+33-83,34-84
+25-82,1-7
+24-39,23-24
+67-68,68-69
+21-58,2-22
+54-61,62-68
+96-99,26-96
+26-70,2-27
+6-94,5-96
+72-88,62-87
+7-76,67-72
+67-98,60-85
+38-39,39-91
+7-23,7-10
+22-60,21-59
+3-3,4-93
+9-66,33-53
+53-76,54-76
+23-85,6-98
+82-88,82-88
+42-78,15-84
+54-78,59-79
+8-99,7-9
+5-94,6-94
+32-32,32-80
+23-52,24-53
+38-88,38-87
+3-54,2-2
+56-74,56-73
+15-15,16-57
+6-62,5-6
+40-40,39-87
+1-77,10-77
+60-95,1-60
+99-99,71-83
+18-35,45-69
+55-83,48-86
+33-33,18-32
+15-61,92-97
+15-69,42-70
+37-74,38-75
+62-98,62-97
+4-70,15-57
+56-56,55-55
+8-94,93-95
+62-64,63-75
+59-67,68-68
+1-91,3-92
+55-69,54-54
+6-81,80-88
+59-61,15-60
+42-96,8-79
+81-84,34-71
+57-59,60-60
+12-95,12-81
+67-67,61-66
+9-31,30-47
+4-52,42-98
+72-87,1-73
+74-99,73-99
+8-30,10-95
+3-97,3-98
+12-16,17-92
+87-94,13-86
+15-50,51-51
+6-46,45-45
+71-71,70-70
+31-93,30-30
+20-21,20-74
+4-75,2-89
+31-74,31-31
+6-26,22-23
+46-87,47-88
+58-77,59-76
+75-75,71-76
+95-97,10-96
+6-11,6-27
+86-87,37-88
+13-17,14-16
+56-76,10-77
+9-88,5-7
+93-95,2-94
+29-61,29-61
+42-82,41-83
+2-14,3-98
+46-91,46-91
+57-74,57-74
+10-57,73-83
+13-31,5-94
+48-85,33-49
+48-89,88-89
+4-98,2-5
+7-85,6-84
+48-75,82-89
+54-77,53-77
+25-90,24-43
+92-94,15-91
+46-81,78-78
+8-89,88-90
+20-78,13-21
+22-28,21-26
+5-87,88-88
+5-94,95-95
+37-43,42-88
+52-52,53-55
+30-76,29-30
+53-88,40-61
+6-82,81-83
+94-96,17-94
+2-92,69-92
+15-80,80-81
+19-90,39-89
+87-99,87-99
+32-86,33-87
+58-87,57-82
+6-74,5-73
+3-17,17-82
+51-69,50-62
+64-68,19-69
+40-92,91-92
+3-93,2-75
+11-94,10-94
+78-98,97-99
+18-70,71-98
+58-87,67-93
+29-57,22-58
+18-35,19-88
+86-95,14-86
+6-37,27-36
+53-65,36-52
+10-95,25-94
+22-60,95-96
+52-79,53-80
+9-38,8-9
+39-54,27-44
+25-98,88-99
+10-90,9-10
+14-48,13-47
+11-38,12-51
+38-55,25-38
+45-55,46-54
+16-89,22-90
+10-56,55-65
+64-88,86-87
+4-28,27-82
+21-75,21-41
+9-11,10-94
+17-86,2-16
+6-51,46-50
+92-93,92-93
+16-47,28-49
+54-58,34-57
+36-50,91-95
+40-44,38-43
+57-96,56-95
+20-30,29-30
+26-92,16-31
+3-79,2-78
+27-74,68-73
+38-43,39-75
+4-64,5-65
+14-62,10-94
+6-21,5-26
+12-12,12-61
+86-86,66-87
+21-47,36-54
+45-81,43-46
+9-63,64-78
+53-55,1-54
+38-52,47-71
+26-29,25-28
+5-92,71-82
+22-81,22-80
+59-93,58-93
+2-11,10-96
+19-24,29-45
+10-98,9-9
+19-45,13-19
+16-83,17-84
+14-46,32-41
+31-90,45-89
+3-98,2-98
+67-91,56-68
+21-90,10-90
+21-41,21-33
+1-3,2-99
+31-78,78-89
+4-23,22-23
+7-92,4-91
+9-75,9-76
+30-35,34-95
+17-90,17-89
+11-54,10-11
+13-87,12-39
+12-59,15-60
+14-89,89-90
+3-98,64-95
+23-99,14-90
+3-3,3-94
+32-77,73-78
+12-14,13-95
+34-66,61-64
+43-49,62-79
+87-87,21-86
+11-30,36-72
+62-62,23-63
+63-86,36-62
+31-35,26-30
+32-98,13-33
+29-59,28-30
+14-92,9-15
+50-65,49-64
+7-49,7-49
+17-17,16-18
+7-13,8-14
+94-98,56-91
+34-72,33-34
+14-87,61-88
+65-65,44-78
+30-31,32-32
+11-51,10-11
+35-82,34-35
+87-90,4-88
+49-53,15-49
+1-3,2-94
+67-87,18-68
+16-71,6-17
+66-85,79-86
+77-86,59-78
+12-38,13-60
+17-37,16-38
+25-80,26-81
+50-95,96-98
+64-66,6-65
+60-69,48-68
+1-63,2-64
+20-94,95-95
+31-59,66-94
+45-93,12-87
+11-33,16-58
+48-97,47-96
+27-86,28-87
+21-25,21-57
+44-46,45-47
+23-44,22-44
+44-82,10-45
+9-91,9-92
+48-80,47-74
+47-49,29-48
+18-36,9-27
+16-93,92-95
+39-80,24-88
+16-99,62-97
+6-66,4-7
+91-98,31-90
+47-86,46-87
+16-88,15-84
+59-80,21-79
+92-98,6-88
+4-43,18-44
+10-58,1-1
+19-94,3-97
+2-73,4-74
+15-23,75-76
+92-99,21-93
+13-14,14-89
+27-95,63-95
+69-92,70-94
+7-73,6-35
+15-87,44-88
+28-81,82-95
+61-94,60-61
+41-45,42-70
+17-76,16-75
+20-91,19-38
+1-62,4-49
+59-59,4-58
+25-27,26-92
+34-78,33-63
+29-71,51-72
+49-74,48-49
+33-94,34-95
+7-15,16-60
+27-75,28-75
+5-6,6-73
+4-4,5-90
+21-23,6-22
+30-93,30-93
+28-74,12-18
+24-77,78-78
+58-69,68-70
+2-89,1-89
+71-75,76-76
+13-35,34-34
+16-94,17-95
+31-41,77-86
+27-76,26-35
+9-44,12-45
+44-46,9-45
+8-88,7-7
+74-75,60-75
+33-56,48-72
+11-82,10-10
+2-95,94-96
+37-52,54-58
+12-32,12-32
+2-68,2-69
+2-12,11-32
+3-7,8-90
+24-24,25-47
+46-47,47-55
+25-78,25-25
+41-47,40-41
+92-93,12-92
+87-88,88-90
+8-52,13-59
+25-86,25-86
+40-52,40-52
+98-99,72-86
+6-90,12-91
+4-7,6-65
+41-89,88-96
+29-83,84-90
+3-82,1-90
+19-35,25-34
+27-99,27-99
+30-72,31-73
+28-30,8-29
+5-95,5-94
+16-94,20-93
+11-61,61-63
+2-4,79-80
+78-80,9-79
+81-83,12-81
+41-46,45-89
+8-68,3-6
+70-72,69-72
+3-87,4-86
+6-99,5-98
+68-85,69-92
+7-11,84-98
+59-69,58-68
+18-73,17-17
+10-90,91-98
+88-93,89-94
+17-17,18-32
+1-63,2-63
+78-78,44-77
+47-90,89-91
+32-74,33-75
+37-38,37-87
+5-80,4-79
+94-95,19-95
+53-63,52-63
+52-70,28-51
+42-95,43-89
+89-93,29-92
+81-98,70-89
+27-85,28-93
+36-72,20-37
+83-87,82-82
+36-77,36-78
+28-54,27-28
+61-76,77-77
+67-71,66-71
+53-77,70-78
+73-77,64-78
+24-81,11-25
+1-2,11-87
+66-74,66-75
+6-7,7-93
+7-37,38-78
+35-89,34-86
+45-72,34-72
+27-95,26-71
+27-78,26-27
+8-96,4-97
+15-70,7-11
+24-92,15-25
+16-45,44-50
+27-79,14-78
+30-33,32-95
+21-55,44-56
+58-97,2-96
+91-97,92-97
+9-13,77-82
+19-90,18-89
+15-90,16-93
+15-18,29-69
+30-41,40-42
+67-80,76-82
+39-65,2-97
+17-95,18-95
+27-88,6-89
+48-74,47-73
+62-93,63-94
+4-61,4-60
+32-91,33-91
+8-91,51-92
+1-99,1-99
+3-64,2-65
+12-58,4-57
+6-36,37-37
+43-59,17-58
+94-99,93-93
+37-61,36-60
+4-8,5-16
+23-25,34-88
+26-49,25-48
+21-21,21-62
+9-83,10-84
+7-90,6-7
+71-97,71-98
+88-99,85-97
+94-98,15-86
+38-61,39-71
+2-87,4-80
+28-87,18-18
+1-88,7-85
+17-87,16-88
+78-88,53-78
+19-45,46-66
+30-87,23-29
+6-73,7-74
+8-69,68-70
+42-70,41-49
+11-60,12-61
+28-86,85-92
+18-79,14-78
+4-91,2-90
+82-93,82-96
+50-86,33-49
+96-98,29-95
+31-35,27-34
+90-93,43-91
+35-35,26-34
+7-67,34-68
+24-72,23-73
+12-96,12-97
+61-68,51-83
+93-95,24-94
+73-92,11-84
+38-81,16-82
+20-76,19-75
+1-4,3-96
+82-85,82-86
+41-57,46-56
+22-22,19-24
+2-97,98-98
+96-96,28-95
+4-58,3-39
+35-86,28-85
+5-80,64-81
+81-92,82-93
+4-79,3-4
+5-26,27-53
+19-75,3-4
+80-81,54-81
+6-9,8-90
+1-97,13-98
+57-57,41-56
+3-88,44-89
+16-53,15-52
+24-84,25-83
+17-76,16-54
+22-72,23-96
+78-79,66-79
+21-35,2-22
+1-89,10-90
+97-98,98-98
+27-98,28-99
+1-79,2-97
+88-88,5-82
+51-86,49-51
+20-87,21-86
+99-99,52-79
+56-58,1-57
+71-74,70-70
+22-51,51-77
+55-92,54-91
+63-99,6-93
+42-88,41-87
+44-53,44-52
+19-59,23-67
+10-76,5-41
+49-64,63-65
+32-64,17-63
+1-2,3-99
+29-75,28-29
+98-98,31-97
+63-84,64-85
+40-85,39-84
+30-46,45-69
+1-25,3-99
+48-98,49-99
+5-40,23-41
+78-79,50-79
+9-10,10-10
+37-65,37-65
+16-22,17-35
+47-82,46-47
+14-67,13-14
+32-93,11-56
+65-93,66-94
+20-80,21-80
+92-94,3-89
+67-68,16-68
+12-97,97-99
+2-16,19-95
+8-32,31-35
+98-98,76-95
+8-57,8-58
+10-25,11-25
+23-33,34-66
+12-69,12-23
+10-68,9-69
+42-50,31-51
+27-81,28-80
+7-99,8-99
+5-88,5-87
+39-84,7-85
+2-61,74-88
+4-56,4-55
+47-60,48-79
+19-47,46-93
+35-93,34-92
+64-96,64-96
+28-28,28-34
+54-91,92-92
+15-27,27-27
+17-79,27-50
+1-3,2-88
+14-97,96-96
+19-66,42-67
+87-94,37-49
+15-82,87-98
+8-26,8-49
+43-43,50-99
+55-98,25-97
+5-82,6-83
+29-53,47-48
+10-92,9-10
+33-43,13-71
+9-79,10-79
+30-63,31-75
+2-54,1-2
+37-95,21-96
+68-79,16-69
+2-47,46-47
+45-65,5-44
+21-99,28-96
+4-31,4-52
+16-94,8-96
+13-86,85-88
+58-76,53-56
+7-95,30-96
+96-96,28-78
+24-55,23-54
+30-84,30-83
+21-82,7-81
+9-35,36-90
+3-17,1-2
+1-1,2-37
+4-99,4-99
+38-65,37-45
+94-95,31-78
+58-95,94-97
+30-95,29-95
+70-81,76-98
+15-76,21-65
+6-59,5-59
+8-28,7-21
+43-61,62-63
+10-30,10-30
+10-85,10-85
+21-40,22-40
+24-60,29-61
+51-86,13-52
+6-96,5-96
+6-18,17-55
+24-24,24-24
+81-95,96-99
diff --git a/2022/04-camp-cleanup/second.zig b/2022/04-camp-cleanup/second.zig
new file mode 100644
index 0000000..283169e
--- /dev/null
+++ b/2022/04-camp-cleanup/second.zig
@@ -0,0 +1,26 @@
+const std = @import("std");
+
+const example = @embedFile("example");
+const input = @embedFile("input");
+
+pub fn main() anyerror!void {
+ try std.testing.expectEqual(solve(example), 4);
+ const result = try solve(input);
+ try std.io.getStdOut().writer().print("{}\n", .{result});
+}
+
+fn solve(puzzle: []const u8) !u64 {
+ var it = std.mem.tokenize(u8, puzzle, "\n");
+ var tot: u64 = 0;
+ while (it.next()) |line| {
+ var it2 = std.mem.tokenize(u8, line, "-,");
+ const a = try std.fmt.parseInt(u64, it2.next() orelse unreachable, 10);
+ const b = try std.fmt.parseInt(u64, it2.next() orelse unreachable, 10);
+ const c = try std.fmt.parseInt(u64, it2.next() orelse unreachable, 10);
+ const d = try std.fmt.parseInt(u64, it2.next() orelse unreachable, 10);
+ if (a <= c and b >= d or a >= c and b <= d or a <= c and b >= c or a <= d and b >= d) {
+ tot += 1;
+ }
+ }
+ return tot;
+}