diff --git a/AdventOfCode/Problems/AOC2024/Day10/HoofIt.cs b/AdventOfCode/Problems/AOC2024/Day10/HoofIt.cs new file mode 100644 index 0000000..e15973a --- /dev/null +++ b/AdventOfCode/Problems/AOC2024/Day10/HoofIt.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdventOfCode.Problems.AOC2024.Day10; +//[ProblemInfo(2024, 10, "Hoof It")] +internal class HoofIt : Problem +{ + public override void CalculatePart1() + { + throw new NotImplementedException(); + } + + public override void CalculatePart2() + { + throw new NotImplementedException(); + } + + public override void LoadInput() + { + throw new NotImplementedException(); + } +} diff --git a/AdventOfCode/Problems/AOC2024/Day11/PlutonianPebbles.cs b/AdventOfCode/Problems/AOC2024/Day11/PlutonianPebbles.cs new file mode 100644 index 0000000..249a876 --- /dev/null +++ b/AdventOfCode/Problems/AOC2024/Day11/PlutonianPebbles.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdventOfCode.Problems.AOC2024.Day11; +//[ProblemInfo(2024, 11, "Plutonian Pebbles")] +internal class PlutonianPebbles : Problem +{ + public override void CalculatePart1() + { + throw new NotImplementedException(); + } + + public override void CalculatePart2() + { + throw new NotImplementedException(); + } + + public override void LoadInput() + { + throw new NotImplementedException(); + } +} diff --git a/AdventOfCode/Problems/AOC2024/Day7/BridgeRepair.cs b/AdventOfCode/Problems/AOC2024/Day7/BridgeRepair.cs index 5ec1513..59e81eb 100644 --- a/AdventOfCode/Problems/AOC2024/Day7/BridgeRepair.cs +++ b/AdventOfCode/Problems/AOC2024/Day7/BridgeRepair.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AdventOfCode.Problems.AOC2024.Day7; +namespace AdventOfCode.Problems.AOC2024.Day7; [ProblemInfo(2024, 7, "Bridge Repair")] internal class BridgeRepair : Problem @@ -27,29 +21,6 @@ internal class BridgeRepair : Problem } } - private bool IsSolvable(ulong target, ulong[] nums, Operator[] ops) - { - return ops.Any(o => IsSolvable(target, nums, o, nums[0], ops)); - } - - private bool IsSolvable(ulong target, ulong[] nums, Operator curOperator, ulong curTotal, Operator[] ops, int idx = 1) - { - if (target == curTotal) - return true; - if (idx >= nums.Length) - return false; - - curTotal = curOperator switch - { - Operator.Mul => curTotal * nums[idx++], - Operator.Add => curTotal + nums[idx++], - Operator.Concat => ulong.Parse($"{curTotal}{nums[idx++]}"), - _ => curTotal, - }; - - return ops.Any(o => IsSolvable(target, nums, o, curTotal, ops, idx)); - } - public override void CalculatePart2() { foreach (var (target, nums) in _data) @@ -59,6 +30,31 @@ internal class BridgeRepair : Problem } } + private static bool IsSolvable(ulong target, ulong[] nums, Operator[] ops) + { + return ops.Any(o => IsSolvable(target, nums, o, nums[0], ops)); + } + + private static bool IsSolvable(ulong target, ulong[] nums, Operator curOperator, ulong curTotal, Operator[] ops, int idx = 1) + { + if (target == curTotal) + return true; + if (curTotal > target) + return false; + if (idx >= nums.Length) + return false; + + curTotal = curOperator switch + { + Operator.Mul => curTotal * nums[idx], + Operator.Add => curTotal + nums[idx], + Operator.Concat => ulong.Parse($"{curTotal}{nums[idx]}"), + _ => throw new InvalidOperationException(), + }; + + return ops.Any(o => IsSolvable(target, nums, o, curTotal, ops, idx + 1)); + } + public override void LoadInput() { var lines = ReadInputLines("input.txt"); diff --git a/AdventOfCode/Problems/AOC2024/Day9/DiskFragmenter.cs b/AdventOfCode/Problems/AOC2024/Day9/DiskFragmenter.cs new file mode 100644 index 0000000..8d21139 --- /dev/null +++ b/AdventOfCode/Problems/AOC2024/Day9/DiskFragmenter.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdventOfCode.Problems.AOC2024.Day9; +//[ProblemInfo(2024, 9, "Disk Fragmenter")] +internal class DiskFragmenter : Problem +{ + public override void CalculatePart1() + { + throw new NotImplementedException(); + } + + public override void CalculatePart2() + { + throw new NotImplementedException(); + } + + public override void LoadInput() + { + throw new NotImplementedException(); + } +}