|
|
@@ -13,10 +13,10 @@ public class Universe
|
|
|
Galaxies.Add(galaxy);
|
|
|
}
|
|
|
|
|
|
- public void Expand()
|
|
|
+ public void Expand(int expansionFactor)
|
|
|
{
|
|
|
- var xMap = new Dictionary<int, IList<Galaxy>>();
|
|
|
- var yMap = new Dictionary<int, IList<Galaxy>>();
|
|
|
+ var xMap = new Dictionary<long, IList<Galaxy>>();
|
|
|
+ var yMap = new Dictionary<long, IList<Galaxy>>();
|
|
|
|
|
|
foreach (var g in Galaxies)
|
|
|
{
|
|
|
@@ -32,8 +32,8 @@ public class Universe
|
|
|
yMap[g.Position.Y].Add(g);
|
|
|
}
|
|
|
|
|
|
- var xPrev = -1;
|
|
|
- var xExpand = 0;
|
|
|
+ var xPrev = -1L;
|
|
|
+ var xExpand = 0L;
|
|
|
foreach (var x in xMap.Keys.Order())
|
|
|
{
|
|
|
xExpand += x - xPrev - 1;
|
|
|
@@ -41,13 +41,13 @@ public class Universe
|
|
|
|
|
|
foreach (var g in xMap[x])
|
|
|
{
|
|
|
- var delta = new GridPoint(xExpand, 0);
|
|
|
+ var delta = new GridPoint(xExpand * (expansionFactor - 1), 0);
|
|
|
g.Move(delta);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- var yPrev = -1;
|
|
|
- var yExpand = 0;
|
|
|
+ var yPrev = -1L;
|
|
|
+ var yExpand = 0L;
|
|
|
foreach (var y in yMap.Keys.Order())
|
|
|
{
|
|
|
yExpand += y - yPrev - 1;
|
|
|
@@ -55,7 +55,7 @@ public class Universe
|
|
|
|
|
|
foreach (var g in yMap[y])
|
|
|
{
|
|
|
- var delta = new GridPoint(0, yExpand);
|
|
|
+ var delta = new GridPoint(0, yExpand * (expansionFactor - 1));
|
|
|
g.Move(delta);
|
|
|
}
|
|
|
}
|
|
|
@@ -63,7 +63,7 @@ public class Universe
|
|
|
|
|
|
public long GetTotalDistance()
|
|
|
{
|
|
|
- var sum = 0;
|
|
|
+ var sum = 0L;
|
|
|
foreach (var pair in BuildPairs())
|
|
|
{
|
|
|
var distance = pair.Left.Position.Distance(pair.Right.Position);
|