diff --git a/AdventOfCode/Problems/AOC2025/Day1/SecretEntrance.cs b/AdventOfCode/Problems/AOC2025/Day1/SecretEntrance.cs index 62a94fe..be86c80 100644 --- a/AdventOfCode/Problems/AOC2025/Day1/SecretEntrance.cs +++ b/AdventOfCode/Problems/AOC2025/Day1/SecretEntrance.cs @@ -35,21 +35,18 @@ internal class SecretEntrance : Problem foreach (var item in Input) { var vStart = v; - var sign = int.Sign(item); - var curC = 0; v += item; if (item > 0) - curC += (int)Math.Floor(v / (float)LOCK_SIZE); + c += (int)Math.Floor(v / (float)LOCK_SIZE); else { var d = v / (float)LOCK_SIZE; var fl = Math.Floor(d); - curC += (int)Math.Abs(fl) - (vStart == 0 ? 1 : 0); + c += (int)Math.Abs(fl) - (vStart == 0 ? 1 : 0); if (fl == d) - curC += 1; + c += 1; } - c += curC; v = v.Mod(LOCK_SIZE); } Part2 = c; diff --git a/AdventOfCode/Problems/AOC2025/Day2/GiftShop.cs b/AdventOfCode/Problems/AOC2025/Day2/GiftShop.cs new file mode 100644 index 0000000..4c0175b --- /dev/null +++ b/AdventOfCode/Problems/AOC2025/Day2/GiftShop.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Reflection.Metadata; +using System.Text; + +using ZLinq; + +namespace AdventOfCode.Problems.AOC2025.Day2; + +[ProblemInfo(2025, 2, "Gift Shop")] +internal class GiftShop : Problem +{ + private IdRange[] _ranges = []; + public override void CalculatePart1() + { + throw new NotImplementedException(); + } + + public static List GetDoubleSequences(IdRange range) + { + var minDigits = range.Min.DigitCount() / 2; + var maxDigits = range.Max.DigitCount() / 2; + throw new NotImplementedException(); + } + + public override void CalculatePart2() + { + throw new NotImplementedException(); + } + + public override void LoadInput() + { + var text = ReadInputText("sample.txt"); + _ranges = text.Split(',') + .AsValueEnumerable() + .Select(r => r.Split('-').Select(int.Parse)) + .Select(r => new IdRange(r.First(), r.Last())) + .ToArray(); + } + + public record IdRange(int Min, int Max); +} diff --git a/AdventOfCode/Runner/ExtraMath.cs b/AdventOfCode/Runner/ExtraMath.cs index f7fe5c3..4127e1b 100644 --- a/AdventOfCode/Runner/ExtraMath.cs +++ b/AdventOfCode/Runner/ExtraMath.cs @@ -34,4 +34,14 @@ public static class ExtraMath { return T.Min(a, b); } + + public static T Mod(this T value, T divisor) where T : INumber + { + T remainder = value % divisor; + + if (remainder < T.Zero) + return remainder + divisor; + else + return remainder; + } } \ No newline at end of file diff --git a/AdventOfCode/Utils/Extensions.cs b/AdventOfCode/Utils/Extensions.cs index 3a7904a..ee37c10 100644 --- a/AdventOfCode/Utils/Extensions.cs +++ b/AdventOfCode/Utils/Extensions.cs @@ -13,13 +13,5 @@ public static class Extensions return string.Join(delim, data); } - public static T Mod(this T value, T divisor) where T : INumber - { - T remainder = value % divisor; - - if (remainder < T.Zero) - return remainder + divisor; - else - return remainder; - } + }