Automatic code cleanup

This commit is contained in:
2023-12-02 12:39:10 -05:00
parent 70de8d15b1
commit 26d876e178
36 changed files with 132 additions and 293 deletions

View File

@@ -1,13 +1,9 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Headers;
using System.Text; using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2015.Day10; namespace AdventOfCode.Problems.AOC2015.Day10;
[ProblemInfo(2015, 10, "Evles Look, Elves Say")] [ProblemInfo(2015, 10, "Evles Look, Elves Say")]
internal class LookAndSay : Problem<int, int> internal class LookAndSay : Problem<int, int>
{ {

View File

@@ -31,6 +31,7 @@ public class NiceList : Problem<int, int>
} }
} }
} }
private static bool IsNice2(string value) private static bool IsNice2(string value)
{ {
var pairs = new Dictionary<string, List<int>>(); var pairs = new Dictionary<string, List<int>>();

View File

@@ -1,11 +1,5 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace AdventOfCode.Problems.AOC2019.Day1 namespace AdventOfCode.Problems.AOC2019.Day1
{ {
[ProblemInfo(2019, 1, "The Tyranny of the Rocket Equation")] [ProblemInfo(2019, 1, "The Tyranny of the Rocket Equation")]
@@ -41,7 +35,6 @@ namespace AdventOfCode.Problems.AOC2019.Day1
public override void CalculatePart2() public override void CalculatePart2()
{ {
Part2 = GetFuelRequirement(_input); Part2 = GetFuelRequirement(_input);
} }
} }

View File

@@ -1,13 +1,6 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Linq;
using System.Net.Http.Headers;
using System.Text;
namespace AdventOfCode.Problems.AOC2019.Day3 namespace AdventOfCode.Problems.AOC2019.Day3
{ {
@@ -227,7 +220,6 @@ namespace AdventOfCode.Problems.AOC2019.Day3
public static int SolveWires(string[] wires) public static int SolveWires(string[] wires)
{ {
var (wireSegmentsA, wireSegmentsB) = CreateWirePair(wires); var (wireSegmentsA, wireSegmentsB) = CreateWirePair(wires);
int shortestWire = int.MaxValue; int shortestWire = int.MaxValue;
@@ -271,7 +263,6 @@ namespace AdventOfCode.Problems.AOC2019.Day3
var wireA = wires[0].Split(','); var wireA = wires[0].Split(',');
var wireSegmentsA = CreateWire(wireA); var wireSegmentsA = CreateWire(wireA);
var wireB = wires[1].Split(','); var wireB = wires[1].Split(',');
var wireSegmentsB = CreateWire(wireB); var wireSegmentsB = CreateWire(wireB);

View File

@@ -1,11 +1,5 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace AdventOfCode.Problems.AOC2019.Day4 namespace AdventOfCode.Problems.AOC2019.Day4
{ {
[ProblemInfo(2019, 4, "Secure Container")] [ProblemInfo(2019, 4, "Secure Container")]
@@ -30,7 +24,6 @@ namespace AdventOfCode.Problems.AOC2019.Day4
public static bool HasDoubles(int[] password) public static bool HasDoubles(int[] password)
{ {
bool foundDouble = false; bool foundDouble = false;
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
{ {
@@ -53,7 +46,6 @@ namespace AdventOfCode.Problems.AOC2019.Day4
foundDouble = true; foundDouble = true;
} }
return foundDouble; return foundDouble;
} }
public static bool IsAssending(int[] password) public static bool IsAssending(int[] password)
@@ -68,8 +60,6 @@ namespace AdventOfCode.Problems.AOC2019.Day4
return true; return true;
} }
public static int CountPasswordsPart1(int lower, int upper) public static int CountPasswordsPart1(int lower, int upper)
{ {
int passwordCount = 0; int passwordCount = 0;
@@ -87,6 +77,7 @@ namespace AdventOfCode.Problems.AOC2019.Day4
} }
return passwordCount; return passwordCount;
} }
public static int CountPasswordsPart2(int lower, int upper) public static int CountPasswordsPart2(int lower, int upper)
{ {
int passwordCount = 0; int passwordCount = 0;
@@ -139,7 +130,6 @@ namespace AdventOfCode.Problems.AOC2019.Day4
} }
} }
public override void LoadInput() public override void LoadInput()
{ {
} }

View File

@@ -1,14 +1,8 @@
using AdventOfCode.Day_5; using AdventOfCode.Day_5;
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2019.Day5; namespace AdventOfCode.Problems.AOC2019.Day5;
[ProblemInfo(2019, 5, "Sunny with a Chance of Asteroids")] [ProblemInfo(2019, 5, "Sunny with a Chance of Asteroids")]
internal class ChanceOfAsteroids : Problem<int, int> internal class ChanceOfAsteroids : Problem<int, int>
{ {

View File

@@ -1,9 +1,4 @@
using System; namespace AdventOfCode.Day_5
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
namespace AdventOfCode.Day_5
{ {
public class IntCodeV2 public class IntCodeV2
{ {
@@ -19,7 +14,6 @@ namespace AdventOfCode.Day_5
this.paramCount = paramCount; this.paramCount = paramCount;
this.action = action; this.action = action;
} }
} }
public bool IsHalted { get; private set; } public bool IsHalted { get; private set; }
@@ -171,6 +165,7 @@ namespace AdventOfCode.Day_5
{ {
case 1: case 1:
return (opModes, arr[0]); return (opModes, arr[0]);
case 2: case 2:
return (opModes, (arr[^2] * 10) + arr[^1]); return (opModes, (arr[^2] * 10) + arr[^1]);
} }
@@ -234,7 +229,5 @@ namespace AdventOfCode.Day_5
_instructionPointer = 0; _instructionPointer = 0;
return this; return this;
} }
} }
} }

View File

@@ -1,12 +1,7 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2019.Day6; namespace AdventOfCode.Problems.AOC2019.Day6;
[ProblemInfo(2019, 6, "Universal Orbit Map")] [ProblemInfo(2019, 6, "Universal Orbit Map")]
internal class UniversalOrbits : Problem<int, int> internal class UniversalOrbits : Problem<int, int>
{ {
@@ -31,7 +26,6 @@ internal class UniversalOrbits : Problem<int, int>
HashSet<string> pathYOU = new(pathToYOU.Select(o => o.Name)); HashSet<string> pathYOU = new(pathToYOU.Select(o => o.Name));
for (int i = 0; i < pathToSAN.Count; i++) for (int i = 0; i < pathToSAN.Count; i++)
{ {
if (pathYOU.Contains(pathToSAN[i].Name)) if (pathYOU.Contains(pathToSAN[i].Name))
@@ -50,7 +44,6 @@ internal class UniversalOrbits : Problem<int, int>
} }
} }
Part2 = dist - 2; Part2 = dist - 2;
} }
public override void LoadInput() public override void LoadInput()

View File

@@ -1,11 +1,5 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace AdventOfCode.Problems.AOC2019.Day8 namespace AdventOfCode.Problems.AOC2019.Day8
{ {
[ProblemInfo(2019, 8, "Space Image Format")] [ProblemInfo(2019, 8, "Space Image Format")]
@@ -18,7 +12,6 @@ namespace AdventOfCode.Problems.AOC2019.Day8
var imageData = File.ReadAllText("Day8/input.txt").Replace("\n", "").Select(c => int.Parse(c.ToString())).ToArray(); var imageData = File.ReadAllText("Day8/input.txt").Replace("\n", "").Select(c => int.Parse(c.ToString())).ToArray();
Console.WriteLine(Checksum(imageData, 25, 6)); Console.WriteLine(Checksum(imageData, 25, 6));
} }
public static void RenderImage(int[] data, int h, int w) public static void RenderImage(int[] data, int h, int w)
@@ -28,11 +21,9 @@ namespace AdventOfCode.Problems.AOC2019.Day8
for (int l = 0; l < layerCount; l++) for (int l = 0; l < layerCount; l++)
{ {
} }
} }
public static int Checksum(int[] data, int h, int w) public static int Checksum(int[] data, int h, int w)
{ {
var imgSize = h * w; var imgSize = h * w;
@@ -54,9 +45,11 @@ namespace AdventOfCode.Problems.AOC2019.Day8
case 0: case 0:
zeroCount[l]++; zeroCount[l]++;
break; break;
case 1: case 1:
oneCount[l]++; oneCount[l]++;
break; break;
case 2: case 2:
twoCount[l]++; twoCount[l]++;
break; break;
@@ -70,7 +63,6 @@ namespace AdventOfCode.Problems.AOC2019.Day8
} }
return oneCount[smallestLayer] * twoCount[smallestLayer]; return oneCount[smallestLayer] * twoCount[smallestLayer];
} }
public override void LoadInput() public override void LoadInput()

View File

@@ -1,10 +1,4 @@
using System; namespace AdventOfCode
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace AdventOfCode
{ {
public static class InputParsing public static class InputParsing
{ {

View File

@@ -1,9 +1,6 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System.Collections; using System.Collections;
using System.Numerics;
using System.Text;
namespace AdventOfCode.Problems.AOC2021.Day11; namespace AdventOfCode.Problems.AOC2021.Day11;
@@ -76,7 +73,6 @@ public class DumboOctopus : Problem<int, int>, IEnumerable<byte>
{ {
Increment(ref data); Increment(ref data);
Flash(ref data, ref flashes); Flash(ref data, ref flashes);
} }
private static void Increment(ref byte[] data) private static void Increment(ref byte[] data)

View File

@@ -1,12 +1,5 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2021.Day3; namespace AdventOfCode.Problems.AOC2021.Day3;
[ProblemInfo(2021, 3, "Binary Diagnostic")] [ProblemInfo(2021, 3, "Binary Diagnostic")]

View File

@@ -1,11 +1,5 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2021.Day6; namespace AdventOfCode.Problems.AOC2021.Day6;
[ProblemInfo(2021, 6, "Lanternfish")] [ProblemInfo(2021, 6, "Lanternfish")]
@@ -18,11 +12,11 @@ internal class LanternFish : Problem<long, long>
var input = ReadInputLines(); var input = ReadInputLines();
Data = input.First().Split(",").Select(v => int.Parse(v)).ToArray(); Data = input.First().Split(",").Select(v => int.Parse(v)).ToArray();
} }
public override void CalculatePart1() public override void CalculatePart1()
{ {
var lifetimes = PrepareLifetimes(); var lifetimes = PrepareLifetimes();
Part1 = Simulate(lifetimes, 80); Part1 = Simulate(lifetimes, 80);
} }
public override void CalculatePart2() public override void CalculatePart2()
@@ -53,8 +47,4 @@ internal class LanternFish : Problem<long, long>
return lifetimes.Sum(); return lifetimes.Sum();
} }
} }

View File

@@ -1,7 +1,7 @@
using AdventOfCode.Runner; using AdventOfCode.Runner.Attributes;
using AdventOfCode.Runner.Attributes;
namespace AdventOfCode.Problems.AOC2022.Day0; namespace AdventOfCode.Problems.AOC2022.Day0;
[ProblemInfo(2022, 0, "Fancy Test")] [ProblemInfo(2022, 0, "Fancy Test")]
public class TestProblem : Problem public class TestProblem : Problem
{ {
@@ -20,7 +20,6 @@ public class TestProblem : Problem
Thread.Sleep(1000); Thread.Sleep(1000);
} }
public override void PrintPart1() public override void PrintPart1()
{ {
Console.WriteLine("Result"); Console.WriteLine("Result");

View File

@@ -1,13 +1,7 @@
using AdventOfCode.Runner; using AdventOfCode.Runner.Attributes;
using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day1; namespace AdventOfCode.Problems.AOC2022.Day1;
[ProblemInfo(2022, 1, "Calorie Counting")] [ProblemInfo(2022, 1, "Calorie Counting")]
internal class CalorieCounting : Problem internal class CalorieCounting : Problem
{ {
@@ -16,7 +10,8 @@ internal class CalorieCounting : Problem
private (int calories, int elf)? _mostestElf; private (int calories, int elf)? _mostestElf;
private IEnumerable<(int sum, int idx)>? _mostestElves; private IEnumerable<(int sum, int idx)>? _mostestElves;
public CalorieCounting() { public CalorieCounting()
{
FlaresFood = new List<List<int>> FlaresFood = new List<List<int>>
{ {
new List<int>() new List<int>()
@@ -38,6 +33,7 @@ internal class CalorieCounting : Problem
FlaresFood[c].Add(int.Parse(calorie)); FlaresFood[c].Add(int.Parse(calorie));
} }
} }
public override void CalculatePart1() public override void CalculatePart1()
{ {
_mostestElf = FlaresFood _mostestElf = FlaresFood

View File

@@ -1,10 +1,5 @@
using System; namespace AdventOfCode.Problems.AOC2022.Day10;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day10;
internal class CathodeCPU internal class CathodeCPU
{ {
public enum Instruction public enum Instruction
@@ -38,9 +33,9 @@ internal class CathodeCPU
return result; return result;
} }
public void ExecuteCode((Instruction ins, int value)[] code, Action<int, int> processor) public void ExecuteCode((Instruction ins, int value)[] code, Action<int, int> processor)
{ {
while (_programCounter < code.Length) while (_programCounter < code.Length)
{ {
var (ins, value) = code[_programCounter]; var (ins, value) = code[_programCounter];
@@ -52,23 +47,20 @@ internal class CathodeCPU
case { ins: Instruction.NoOp }: case { ins: Instruction.NoOp }:
_programCounter++; _programCounter++;
break; break;
case { ins: Instruction.AddX, _pending: -1 }: case { ins: Instruction.AddX, _pending: -1 }:
_pending = 1; _pending = 1;
break; break;
case { ins: Instruction.AddX, _pending: 0 }: case { ins: Instruction.AddX, _pending: 0 }:
X += value; X += value;
_programCounter++; _programCounter++;
break; break;
} }
if (_pending >= 0) if (_pending >= 0)
_pending--; _pending--;
_cycleNumber++; _cycleNumber++;
} }
} }
} }

View File

@@ -25,7 +25,6 @@ internal class CathodeRayTube : Problem<int, string>
if (cycle > output.Length) if (cycle > output.Length)
return; return;
var pos = signal % 40; var pos = signal % 40;
var head = (cycle % 40); var head = (cycle % 40);
var sprite = Math.Abs(pos - head); var sprite = Math.Abs(pos - head);

View File

@@ -1,13 +1,7 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day11; namespace AdventOfCode.Problems.AOC2022.Day11;
[ProblemInfo(2022, 11, "Monkey in the Middle")] [ProblemInfo(2022, 11, "Monkey in the Middle")]
internal class MonkeyInTheMiddle : Problem<int, int> internal class MonkeyInTheMiddle : Problem<int, int>
{ {
@@ -37,7 +31,6 @@ internal class MonkeyInTheMiddle : Problem<int, int>
var lines = ReadInputLines("test.txt").Chunk(7); var lines = ReadInputLines("test.txt").Chunk(7);
_monkeysPart1 = lines.Select(ln => new Monkey(ln)).ToArray(); _monkeysPart1 = lines.Select(ln => new Monkey(ln)).ToArray();
_monkeysPart2 = lines.Select(ln => new Monkey(ln)).ToArray(); _monkeysPart2 = lines.Select(ln => new Monkey(ln)).ToArray();
} }
private static void Simulate(Monkey[] monkeys, int rounds, uint worry = 3) private static void Simulate(Monkey[] monkeys, int rounds, uint worry = 3)
@@ -54,8 +47,8 @@ internal class MonkeyInTheMiddle : Problem<int, int>
SimulateTurn(monkey, monkeys, worry); SimulateTurn(monkey, monkeys, worry);
} }
private static void SimulateTurn(Monkey monkey, Monkey[] monkeys, uint worry = 3)
private static void SimulateTurn(Monkey monkey, Monkey[] monkeys, uint worry = 3) { {
for (int i = 0; i < monkey.Items.Count; i++) for (int i = 0; i < monkey.Items.Count; i++)
{ {
var item = monkey.Inspect(monkey.Items[i], worry); var item = monkey.Inspect(monkey.Items[i], worry);

View File

@@ -1,12 +1,7 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day12; namespace AdventOfCode.Problems.AOC2022.Day12;
[ProblemInfo(2022, 12, "Hill Climbing Algorithm")] [ProblemInfo(2022, 12, "Hill Climbing Algorithm")]
internal class HillClimbing : Problem internal class HillClimbing : Problem
{ {

View File

@@ -1,12 +1,7 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day13; namespace AdventOfCode.Problems.AOC2022.Day13;
[ProblemInfo(2022, 13, "Distress Signal")] [ProblemInfo(2022, 13, "Distress Signal")]
internal class DistressSignal : Problem internal class DistressSignal : Problem
{ {

View File

@@ -1,12 +1,7 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day14; namespace AdventOfCode.Problems.AOC2022.Day14;
[ProblemInfo(2022, 14, "Regolith Reservoir")] [ProblemInfo(2022, 14, "Regolith Reservoir")]
internal class RegolithReservoir : Problem internal class RegolithReservoir : Problem
{ {

View File

@@ -1,5 +1,4 @@
using AdventOfCode.Runner; using AdventOfCode.Runner.Attributes;
using AdventOfCode.Runner.Attributes;
namespace AdventOfCode.Problems.AOC2022.Day2; namespace AdventOfCode.Problems.AOC2022.Day2;
@@ -74,7 +73,8 @@ internal class RockPaperScissors : Problem
}; };
} }
private static int GetResponseValue(char move, char result) { private static int GetResponseValue(char move, char result)
{
var p = result switch var p = result switch
{ {
'X' => (GetMoveValue(move) + 2) % 3, //Lose 'X' => (GetMoveValue(move) + 2) % 3, //Lose
@@ -85,7 +85,6 @@ internal class RockPaperScissors : Problem
return p == 0 ? 3 : p; return p == 0 ? 3 : p;
} }
public override void CalculatePart2() public override void CalculatePart2()
{ {
var score = 0; var score = 0;

View File

@@ -1,19 +1,14 @@
using AdventOfCode.Runner; using AdventOfCode.Runner.Attributes;
using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day3; namespace AdventOfCode.Problems.AOC2022.Day3;
[ProblemInfo(2022, 3, "Rucksack Reorganization")] [ProblemInfo(2022, 3, "Rucksack Reorganization")]
internal class RucksackReorganization : Problem internal class RucksackReorganization : Problem
{ {
private string[] _sacks; private string[] _sacks;
public RucksackReorganization() { public RucksackReorganization()
{
_sacks = Array.Empty<string>(); _sacks = Array.Empty<string>();
} }
@@ -21,6 +16,7 @@ internal class RucksackReorganization : Problem
{ {
_sacks = ReadInputLines("input.txt"); _sacks = ReadInputLines("input.txt");
} }
public override void CalculatePart1() public override void CalculatePart1()
{ {
var total = 0; var total = 0;
@@ -55,5 +51,4 @@ internal class RucksackReorganization : Problem
} }
Part2 = total.ToString(); Part2 = total.ToString();
} }
} }

View File

@@ -1,13 +1,7 @@
using AdventOfCode.Runner; using AdventOfCode.Runner.Attributes;
using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day4; namespace AdventOfCode.Problems.AOC2022.Day4;
[ProblemInfo(2022, 4, "Camp Cleanup")] [ProblemInfo(2022, 4, "Camp Cleanup")]
internal class CampCleanup : Problem<int, int> internal class CampCleanup : Problem<int, int>
{ {
@@ -32,7 +26,6 @@ internal class CampCleanup : Problem<int, int>
} }
} }
public override void CalculatePart1() public override void CalculatePart1()
{ {
var total = 0; var total = 0;
@@ -53,7 +46,6 @@ internal class CampCleanup : Problem<int, int>
} }
} }
record Range(int A, int B) record Range(int A, int B)
{ {
public bool Contains(Range other) public bool Contains(Range other)

View File

@@ -3,7 +3,6 @@
using Superpower; using Superpower;
using Superpower.Parsers; using Superpower.Parsers;
using System.Diagnostics;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace AdventOfCode.Problems.AOC2022.Day5; namespace AdventOfCode.Problems.AOC2022.Day5;
@@ -13,6 +12,7 @@ internal partial class SupplyStacks : Problem
{ {
private List<char>[] _stacksPart1 = Array.Empty<List<char>>(); private List<char>[] _stacksPart1 = Array.Empty<List<char>>();
private List<char>[] _stacksPart2 = Array.Empty<List<char>>(); private List<char>[] _stacksPart2 = Array.Empty<List<char>>();
private readonly TextParser<(int, int, int)> _moveParser = from move in Character.Letter.Or(Character.WhiteSpace).Many() private readonly TextParser<(int, int, int)> _moveParser = from move in Character.Letter.Or(Character.WhiteSpace).Many()
from stack in Character.Digit.Many() from stack in Character.Digit.Many()
from frm in Character.Letter.Or(Character.WhiteSpace).Many() from frm in Character.Letter.Or(Character.WhiteSpace).Many()

View File

@@ -1,11 +1,5 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2022.Day6; namespace AdventOfCode.Problems.AOC2022.Day6;
[ProblemInfo(2022, 6, "Tuning Trouble")] [ProblemInfo(2022, 6, "Tuning Trouble")]

View File

@@ -1,6 +1,4 @@
using System.Collections; namespace AdventOfCode.Problems.AOC2022.Day7;
namespace AdventOfCode.Problems.AOC2022.Day7;
internal class DirectoryNode internal class DirectoryNode
{ {

View File

@@ -37,7 +37,8 @@ internal class NoSpace : Problem<int,int>
ParseCommand(line[2..], ref curDir); ParseCommand(line[2..], ref curDir);
dir = $"/{string.Join("/", curDir.Reverse())}"; dir = $"/{string.Join("/", curDir.Reverse())}";
_dirTree.AddDirectory(dir); _dirTree.AddDirectory(dir);
}else }
else
ReadDirectory(line, _dirTree.GetDirectory(dir)!); ReadDirectory(line, _dirTree.GetDirectory(dir)!);
} }
} }

View File

@@ -68,7 +68,6 @@ public class RopeSimulator
else else
_visited.Add(tail, 1); _visited.Add(tail, 1);
} }
} }
private void FollowHead() private void FollowHead()

View File

@@ -1,14 +1,5 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using Superpower.Parsers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2023.Day1; namespace AdventOfCode.Problems.AOC2023.Day1;
[ProblemInfo(2023, 1, "Trebuchet!?")] [ProblemInfo(2023, 1, "Trebuchet!?")]
@@ -20,6 +11,7 @@ public partial class Trebuchet : Problem<int, int>
{ {
_inputData = ReadInputLines(); _inputData = ReadInputLines();
} }
public override void CalculatePart1() public override void CalculatePart1()
{ {
Part1 = _inputData.Select(GetCalibrationValues) Part1 = _inputData.Select(GetCalibrationValues)
@@ -78,7 +70,8 @@ public partial class Trebuchet : Problem<int, int>
{ {
left = word; left = word;
break; break;
}else if(line[i] - '0' >= 10) }
else if (line[i] - '0' >= 10)
continue; continue;
left = line[i] - '0'; left = line[i] - '0';

View File

@@ -1,12 +1,7 @@
using AdventOfCode.Runner.Attributes; using AdventOfCode.Runner.Attributes;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2023.Day2; namespace AdventOfCode.Problems.AOC2023.Day2;
[ProblemInfo(2023, 2, "Cube Conundrum")] [ProblemInfo(2023, 2, "Cube Conundrum")]
internal class CubeConundrum : Problem<int, int> internal class CubeConundrum : Problem<int, int>
{ {

View File

@@ -1,12 +1,4 @@
using System; namespace AdventOfCode.Problems.AOC2023.Day2;
using System.Collections.Generic;
using System.Linq;
using System.Reflection.PortableExecutable;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace AdventOfCode.Problems.AOC2023.Day2;
internal class CubeGame internal class CubeGame
{ {
@@ -54,15 +46,15 @@ internal record struct CubeRound(int Red, int Green, int Blue)
var count = int.Parse(info[0]); var count = int.Parse(info[0]);
switch (info[1]) switch (info[1])
{ {
case "red": case ['r', ..]:
r = count; r = count;
break; break;
case "green": case ['g', ..]:
g = count; g = count;
break; break;
case "blue": case ['b', ..]:
b = count; b = count;
break; break;
} }

View File

@@ -1,5 +1,4 @@
global using AdventOfCode.Runner;
global using AdventOfCode.Runner;
namespace AdventOfCode; namespace AdventOfCode;

View File

@@ -1,9 +1,11 @@
namespace AdventOfCode.Runner.Attributes; namespace AdventOfCode.Runner.Attributes;
public class ProblemInfoAttribute : Attribute public class ProblemInfoAttribute : Attribute
{ {
public int Day { get; init; } public int Day { get; init; }
public int Year { get; init; } public int Year { get; init; }
public string Name { get; init; } public string Name { get; init; }
public ProblemInfoAttribute(int year, int day, string name) public ProblemInfoAttribute(int year, int day, string name)
{ {
Year = year; Year = year;