22 lines
13 KiB
JavaScript
22 lines
13 KiB
JavaScript
|
let input = "28-47,45-47\n32-97,98-98\n59-92,91-93\n8-74,9-74\n58-98,23-57\n92-94,5-91\n88-89,19-87\n14-83,13-82\n44-61,45-62\n32-41,33-41\n44-90,12-41\n63-95,64-96\n11-67,11-67\n45-67,55-63\n3-48,5-49\n9-48,8-50\n97-97,11-96\n21-21,22-75\n61-61,57-60\n3-97,1-97\n7-84,7-83\n15-20,36-41\n19-44,20-44\n20-25,41-56\n6-49,1-49\n61-63,62-63\n8-22,21-49\n28-28,29-53\n2-61,1-61\n9-50,8-10\n25-76,25-26\n30-49,31-99\n2-99,1-87\n35-99,27-27\n10-84,9-85\n12-25,36-47\n38-76,37-37\n73-75,32-74\n24-38,36-43\n32-93,31-94\n27-27,26-33\n57-81,58-82\n13-33,41-81\n11-20,21-56\n2-52,7-80\n7-99,8-8\n24-63,34-61\n24-86,23-38\n20-83,19-84\n4-17,4-18\n26-65,24-25\n27-80,12-26\n4-90,4-91\n10-90,91-94\n4-45,46-97\n1-94,2-93\n1-12,1-13\n5-98,97-98\n61-61,2-62\n76-97,87-97\n4-6,5-96\n13-55,4-5\n27-51,28-87\n95-97,6-96\n84-97,60-83\n25-69,26-70\n11-30,12-24\n3-83,9-84\n4-68,5-69\n73-77,14-73\n14-97,5-97\n10-63,8-63\n7-71,8-71\n2-98,3-99\n12-88,13-69\n13-86,10-87\n85-85,46-85\n81-87,81-81\n98-98,16-98\n49-95,48-90\n66-96,67-97\n35-67,34-34\n42-69,41-68\n9-39,39-98\n5-51,4-5\n30-99,31-98\n61-85,15-60\n55-72,54-71\n47-87,48-83\n11-69,12-69\n50-56,49-50\n29-88,28-89\n74-93,7-75\n15-65,4-65\n1-99,2-99\n8-8,9-60\n99-99,2-99\n14-77,15-66\n1-95,95-98\n34-63,33-64\n42-82,49-83\n1-4,4-43\n77-91,16-28\n81-81,43-82\n44-72,45-45\n22-37,49-81\n14-92,13-84\n8-17,17-37\n21-86,85-86\n8-11,12-96\n34-34,35-77\n25-57,26-56\n32-32,32-97\n13-84,12-85\n43-99,42-88\n7-31,6-32\n25-67,95-96\n21-26,20-76\n91-91,42-91\n53-64,33-52\n9-86,9-87\n38-87,37-88\n9-91,9-90\n3-85,84-96\n19-91,92-93\n47-96,46-95\n19-66,20-67\n8-40,41-78\n20-95,95-98\n5-47,4-10\n18-18,17-97\n55-97,55-96\n14-26,27-28\n5-24,29-63\n82-91,83-92\n21-64,64-94\n38-89,37-88\n74-75,2-75\n81-96,26-82\n42-48,41-47\n1-91,4-91\n28-92,27-28\n18-78,77-79\n51-75,50-74\n9-94,8-10\n12-60,13-59\n2-99,34-98\n26-67,26-88\n51-53,19-52\n36-97,37-97\n18-23,41-66\n81-85,6-86\n11-75,10-88\n3-82,9-83\n54-73,53-55\n33-85,34-69\n24-40,23-60\n43-70,42-71\n26-96,26-90\n38-44,39-58\n80-80,42-80\n50-92,51-92\n13-32,14-14\n1-97,3-97\n12-56,57-71\n5-92,4-93\n1-89,2-88\n22-58,57-58\n19-96,28-97\n5-5,4-94\n6-19,6-18\n1-78,1-86\n91-92,30-92\n21-89,22-88\n62-64,53-64\n6-84,7-85\n11-44,11-45\n1-99,2-98\n80-89,46-90\n45-79,25-78\n25-54,27-28\n10-20,9-10\n94-94,60-93\n12-56,11-11\n71-99,98-98\n45-95,46-92\n6-48,5-92\n11-97,10-98\n60-92,59-91\n12-98,12-91\n11-11,11-76\n20-87,20-88\n52-83,31-51\n9-73,9-73\n7-71,1-70\n84-94,85-95\n7-93,8-66\n32-35,32-34\n47-61,46-48\n55-80,54-58\n83-96,99-99\n37-50,36-50\n7-12,6-26\n60-67,13-68\n15-89,15-90\n12-65,64-66\n18-34,17-99\n28-88,27-28\n47-52,53-76\n10-72,5-9\n58-85,2-86\n88-88,74-89\n39-75,88-91\n58-59,57-59\n86-97,77-97\n13-38,37-96\n17-86,18-85\n29-78,61-77\n91-91,34-91\n4-90,91-91\n3-92,4-92\n40-51,24-51\n76-94,34-76\n7-94,95-97\n1-72,73-98\n13-93,14-93\n16-55,16-70\n66-69,37-66\n70-72,4-71\n16-16,15-90\n15-89,14-73\n13-72,10-72\n1-86,2-88\n4-45,5-94\n92-96,1-91\n3-97,2-97\n9-19,8-20\n93-93,56-92\n16-92,93-95\n17-58,16-89\n70-76,69-95\n25-94,25-60\n59-60,14-60\n3-33,3-20\n69-98,20-79\n30-79,31-54\n22-98,99-99\n16-18,17-19\n40-86,10-39\n54-60,36-60\n29-35,30-56\n63-77,64-78\n17-43,83-92\n5-58,18-26\n12-72,12-73\n50-58,49-59\n6-36,24-37\n29-97,29-98\n11-86,11-85\n42-92,42-86\n1-96,95-95\n59-76,60-75\n1-98,97-98\n95-98,18-94\n5-83,82-84\n12-66,66-66\n15-23,14-31\n16-24,25-91\n76-82,15-75\n19-32,27-33\n2-82,1-70\n5-5,7-93\n80-92,80-99\n8-54,36-53\n11-28,13-26\n47-73,8-46\n10-86,11-99\n48-87,47-49\n24-89,1-88\n54-55,54-93\n6-84,5-88\n38-81,34-38\n91-98,92-99\n3-73,7-73\n48-84,47-84\n29-92,85-91\n40-40,8-40\n91-97,91-95\n2-23,4-23\n3-98,3-4\n36-98,35-37\n14-93,93-93\n32-65,50-64\n2-62,3-61\n11-71,96-97\n7-92,93-93\n9-96,9-94\n22-85,22-69\n5-50,42-49\n7-7,8-47\n14-91,13-71\n2-93,92-94\n3-97,2-4\n4-92,3-91\n1-68,5-69\n6-39,5-37\n14-15,13-17\n54-64,63-64\n21-54,20-21\n12-98,11-11\n1-6,7-45\n25-77,77-77\n96-97,2-95\n10-90,89-90\n4-30,2-30\n53-92,52-54\n51-51,52-52\n5-13,14-14\n4-95,3-3\n23-94,22-24\n2-53,2-78\n29-84,28-83\n15-46,14-99\n62-74,61-63\n98-99,10-99\n6-94,5-5\n6-84,5-7\n52-53,35-53\n1-82,81-81\n93-93
|
||
|
|
||
|
const pairs = input.split("\n").map(p => p.split(",").map(r => r.split("-").map(x => parseFloat(x))));
|
||
|
|
||
|
console.log("length: ", pairs.length);
|
||
|
|
||
|
let count = 0;
|
||
|
|
||
|
pairs.forEach(pair => {
|
||
|
const [[a, b], [x,y]] = pair;
|
||
|
if((a >= x && b <= y ) || (a <= x && b >= y)) {
|
||
|
|
||
|
console.log("A: ", a, ", B: ", b, ", X: ", x, ", Y:", y);
|
||
|
console.log("True: ", pair);
|
||
|
count++;
|
||
|
} else {
|
||
|
console.log("False: ", pair);
|
||
|
}
|
||
|
});
|
||
|
|
||
|
console.log(count);
|