diff --git a/aoc2019/Day12.cs b/aoc2019/Day12.cs
index 86d1981..1a36520 100644
--- a/aoc2019/Day12.cs
+++ b/aoc2019/Day12.cs
@@ -22,19 +22,6 @@ public sealed class Day12 : Day
moon.SetSiblings(moons);
}
- private static long Lcm(long a, long b) => a * b / Gcd(a, b);
-
- private static long Gcd(long a, long b)
- {
- while (true)
- {
- if (b == 0) return a;
- var a1 = a;
- a = b;
- b = a1 % b;
- }
- }
-
private void Step()
{
foreach (var moon in moons)
@@ -66,7 +53,7 @@ public sealed class Day12 : Day
if (cycleZ == 0 && moons.All(m => m.Dz == 0)) cycleZ = step * 2;
}
- return $"{Lcm(cycleX, Lcm(cycleY, cycleZ))}";
+ return $"{Util.Lcm(cycleX, Util.Lcm(cycleY, cycleZ))}";
}
public class Position
diff --git a/aoc2019/Util.cs b/aoc2019/Util.cs
new file mode 100644
index 0000000..28991e1
--- /dev/null
+++ b/aoc2019/Util.cs
@@ -0,0 +1,17 @@
+namespace aoc2019;
+
+internal static class Util
+{
+ public static long Lcm(long a, long b) => a * b / Gcd(a, b);
+
+ private static long Gcd(long a, long b)
+ {
+ while (true)
+ {
+ if (b == 0) return a;
+ var a1 = a;
+ a = b;
+ b = a1 % b;
+ }
+ }
+}
\ No newline at end of file
|