foo
This commit is contained in:
1 parent
4fef30bfba
commit
bbd000a14f
6 files changed
+189
-2
No files matched your search
@@ -0,0 +1,71 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace adventOfCode.day9;
|
||||
|
||||
record Point(long X, long Y)
|
||||
{
|
||||
public static Point ParseLine(string line)
|
||||
{
|
||||
var x = line.Split(",");
|
||||
return new Point(long.Parse(x[0]), long.Parse(x[1]));
|
||||
}
|
||||
|
||||
|
||||
public static long Dist(Point p1, Point p2)
|
||||
{
|
||||
return (Math.Abs(p1.X - p2.X) + 1) * (Math.Abs(p1.Y - p2.Y) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
record Rectangle(Point C1, Point C2)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class Day9
|
||||
{
|
||||
static List<Point> ParseInput(string document)
|
||||
{
|
||||
return (from line in document.Split("\n") select Point.ParseLine(line)).ToList();
|
||||
}
|
||||
|
||||
static IEnumerable<Tuple<Point, Point>> AllPairs(List<Point> points)
|
||||
{
|
||||
for (var i = 0; i < points.Count; i++)
|
||||
{
|
||||
for (var j = i + 1; j < points.Count; j++)
|
||||
{
|
||||
yield return new Tuple<Point, Point>(points[i], points[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static long Question9A(string document)
|
||||
{
|
||||
var points = ParseInput(document);
|
||||
return (from pair in AllPairs(points) select Point.Dist(pair.Item1, pair.Item2)).Max();
|
||||
}
|
||||
|
||||
static long Question9B(string document)
|
||||
{
|
||||
var points = ParseInput(document);
|
||||
var pairs = from pair in AllPairs(points) orderby Point.Dist(pair.Item1, pair.Item2) descending select pair;
|
||||
foreach (var pair in pairs)
|
||||
{
|
||||
// if
|
||||
|
||||
}
|
||||
return 23;
|
||||
|
||||
}
|
||||
|
||||
public static void Main_()
|
||||
{
|
||||
Console.WriteLine($"Answer to question 9a is: {Question9A(Inputs.Input)}");
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace adventOfCode.day9;
|
||||
|
||||
public class Inputs
|
||||
{
|
||||
public static readonly string Example = "7,1\n11,1\n11,7\n9,7\n9,5\n2,5\n2,3\n7,3";
|
||||
public static readonly string Input = "97615,50359\n97615,51574\n97880,51574\n97880,52787\n97832,52787\n97832,54045\n98308,54045\n98308,55187\n97455,55187\n97455,56428\n97608,56428\n97608,57577\n97086,57577\n97086,58800\n97054,58800\n97054,60056\n97128,60056\n97128,61283\n97011,61283\n97011,62360\n96295,62360\n96295,63474\n95780,63474\n95780,64718\n95702,64718\n95702,65758\n94990,65758\n94990,67104\n95133,67104\n95133,68247\n94699,68247\n94699,69240\n93917,69240\n93917,70385\n93499,70385\n93499,71581\n93170,71581\n93170,72717\n92702,72717\n92702,73502\n91601,73502\n91601,74745\n91319,74745\n91319,75801\n90706,75801\n90706,76627\n89745,76627\n89745,77961\n89534,77961\n89534,78812\n88622,78812\n88622,79459\n87470,79459\n87470,80349\n86652,80349\n86652,81297\n85905,81297\n85905,82410\n85333,82410\n85333,83641\n84859,83641\n84859,84224\n83712,84224\n83712,85182\n82941,85182\n82941,85489\n81580,85489\n81580,86273\n80667,86273\n80667,87660\n80237,87660\n80237,87896\n78879,87896\n78879,88858\n78085,88858\n78085,89421\n76998,89421\n76998,90264\n76103,90264\n76103,90831\n75024,90831\n75024,91515\n74018,91515\n74018,92447\n73143,92447\n73143,92488\n71787,92488\n71787,93692\n71024,93692\n71024,93312\n69506,93312\n69506,94350\n68637,94350\n68637,94479\n67379,94479\n67379,95144\n66333,95144\n66333,95471\n65160,95471\n65160,96293\n64141,96293\n64141,96243\n62855,96243\n62855,96580\n61686,96580\n61686,97010\n60535,97010\n60535,97390\n59366,97390\n59366,96985\n58055,96985\n58055,97125\n56855,97125\n56855,97277\n55659,97277\n55659,97593\n54477,97593\n54477,97412\n53250,97412\n53250,98188\n52079,98188\n52079,97850\n50851,97850\n50851,97591\n49640,97591\n49640,97613\n48433,97613\n48433,97478\n47232,97478\n47232,97959\n45983,97959\n45983,98122\n44739,98122\n44739,97901\n43531,97901\n43531,97758\n42314,97758\n42314,96719\n41262,96719\n41262,97232\n39921,97232\n39921,96719\n38786,96719\n38786,96225\n37658,96225\n37658,96045\n36448,96045\n36448,95750\n35265,95750\n35265,95184\n34173,95184\n34173,95280\n32840,95280\n32840,94440\n31858,94440\n31858,93838\n30794,93838\n30794,93113\n29795,93113\n29795,93299\n28353,93299\n28353,92192\n27553,92192\n27553,91710\n26435,91710\n26435,91165\n25347,91165\n25347,90253\n24485,90253\n24485,89978\n23217,89978\n23217,88985\n22426,88985\n22426,88304\n21425,88304\n21425,87446\n20559,87446\n20559,87114\n19267,87114\n19267,86006\n18614,86006\n18614,85364\n17561,85364\n17561,84365\n16835,84365\n16835,83879\n15605,83879\n15605,82741\n15031,82741\n15031,81877\n14176,81877\n14176,81139\n13168,81139\n13168,80122\n12482,80122\n12482,79364\n11466,79364\n11466,77950\n11328,77950\n11328,77269\n10183,77269\n10183,75850\n10124,75850\n10124,75271\n8765,75271\n8765,73896\n8695,73896\n8695,72983\n7845,72983\n7845,72127\n6848,72127\n6848,70848\n6673,70848\n6673,69631\n6410,69631\n6410,68724\n5442,68724\n5442,67546\n5091,67546\n5091,66231\n5138,66231\n5138,65210\n4378,65210\n4378,63906\n4476,63906\n4476,62782\n4019,62782\n4019,61592\n3793,61592\n3793,60572\n2824,60572\n2824,59258\n3156,59258\n3156,58109\n2702,58109\n2702,56905\n2535,56905\n2535,55719\n2221,55719\n2221,54475\n2427,54475\n2427,53302\n1837,53302\n1837,52073\n1940,52073\n1940,50856\n1855,50856\n1855,50338\n94918,50338\n94918,48430\n2294,48430\n2294,47210\n2136,47210\n2136,45974\n1928,45974\n1928,44816\n2583,44816\n2583,43602\n2623,43602\n2623,42452\n3100,42452\n3100,41261\n3276,41261\n3276,39997\n3124,39997\n3124,38711\n2970,38711\n2970,37675\n3839,37675\n3839,36558\n4329,36558\n4329,35324\n4431,35324\n4431,34177\n4825,34177\n4825,32887\n4842,32887\n4842,31903\n5669,31903\n5669,30777\n6123,30777\n6123,29546\n6355,29546\n6355,28756\n7505,28756\n7505,27268\n7271,27268\n7271,26599\n8579,26599\n8579,25471\n9042,25471\n9042,24432\n9662,24432\n9662,23524\n10480,23524\n10480,22341\n10894,22341\n10894,21323\n11559,21323\n11559,20292\n12213,20292\n12213,19289\n12911,19289\n12911,18288\n13619,18288\n13619,17248\n14294,17248\n14294,16628\n15419,16628\n15419,16039\n16548,16039\n16548,15220\n17435,15220\n17435,14383\n18306,14383\n18306,13672\n19286,13672\n19286,12373\n19789,12373\n19789,12150\n21156,12150\n21156,11025\n21831,11025\n21831,10536\n22972,10536\n22972,10037\n24092,10037\n24092,9428\n25134,9428\n25134,8698\n26104,8698\n26104,8188\n27203,8188\n27203,7023\n27961,7023\n27961,6535\n29085,6535\n29085,6343\n30338,6343\n30338,5846\n31445,5846\n31445,5498\n32612,5498\n32612,4868\n33671,4868\n33671,4752\n34914,4752\n34914,4301\n36039,4301\n36039,4224\n37274,4224\n37274,3841\n38419,3841\n38419,2952\n39455,2952\n39455,3029\n40716,3029\n40716,2858\n41917,2858\n41917,2054\n43024,2054\n43024,1940\n44247,1940\n44247,2483\n45530,2483\n45530,1888\n46701,1888\n46701,2338\n47943,2338\n47943,1574\n49138,1574\n49138,2240\n50360,2240\n50360,2185\n51572,2185\n51572,1632\n52818,1632\n52818,1686\n54046,1686\n54046,2670\n55174,2670\n55174,2098\n56468,2098\n56468,3008\n57562,3008\n57562,2737\n58839,2737\n58839,2624\n60108,2624\n60108,3047\n61269,3047\n61269,3156\n62506,3156\n6
Line truncated
|
||||
}
|
||||
Reference in new issue
Block a user