advent-of-code/2022/4/index2.js
2022-12-03 21:47:52 -08:00

21 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,92-92\n9-30,19-30\n36-82,12-81\n29-53,54-98\n6-20,7-25\n23-70,85-90\n14-14,15-81\n59-68,60-68\n52-53,31-53\n43-61,56-60\n27-66,28-67\n91-98,89-90\n13-86,12-86\n56-71,57-71\n55-68,54-84\n12-13,18-97\n96-96,84-97\n80-96,14-96\n37-62,63-66\n6-69,34-69\n89-89,9-90\n14-91,1-90\n9-18,17-18\n31-50,32-50\n7-50,8-63\n40-93,12-39\n74-98,99-99\n7-16,2-15\n4-4,8-97\n14-94,14-95\n85-94,84-94\n41-46,41-46\n12-89,13-85\n52-78,52-52\n3-90,2-91\n40-69,69-69\n13-97,98-99\n60-94,60-95\n51-95,50-94\n23-70,57-70\n15-86,86-87\n10-87,1-86\n60-61,20-61\n15-15,18-42\n20-93,92-93\n34-60,5-5\n6-86,5-5\n28-88,27-28\n28-81,42-82\n81-82,9-82\n2-90,2-95\n56-56,50-56\n29-50,28-62\n29-76,30-77\n1-88,97-99\n45-87,44-78\n58-95,94-96\n5-94,95-95\n19-31,32-76\n17-57,16-57\n4-70,4-80\n5-24,18-19\n1-99,99-99\n12-15,16-81\n7-95,8-8\n4-67,68-68\n11-89,8-10\n7-42,6-43\n89-94,7-77\n14-25,8-8\n43-57,43-44\n30-80,79-80\n15-80,14-81\n22-79,21-23\n5-70,9-69\n64-65,16-65\n69-71,55-70\n16-81,3-11\n23-56,20-62\n43-59,28-59\n99-99,17-96\n7-7,8-92\n57-95,46-98\n96-98,7-93\n4-96,3-4\n18-18,19-40\n44-65,43-45\n27-97,26-98\n1-93,21-94\n8-8,7-96\n22-79,78-79\n93-93,5-93\n3-90,2-2\n42-42,41-42\n39-77,54-65\n1-2,2-29\n37-47,36-38\n50-79,32-50\n45-94,95-96\n50-54,51-53\n98-99,33-91\n6-93,93-99\n17-63,17-93\n72-74,75-82\n43-79,44-59\n17-97,31-98\n93-98,94-99\n40-42,41-58\n29-31,12-71\n49-49,45-49\n30-99,29-99\n16-29,15-30\n46-46,47-83\n35-86,29-31\n12-14,11-13\n21-78,22-77\n30-74,95-97\n6-24,6-57\n8-93,7-91\n25-69,24-24\n11-35,1-35\n39-40,42-76\n5-92,5-91\n58-83,3-83\n98-98,2-95\n32-69,31-64\n61-99,26-99\n90-95,53-89\n36-37,12-37\n70-79,69-80\n8-67,8-66\n27-87,28-86\n13-86,12-93\n19-83,18-84\n7-40,6-41\n12-87,12-87\n12-91,12-96\n10-83,15-83\n6-68,69-69\n5-13,3-13\n57-57,56-71\n4-51,5-52\n15-83,14-83\n4-98,4-96\n3-25,4-26\n37-77,36-82\n69-78,6-68\n13-96,12-99\n41-76,40-77\n6-66,7-67\n4-9,5-50\n74-83,75-98\n11-97,10-97\n90-90,15-89\n2-74,2-3\n12-97,11-98\n99-99,1-99\n68-92,68-91\n11-12,19-61\n16-74,17-75\n37-46,15-20\n16-53,13-13\n18-84,17-84\n69-78,70-79\n47-74,48-83\n95-95,10-94\n37-67,37-43\n35-91,1-92\n17-19,18-96\n5-98,4-99\n52-53,52-79\n1-2,1-98\n84-97,60-83\n51-89,88-99\n5-35,25-36\n9-98,8-67\n3-4,3-83\n33-91,48-91\n49-50,3-50\n55-91,95-99\n53-53,3-54\n2-95,1-1\n24-80,51-80\n97-98,1-96\n12-97,11-99\n3-97,4-97\n6-69,13-70\n1-93,1-93\n25-90,26-52\n13-27,28-95\n9-89,9-87\n23-66,16-22\n88-99,87-98\n58-77,57-68\n24-51,51-94\n2-8,9-79\n62-62,44-70\n47-47,5-47\n8-8,7-13\n12-99,12-97\n36-47,46-46\n34-40,33-39\n80-80,6-80\n6-24,5-22\n8-91,7-91\n65-85,66-86\n5-45,38-44\n21-27,26-76\n5-96,4-99\n12-94,2-95\n10-77,9-23\n12-78,18-77\n4-92,5-96\n38-70,48-70\n21-49,22-27\n1-39,2-2\n74-75,23-75\n94-99,17-93\n10-10,11-40\n18-81,81-81\n31-84,83-85\n49-53,50-57\n10-24,40-60\n20-87,86-87\n75-81,76-81\n14-80,13-95\n9-9,10-98\n82-92,81-93\n37-83,38-74\n28-85,3-15\n1-42,8-43\n24-54,13-14\n62-97,61-96\n15-94,16-16\n6-24,30-74\n27-27,26-82\n25-27,27-50\n48-92,47-78\n7-49,18-50\n8-87,9-97\n2-99,3-99\n23-28,22-27\n21-21,21-27\n7-90,6-89\n46-76,47-76\n63-99,62-98\n91-92,91-97\n22-76,5-23\n15-89,1-10\n30-96,28-93\n74-91,74-94\n65-89,66-82\n29-47,29-93\n44-99,45-98\n89-89,17-90\n5-83,5-83\n17-85,16-85\n7-49,48-48\n4-82,4-81\n5-8,4-8\n40-57,56-58\n45-82,30-82\n4-97,4-95\n3-90,4-89\n41-64,63-71\n29-29,30-32\n28-98,17-28\n27-97,27-27\n1-92,1-92\n34-76,77-77\n86-94,5-93\n24-85,24-92\n7-97,96-98\n28-43,42-42\n27-35,28-34\n37-49,38-38\n94-95,2-95\n86-86,15-80\n41-53,42-52\n11-73,11-74\n18-19,19-90\n2-2,4-33\n3-93,4-93\n5-93,21-94\n3-58,2-98\n39-50,40-50\n33-81,2-81\n10-24,11-25\n55-61,54-62\n93-93,50-93\n3-92,4-4\n2-81,1-82\n20-99,16-98\n81-92,1-81\n22-56,22-56\n29-40,30-30\n38-69,22-69\n11-50,10-32\n49-60,48-59\n1-37,8-49\n88-95,1-87\n92-96,27-68\n31-40,30-32\n67-84,47-67\n22-64,23-23\n68-92,67-67\n64-65,9-65\n8-80,7-8\n44-98,45-99\n38-67,68-68\n3-93,4-97\n56-56,57-70\n10-12,11-82\n31-76,31-65\n19-96,96-96\n44-95,45-94\n20-90,21-90\n8-94,9-94\n94-97,12-93\n61-78,61-78\n77-88,78-82\n23-97,96-97\n18-98,19-99\n63-63,56-63\n21-85,12-95\n3-98,1-1\n19-91,18-18\n8-11,13-38\n21-73,21-74\n12-80,11-79\n3-4,4-51\n98-99,44-97\n17-60,14-60\n47-48,47-91\n42-43,44-61\n21-93,20-92\n79-98,80-98\n47-60,46-79\n27-85,28-86\n45-76,6-75\n35-47,36-46\n25-29,24-75\n16-63,60-92\n56-70,50-56\n27-94,27-80\n10-88,87-88\n5-78,3-56\n2-18,1-7\n6-77,5-8\n57-57,53-57\n8-83,7-83\n14-99,14-97\n4-16,15-15\n66-94,65-95\n61-84,60-83\n2-85,3-27\n2-94,75-95\n5-88,5-87\n2-94,1-93\n44-45,1-44\n16-72,6-17\n48-48,47-64\n79-79,50-78\n33-50,15-32\n30-98,31-97\n7-53,7-54\n57-68,69-74\n21-21,20-86\n19-61,20-20\n61-61,42-60\n25-89,10-24\n19-82,22-83\n7-32,19-32\n30-41,42-67\n37-38,1-38\n2-94,1-94\n15-92,1-15\n16-88,87-87\n71-83,82-84\n82-83,82-82\n9-14,8-10\n18-26,19-27\n69-69,17-69\n52-93,51-93\n7-99,98-99\n10-93,42-93\n18-93,18-19\n4-99,1-98\n42-89,97-98\n7-86,6-87\n31-54,5-53\n44-95,43-94\n15-96,16-95\n8-72,7-23\n21-21,20-84\n23-96,24-96\n38-87,19-23\n3-92,4-4\n17-25,17-25\n10-88,11-91\n4-12,11-71\n20-43,19-35\n91-91,22-92\n51-97,52-98\n89-98,7-63\n45-45,34-45\n91-91,16-91\n29-56,21-28\n46-65,45-58\n14-50,15-70\n9-48,10-10\n18-18,18-82\n87-95,87-94\n79-83,18-52\n35-54,25-55\n76-87,36-87\n27-61,25-61\n1-44,1-74\n23-25,24-56\n29-68,15-68\n85-97,86-99\n14-91,13-91\n10-90,10-92\n46-85,33-79\n86-92,6-54\n1-99,98-99\n3-73,3-72\n68-79,53-79\n5-42,4-77\n83-84,51-84\n6-55,7-54\n58-59,13-59\n32-59,1-15\n4-7,5-44\n3-97,3-98\n27-68,26-69\n41-52,53-85\n3-97,2-97\n27-61,26-62\n1-93,92-92\n29-34,28-35\n29-48,30-30\n19-21,20-54\n14-63,4-63\n25-93,10-93\n1-1,1-99\n18-33,18-34\n86-86,9-86\n26-95,96-99\n12-53,11-52\n2-93,94-98\n44-74,73-77\n23-99,20-22\n1-53,4-54\n9-9,8-10\n89-93,3-88\n32-32,15-32\n17-18,18-82\n3-99,2-98\n55-61,21-76\n13-27,14-28\n43-93,51-95\n52-91,52-90\n34-70,33-69\n14-92,14-91\n93-93,27-94\n14-17,4-13\n44-89,43-89\n2-96,4-90\n5-52,5-69\n11-67,12-12\n39-95,17-95\n1-58,3-57\n39-70,40-81\n3-90,90-94\n56-97,55-81\n2-39,1-39\n2-4,6-89\n69-69,8-69\n97-99,52-57\n55-56,23-56\n3-98,2-99\n68-89,21-88\n87-95,47-66\n44-99,45-98\n25-90,97-99\n53-90,90-90\n3-95,2-96\n3-5,6-78\n11-25,12-24\n8-11,8-64\n62-97,62-79\n89-89,66-89\n27-94,68-93\n30-83,83-83\n10-98,15-88\n2-2,1-98\n95-95,39-95\n3-29,29-92\n5-5,6-99\n40-73,72-72\n83-95,57-80\n57-58,54-58\n30-42,29-74\n12-14,13-93\n5-7,6-18\n25-61,62-62\n8-28,6-8\n14-45,13-59\n9-97,8-98\n2-97,3-98\n6-24,22-24\n40-95,39-96\n42-74,43-74\n33-33,34-96\n25-87,86-87\n62-62,63-95\n12-78,79-98\n67-89,23-72\n95-96,7-96\n7-69,4-41\n1-2,3-99\n45-86,86-96\n42-89,55-90\n81-87,27-80\n4-91,2-3\n26-58,73-77\n1-88,2-97\n42-59,41-88\n19-71,3-71\n47-66,28-89\n21-81,9-20\n56-85,57-98\n9-30,7-31\n12-19,53-62\n87-99,13-86\n22-84,21-83\n36-36,35-75\n97-98,60-98\n78-78,15-79\n13-95,96-97\n3-63,62-64\n6-80,7-79\n13-45,45-73\n34-57,9-33\n71-74,71-73\n21-27,21-21\n3-6,7-87\n8-87,9-88\n96-99,39-97\n5-57,2-2\n48-48,47-90\n49-81,81-81\n26-27,26-79\n13-95,14-94\n2-99,3-98\n17-93,3-92\n48-97,48-94\n6-68,6-85\n67-84,71-83\n87-91,16-68\n36-39,26-38\n36-86,20-35\n23-69,23-93\n23-33,34-56\n54-95,54-95\n10-10,9-96\n28-28,27-27\n44-87,43-45\n59-59,45-59\n70-98,97-98\n24-98,25-78\n11-98,11-75\n3-11,32-86\n23-87,22-91\n5-80,6-14\n38-81,51-80\n33-85,20-21\n29-37,38-82\n41-91,42-59\n45-88,78-84\n48-49,48-83\n5-80,3-80\n27-43,28-46\n2-95,3-99\n14-68,13-69\n1-84,2-83\n59-94,60-95\n4-5,2-6\n5-96,8-97\n78-84,54-77\n36-90,37-89\n28-35,28-50\n12-77,12-92\n25-88,2-87\n16-26,17-25\n26-99,98-99\n95-95,97-97\n34-82,33-83\n14-98,98-98\n2-97,2-97\n29-29,30-92\n97-98,14-98\n13-86,3-85\n6-76,5-5\n89-95,30-38\n22-66,23-34\n2-22,12-68\n19-66,20-20\n23-64,10-22\n6-69,3-6\n8-48,9-10\n37-38,17-38\n20-38,33-37\n43-43,2-42\n2-98,4-98\n28-99,27-68\n29-69,68-70\n15-25,16-26\n73-79,74-79\n69-96,70-95\n13-67,12-68\n76-90,7-89\n59-89,95-99\n34-90,33-99\n70-94,66-87\n72-80,73-80\n29-72,31-59\n26-35,25-36\n43-93,93-93\n84-93,30-85\n32-32,7-33\n31-91,53-90\n55-59,34-60\n76-99,77-77\n12-24,25-55\n38-81,39-82\n12-99,6-59\n24-82,24-35\n16-53,16-53\n19-22,21-21\n61-61,10-62\n5-87,2-87\n4-95,10-92\n13-39,14-99\n3-95,1-95\n9-64,16-64\n38-75,37-74\n2-47,3-80\n40-82,82-86\n53-68,53-53\n1-90,2-91\n25-25,26-55\n14-49,14-42\n6-15,5-38\n11-12,12-23\n36-94,37-96\n25-93,25-94\n20-57,19-58\n67-85,68-85\n26-69,27-68\n8-20,11-63\n15-86,14-86\n9-77,6-77\n11-90,12-91\n23-83,13-84\n89-97,96-97\n43-50,42-50\n59-78,60-87\n7-76,6-6\n20-35,22-34";
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 && a <= y ) || (b >= 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);