Skip to content

Instantly share code, notes, and snippets.

@stevehjohn
Created December 16, 2022 02:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevehjohn/4cd65003a055fc42bc95fcaf83b41657 to your computer and use it in GitHub Desktop.
Save stevehjohn/4cd65003a055fc42bc95fcaf83b41657 to your computer and use it in GitHub Desktop.
AoC 2022.15
for (var l = 0; l < _sensors.Count; l++)
{
var sensorL = _sensors[l];
for (var r = 1; r < _sensors.Count; r++)
{
var sensorR = _sensors[r];
var targetDelta = sensorL.ManhattanRange + sensorR.ManhattanRange + 2;
var delta = Math.Abs(sensorL.Position.X - sensorR.Position.X) + Math.Abs(sensorL.Position.Y - sensorR.Position.Y);
if (delta == targetDelta)
{
Console.WriteLine($"{l}, {r}");
/*
* 2, 11
* 11, 2
* 12, 13
* 13, 12
*/
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment