misc
This commit is contained in:
25
AdventOfCode/Problems/AOC2024/Day10/HoofIt.cs
Normal file
25
AdventOfCode/Problems/AOC2024/Day10/HoofIt.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
25
AdventOfCode/Problems/AOC2024/Day11/PlutonianPebbles.cs
Normal file
25
AdventOfCode/Problems/AOC2024/Day11/PlutonianPebbles.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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<ulong, ulong>
|
||||
@@ -27,29 +21,6 @@ internal class BridgeRepair : Problem<ulong, ulong>
|
||||
}
|
||||
}
|
||||
|
||||
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<ulong, ulong>
|
||||
}
|
||||
}
|
||||
|
||||
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");
|
||||
|
||||
25
AdventOfCode/Problems/AOC2024/Day9/DiskFragmenter.cs
Normal file
25
AdventOfCode/Problems/AOC2024/Day9/DiskFragmenter.cs
Normal file
@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user