-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaoc-2022-day04-c02.rs
72 lines (58 loc) · 14.3 KB
/
aoc-2022-day04-c02.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// https://adventofcode.com/2022/day/4
// (part 2)
const ELF_SEPARATOR: char = ',';
const SECTIONS_SEPARATOR: char = '-';
fn sections_get(elf_sections: &str) -> [u32; 2] {
let sect_sep: Option<usize> = elf_sections.find(SECTIONS_SEPARATOR);
assert!(sect_sep.is_some());
let first = elf_sections.get(0..sect_sep.unwrap());
let last = elf_sections.get(sect_sep.unwrap() + 1..elf_sections.len());
return [
first.unwrap().parse::<u32>().unwrap(),
last.unwrap().parse::<u32>().unwrap(),
];
}
fn sections_overlap_is(elf1: [u32; 2], elf2: [u32; 2]) -> bool {
return !(elf1[1] < elf2[0] || elf2[1] < elf1[0]);
}
fn overlap_is(pair: &str) -> bool {
let elf_sep: Option<usize> = pair.find(ELF_SEPARATOR);
assert!(elf_sep.is_some());
let elf1_sections: [u32; 2] = sections_get(pair.get(0..elf_sep.unwrap()).unwrap());
let elf2_sections: [u32; 2] = sections_get(pair.get(elf_sep.unwrap() + 1..pair.len()).unwrap());
let fully_contained: bool = sections_overlap_is(elf1_sections, elf2_sections);
return fully_contained;
}
fn overlaps_compute(list: &str) -> u32 {
let mut count: u32 = 0;
let lines: Vec<&str> = list.split('\n').collect();
for line in lines {
if overlap_is(line) {
count += 1;
}
}
return count;
}
fn main() {
// example
assert_eq!(
4,
overlaps_compute("2-4,6-8\n2-3,4-5\n5-7,7-9\n2-8,3-7\n6-6,4-6\n2-6,4-8")
);
assert_eq!(
936,
overlaps_compute(
"8-41,8-79\n1-71,2-71\n11-74,74-75\n44-96,43-96\n79-79,3-78\n67-86,50-93\n15-42,41-93\n21-98,20-99\n42-53,13-41\n51-80,38-79\n13-13,13-93\n14-20,20-66\n34-64,33-34\n93-94,56-93\n28-59,58-90\n9-58,4-8\n39-79,32-87\n60-62,48-61\n1-76,21-75\n1-11,2-12\n7-85,4-7\n5-69,26-69\n10-95,11-96\n73-99,65-97\n6-67,1-35\n26-48,29-44\n3-85,1-3\n51-53,14-52\n38-64,37-70\n19-30,30-55\n73-77,72-73\n28-65,28-66\n30-60,47-87\n32-32,30-34\n82-96,3-97\n12-63,13-63\n42-91,19-91\n38-45,45-80\n4-98,14-76\n22-91,23-90\n9-84,10-41\n79-98,48-92\n41-45,41-46\n15-94,30-89\n13-84,25-83\n60-68,37-69\n35-86,7-87\n32-78,31-78\n4-98,4-99\n20-20,20-93\n5-88,87-88\n9-42,4-12\n44-97,54-86\n32-82,6-26\n39-41,40-42\n10-76,10-75\n5-99,2-99\n48-48,47-99\n1-1,1-91\n60-75,59-61\n31-32,32-33\n21-88,22-88\n11-42,11-11\n57-75,74-95\n94-94,94-94\n60-84,58-86\n18-87,11-18\n14-34,29-33\n64-90,22-69\n33-95,71-96\n10-93,9-93\n18-18,18-68\n3-94,93-93\n38-38,38-78\n79-81,67-86\n24-73,3-73\n93-94,46-94\n10-97,11-35\n5-93,4-98\n3-99,47-97\n31-60,59-86\n1-67,45-68\n22-84,59-83\n24-72,23-73\n15-78,16-77\n90-90,85-92\n43-91,44-92\n2-88,86-89\n4-38,4-37\n43-87,44-87\n4-91,5-91\n23-37,27-46\n1-4,3-99\n77-77,78-81\n33-35,33-37\n80-87,81-81\n5-52,6-99\n66-66,52-66\n6-96,16-92\n16-89,4-98\n60-60,60-97\n5-62,1-6\n38-91,38-38\n4-14,13-57\n7-53,7-54\n1-97,13-97\n2-90,3-46\n19-19,20-96\n3-33,33-33\n28-42,29-42\n25-76,47-76\n16-24,25-44\n55-71,55-71\n29-76,28-89\n17-90,17-89\n1-98,10-99\n6-43,22-42\n7-95,67-95\n4-97,97-98\n62-94,62-95\n4-86,5-87\n6-83,6-89\n18-26,26-69\n95-98,10-95\n7-86,1-7\n91-92,27-91\n3-75,8-87\n38-53,30-52\n11-85,9-12\n39-83,39-83\n62-94,10-63\n12-35,35-97\n15-17,16-87\n2-93,1-92\n33-86,34-87\n4-19,19-92\n5-70,69-90\n10-97,5-97\n82-83,41-82\n16-29,16-29\n1-82,5-81\n62-71,61-72\n6-99,8-99\n10-44,6-10\n14-45,13-92\n36-37,37-91\n11-41,22-68\n51-78,79-95\n19-36,28-36\n4-91,9-92\n3-98,3-3\n1-44,2-43\n4-22,4-22\n24-89,42-89\n72-98,57-73\n28-92,4-29\n60-91,25-61\n2-89,5-88\n71-73,3-71\n17-99,24-98\n88-96,3-88\n39-74,75-75\n52-92,4-93\n18-56,53-97\n27-75,16-71\n81-94,1-82\n65-67,15-66\n77-79,77-79\n16-33,17-34\n83-87,29-84\n84-84,20-85\n26-28,27-82\n6-66,66-66\n8-72,9-59\n9-99,10-97\n48-48,47-47\n7-58,6-57\n46-58,23-70\n2-2,2-93\n20-33,20-20\n7-20,8-15\n17-67,16-17\n2-21,1-99\n5-5,4-72\n79-95,9-96\n7-38,7-38\n8-98,6-99\n68-84,10-68\n19-35,2-34\n5-43,3-9\n15-62,14-14\n82-95,48-96\n75-77,34-76\n33-65,65-66\n95-95,19-95\n12-88,13-87\n28-68,25-30\n12-37,8-91\n38-63,16-63\n41-58,53-57\n12-42,29-71\n68-96,68-96\n6-77,78-78\n22-37,23-36\n65-74,64-75\n36-88,35-99\n3-49,13-32\n84-91,1-84\n13-66,13-66\n9-92,10-91\n26-26,26-27\n10-17,15-35\n68-82,59-83\n27-69,26-58\n82-92,10-81\n12-18,12-18\n29-35,29-46\n60-71,71-71\n6-80,79-95\n2-12,1-3\n19-77,20-77\n95-97,88-95\n55-79,21-54\n3-4,9-97\n23-98,23-98\n1-4,3-47\n2-26,1-2\n22-72,9-22\n3-84,13-83\n43-45,18-44\n49-53,51-51\n15-85,16-85\n7-21,4-21\n1-24,1-25\n16-86,16-16\n79-87,80-86\n1-95,57-97\n4-99,29-99\n97-98,6-98\n46-78,53-83\n28-82,51-93\n59-95,32-96\n11-32,23-33\n13-29,24-47\n7-74,11-73\n28-36,36-89\n17-83,18-82\n2-85,10-66\n4-79,4-78\n36-62,61-79\n50-52,28-51\n22-48,3-28\n51-92,68-91\n29-91,28-92\n9-52,8-53\n7-97,55-96\n16-59,15-92\n98-98,3-97\n67-72,15-72\n15-52,5-77\n1-78,3-79\n6-66,3-3\n48-64,63-63\n6-97,6-97\n27-27,19-27\n2-72,1-71\n47-59,48-79\n12-61,13-65\n50-57,38-62\n30-73,65-70\n79-94,79-93\n81-97,98-98\n26-78,17-26\n46-57,29-89\n86-95,29-95\n57-64,43-64\n14-93,71-97\n4-99,66-98\n77-87,17-78\n25-26,26-96\n34-73,33-73\n36-57,35-62\n41-73,55-91\n41-48,12-47\n21-83,20-82\n15-35,14-73\n19-93,93-99\n50-69,51-95\n59-66,66-66\n5-93,92-92\n37-37,37-94\n38-39,38-54\n8-49,27-57\n43-83,79-82\n64-66,13-70\n40-92,92-97\n13-67,51-73\n29-88,30-71\n16-96,17-97\n25-37,27-77\n20-57,3-36\n91-96,63-99\n21-84,44-83\n4-87,2-4\n9-31,31-79\n33-82,33-33\n4-65,3-64\n18-71,19-22\n18-63,10-18\n87-92,88-93\n62-63,61-72\n20-49,49-68\n77-83,64-84\n10-79,8-11\n33-59,34-49\n5-85,11-85\n95-96,7-96\n59-60,35-59\n19-90,7-13\n16-84,16-47\n61-89,88-90\n24-52,51-51\n51-51,50-93\n39-77,18-96\n49-90,90-92\n37-76,75-76\n12-20,21-83\n2-94,3-95\n83-83,83-88\n3-99,2-97\n48-72,72-78\n14-99,13-99\n10-11,1-10\n4-99,5-92\n4-81,71-81\n5-5,5-93\n17-53,5-53\n38-91,37-37\n27-71,26-70\n1-98,73-82\n13-96,7-14\n14-82,14-14\n5-36,4-46\n9-75,9-93\n83-83,44-82\n34-95,23-35\n58-87,58-88\n70-98,69-69\n1-15,2-14\n22-22,22-24\n8-93,8-92\n50-60,2-55\n39-78,40-78\n55-92,31-92\n3-88,1-50\n23-65,23-66\n63-64,17-64\n15-31,11-91\n19-97,18-96\n12-89,12-88\n6-26,7-10\n45-70,45-69\n53-79,77-79\n31-63,30-30\n66-68,7-67\n22-85,43-85\n9-9,9-82\n1-30,4-80\n36-58,36-37\n15-84,14-83\n41-42,40-71\n38-73,37-98\n1-61,2-91\n71-73,71-73\n31-80,31-80\n12-99,13-99\n1-83,1-83\n9-92,9-93\n3-35,4-34\n15-64,19-63\n36-36,36-84\n15-43,14-57\n96-98,4-97\n36-46,45-79\n27-71,27-27\n6-6,6-53\n2-55,10-19\n8-48,2-53\n17-99,16-97\n13-64,12-65\n75-86,76-85\n63-64,3-63\n5-87,3-5\n56-91,41-91\n7-23,7-22\n3-88,3-86\n3-5,5-53\n1-94,2-95\n83-85,81-84\n98-98,82-99\n31-68,4-68\n5-95,12-96\n22-35,35-91\n1-93,3-93\n33-86,28-39\n24-95,95-95\n89-91,10-90\n5-77,4-76\n2-49,21-49\n67-91,54-91\n51-76,51-51\n70-74,59-74\n22-32,31-31\n22-53,21-84\n39-63,25-27\n5-95,2-5\n56-66,67-89\n60-60,58-61\n9-36,1-36\n16-35,15-34\n34-69,69-70\n52-84,54-97\n10-84,36-83\n96-97,24-95\n4-99,2-5\n34-90,33-35\n87-97,97-99\n29-38,30-39\n67-97,66-67\n64-83,76-94\n4-94,2-5\n67-87,14-96\n3-94,7-86\n69-80,74-79\n67-82,66-66\n3-85,29-85\n95-97,94-96\n81-85,3-81\n13-78,19-77\n5-35,16-35\n14-42,14-91\n21-81,3-88\n1-7,7-89\n18-70,17-18\n47-96,96-97\n69-93,73-92\n48-48,11-48\n36-95,35-35\n67-67,11-66\n3-86,5-85\n48-89,2-7\n9-58,10-57\n69-70,69-95\n36-97,96-98\n9-43,9-92\n10-69,12-69\n17-76,76-77\n2-99,98-98\n30-31,29-33\n38-64,41-64\n1-91,1-92\n7-16,2-16\n1-99,1-1\n11-96,12-95\n14-93,13-93\n10-87,2-10\n10-66,10-96\n17-87,16-16\n14-58,57-59\n19-95,20-94\n43-59,22-44\n84-97,84-98\n14-77,34-77\n45-69,44-46\n52-87,51-68\n3-7,6-56\n14-51,46-50\n44-66,49-67\n9-12,1-11\n86-90,86-90\n32-41,29-42\n53-80,11-73\n93-93,13-94\n39-84,40-73\n16-71,71-72\n9-94,9-94\n44-91,3-98\n18-78,18-98\n19-48,18-47\n23-77,68-77\n20-68,63-67\n48-90,48-97\n40-49,39-71\n4-15,15-99\n76-77,60-76\n12-56,17-57\n27-92,28-93\n13-74,12-14\n4-97,5-66\n50-50,50-51\n66-66,44-66\n58-68,23-52\n47-76,48-76\n8-96,48-98\n43-92,7-92\n33-54,15-97\n72-99,71-98\n13-76,31-36\n2-14,11-13\n8-70,7-9\n8-54,8-55\n93-96,94-96\n31-74,73-73\n65-74,53-74\n46-93,45-94\n31-99,8-99\n6-37,10-37\n21-82,22-83\n55-73,17-20\n65-79,66-72\n15-43,14-44\n1-96,6-97\n3-98,5-99\n24-80,18-71\n56-92,57-80\n12-54,40-83\n31-80,16-81\n35-48,22-85\n2-90,1-89\n2-2,2-59\n87-96,51-87\n36-99,37-99\n8-90,37-70\n14-14,14-76\n39-99,20-71\n52-65,52-65\n31-48,31-48\n57-57,57-88\n68-92,68-81\n5-98,6-98\n87-96,25-88\n6-86,87-87\n69-88,33-84\n39-86,40-40\n77-82,77-87\n11-88,97-97\n29-87,87-89\n40-55,39-40\n96-97,47-95\n5-85,85-85\n11-93,93-94\n29-96,89-95\n6-69,26-92\n20-76,15-20\n39-40,38-39\n7-33,6-34\n34-78,35-37\n18-67,9-67\n7-99,6-99\n64-88,47-64\n17-96,18-93\n6-84,4-85\n21-21,21-96\n6-42,5-98\n35-97,38-85\n31-94,9-57\n59-73,62-73\n5-97,5-97\n16-53,16-32\n8-42,7-43\n10-94,11-60\n42-50,17-80\n54-57,57-77\n37-89,88-96\n24-79,20-79\n7-91,24-96\n24-89,88-94\n28-82,10-81\n3-3,3-94\n89-93,92-92\n34-99,34-34\n22-22,23-63\n10-92,3-10\n77-77,77-84\n32-59,28-42\n54-86,55-71\n42-50,11-46\n88-88,6-90\n70-74,72-72\n1-1,1-50\n46-50,9-47\n95-95,3-96\n93-95,12-94\n22-85,14-15\n23-73,22-92\n4-86,4-86\n75-90,75-75\n56-56,55-55\n31-91,32-80\n64-78,3-79\n16-85,15-53\n61-64,62-65\n86-86,23-87\n27-96,68-80\n18-98,18-51\n6-92,49-98\n23-23,23-28\n13-74,5-14\n15-93,16-91\n2-97,12-97\n23-92,17-24\n56-76,75-75\n38-82,39-83\n15-97,97-98\n44-86,45-69\n79-85,35-86\n19-98,20-92\n59-59,7-59\n27-91,28-88\n11-71,66-70\n3-79,5-78\n22-77,21-76\n92-94,12-93\n6-85,6-6\n14-81,14-81\n5-6,8-44\n34-37,36-36\n1-53,29-87\n40-72,67-72\n4-81,1-97\n27-76,10-58\n32-75,2-40\n15-86,86-86\n42-90,2-90\n21-73,20-73\n84-99,3-97\n21-81,2-22\n75-99,53-76\n5-96,5-99\n68-70,21-69\n24-24,23-47\n7-8,7-73\n6-6,6-66\n31-37,30-36\n4-91,5-90\n16-76,18-47\n44-97,25-97\n48-92,47-95\n45-62,45-62\n62-93,48-93\n53-91,77-98\n54-70,12-69\n6-20,17-39\n46-46,12-47\n4-4,5-61\n9-42,43-88\n97-99,1-97\n11-90,89-89\n9-15,4-14\n15-81,4-80\n31-43,44-68\n4-9,1-10\n47-48,32-47\n22-47,46-55\n10-12,11-86\n3-4,4-41\n64-84,18-85\n15-39,14-47\n15-51,11-12\n10-57,9-56\n16-29,15-30\n38-57,10-39\n20-87,20-82\n1-43,3-43\n9-90,7-89\n23-88,25-89\n50-92,51-91\n13-94,94-96\n2-92,47-91\n22-95,1-23\n22-73,21-22\n3-5,4-33\n13-75,12-76\n18-26,17-39\n6-72,10-71\n17-76,3-41\n24-96,17-96\n50-57,51-55\n97-99,80-98\n5-66,5-78\n8-57,14-56\n20-21,20-97\n22-79,21-79\n2-99,99-99\n95-95,38-96\n34-95,35-94\n14-27,6-13\n19-87,18-88\n64-66,60-66\n38-85,37-38\n88-97,4-87\n1-99,2-92\n8-12,12-92\n25-60,26-59\n38-74,19-38\n45-76,15-46\n60-91,60-91\n81-81,12-82\n19-20,20-61\n22-97,19-98\n13-57,28-65\n15-90,12-15\n40-40,23-40\n27-92,17-92\n7-99,8-77\n6-83,16-83\n53-70,37-69\n66-93,42-71\n73-92,89-92\n5-87,6-39\n9-99,99-99\n27-80,81-81\n7-58,58-58\n9-85,50-86\n39-94,14-88\n13-40,2-39\n2-89,1-28\n43-89,72-88\n23-41,24-24\n23-34,34-83\n19-64,19-20\n60-97,61-89\n4-57,56-56\n8-89,40-90\n30-48,17-30\n3-93,2-92\n1-10,10-74\n1-24,5-56\n19-19,18-47\n3-10,5-83\n50-52,48-51\n13-75,13-13\n10-10,16-61\n27-92,27-88\n45-93,46-94\n47-61,16-61\n76-77,76-83\n32-84,84-87\n86-86,87-87\n7-95,8-73\n8-69,20-68\n44-95,44-95\n11-39,12-40\n63-99,70-99\n36-45,35-49\n6-55,55-75\n91-93,91-93\n61-75,49-75\n86-98,87-99\n46-98,10-14\n95-95,74-96\n5-92,91-99\n2-92,2-2\n1-57,11-56\n97-97,14-98\n8-74,74-83\n19-67,61-66\n94-94,24-95\n5-9,69-90\n30-66,30-65\n2-99,1-98\n38-94,63-73\n1-2,1-99\n43-93,20-90\n42-89,40-42\n22-88,52-87\n78-79,23-77\n22-89,21-89\n12-94,11-80\n2-7,6-84\n20-99,20-20\n8-93,38-99\n16-60,17-61\n41-41,41-83\n17-47,4-57\n18-56,18-56\n1-57,1-57\n77-87,1-77\n62-91,63-92\n6-90,10-91\n2-4,3-97\n53-67,54-62\n29-30,5-30\n51-51,7-50\n2-87,1-88\n13-73,55-87\n8-29,7-29\n64-97,15-98\n23-84,22-23\n7-10,3-11\n19-35,35-78\n49-96,50-97\n16-94,17-94\n24-71,9-82\n29-88,9-29\n24-52,43-51\n69-73,8-82\n1-3,2-91\n6-85,7-7\n4-86,16-79\n4-4,6-50\n17-83,82-88\n27-81,28-67\n82-85,56-84\n39-40,40-86\n2-48,8-49\n8-79,7-8\n62-86,61-85\n65-67,47-66\n48-97,49-97\n41-86,66-85\n18-41,17-40\n40-85,67-76\n77-95,58-91\n39-66,31-40\n4-7,7-98\n33-96,44-96\n3-11,3-3\n69-70,8-70\n97-97,3-97\n32-94,81-93\n21-70,20-69\n47-56,28-55\n1-1,1-33\n36-71,35-86\n18-88,19-88\n4-99,8-96\n13-79,14-62\n11-71,11-79\n69-92,68-92\n18-88,88-94\n26-92,26-92\n15-69,16-68\n59-95,95-98\n40-53,39-54\n53-64,32-53\n17-97,16-84\n28-99,7-88\n49-81,49-69\n22-98,97-98\n66-94,5-97\n3-70,1-76\n5-93,2-25\n46-66,65-65\n69-70,11-99\n55-93,56-77\n11-92,12-93\n34-96,95-96\n1-3,3-15\n49-88,19-88\n80-84,63-85\n7-83,56-99\n14-62,55-67\n22-84,23-66\n35-89,31-35\n33-81,7-81\n78-85,77-86\n38-44,46-80\n72-83,12-73\n62-92,65-92\n60-89,26-60\n48-59,41-57\n55-83,56-84\n27-89,48-50\n5-66,5-84\n30-84,21-84\n23-62,22-62\n55-93,37-94\n6-47,15-46\n28-28,29-39\n2-3,13-13\n46-81,18-81\n37-88,38-89\n7-53,17-52\n32-67,18-81\n22-22,22-24\n2-71,15-45\n1-92,1-92\n14-89,10-91\n9-79,12-78\n4-15,3-92\n49-68,29-69\n1-2,3-51\n27-45,28-44\n22-99,21-99\n66-70,64-69\n97-98,67-98\n47-98,47-57\n47-98,48-79\n7-31,9-34\n8-84,8-8\n20-92,6-20\n14-90,5-22\n23-68,29-87\n3-42,41-71\n80-80,81-96\n59-80,79-95\n17-86,35-86\n32-92,91-91\n72-77,53-78\n20-23,23-95\n94-97,8-94\n25-34,26-33\n12-96,13-98\n73-95,73-73\n43-50,44-50\n5-99,1-5\n63-94,63-94\n40-52,41-42\n25-25,25-78\n6-10,9-97\n23-26,26-77\n48-79,48-48\n26-96,88-90\n6-11,9-27\n34-42,43-92\n15-83,16-87\n9-93,82-93\n45-77,76-85\n74-98,18-99\n7-95,8-94\n46-98,97-99\n18-42,42-60\n15-17,16-35\n44-88,64-87\n60-61,56-62\n46-48,49-58\n90-97,6-90\n19-20,15-20\n1-1,1-61\n34-75,33-76\n1-90,5-90\n51-61,5-52\n40-91,90-95\n17-77,1-77\n77-77,17-77\n32-81,33-76\n12-41,13-41\n61-91,59-92\n44-67,44-81\n31-63,31-71\n8-97,6-79\n7-98,6-99\n4-38,3-4\n2-95,94-99\n3-28,1-3\n50-56,3-98\n24-76,24-24\n5-10,4-78\n30-75,30-76\n41-47,40-66\n4-37,3-4\n72-98,71-99\n7-19,8-19\n64-64,19-64\n7-58,7-58\n35-45,36-45\n1-99,99-99\n6-68,2-69\n52-75,53-72\n11-91,38-91\n6-17,6-17\n16-57,17-57\n6-16,7-15\n18-86,17-85\n13-35,7-74\n35-40,34-40\n20-85,37-84\n89-89,21-89\n2-24,21-25\n25-73,3-47\n7-7,7-93\n15-20,14-95\n10-83,11-82\n10-95,9-96\n17-86,47-87\n14-80,78-80\n47-50,53-92\n74-76,63-75\n8-44,3-9\n80-91,16-92\n11-11,12-89\n35-97,34-98\n28-98,98-99\n20-58,58-80\n21-71,8-40\n14-77,14-14\n28-73,27-73\n58-83,59-83\n12-96,44-59"));
//// user puzzle input
}
/*
--- Part Two ---
It seems like there is still quite a bit of duplicate work planned. Instead, the Elves would like to know the number of pairs that overlap at all.
In the above example, the first two pairs (2-4,6-8 and 2-3,4-5) don't overlap, while the remaining four pairs (5-7,7-9, 2-8,3-7, 6-6,4-6, and 2-6,4-8) do overlap:
5-7,7-9 overlaps in a single section, 7.
2-8,3-7 overlaps all of the sections 3 through 7.
6-6,4-6 overlaps in a single section, 6.
2-6,4-8 overlaps in sections 4, 5, and 6.
So, in this example, the number of overlapping assignment pairs is 4.
In how many assignment pairs do the ranges overlap?
*/