Removed utils class, changed interface to abstract and incorparated util methods. Added Day 5
This commit is contained in:
parent
b41ac3c81b
commit
d86a65dec5
@ -8,7 +8,7 @@ string _demoData = @"2-4,6-8
|
|||||||
6-6,4-6
|
6-6,4-6
|
||||||
2-6,4-8";
|
2-6,4-8";
|
||||||
|
|
||||||
IAnswerable answerable = new Day04Part1();
|
Answerable answerable = new Day05Part2();
|
||||||
byte[] dataArray = File.ReadAllBytes(answerable.DefaultInputFile);
|
byte[] dataArray = File.ReadAllBytes(answerable.DefaultInputFile);
|
||||||
//dataArray = Encoding.UTF8.GetBytes(_demoData);
|
//dataArray = Encoding.UTF8.GetBytes(_demoData);
|
||||||
|
|
||||||
|
|||||||
@ -2,15 +2,15 @@
|
|||||||
{
|
{
|
||||||
using AdventOfCodeLibrary.Shared;
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
public class Day01Part1 : IAnswerable
|
public class Day01Part1 : Answerable
|
||||||
{
|
{
|
||||||
public int Year { get; set; } = 2022;
|
public override int Year { get; set; } = 2022;
|
||||||
public int Day { get; set; } = 1;
|
public override int Day { get; set; } = 1;
|
||||||
public int Part { get; set; } = 1;
|
public override int Part { get; set; } = 1;
|
||||||
|
|
||||||
public string GetAwner(byte[] data)
|
public override string GetAwner(byte[] data)
|
||||||
{
|
{
|
||||||
return ByteHelper.GetAsString(data).TrimEnd()
|
return GetAsString(data).TrimEnd()
|
||||||
.Split(Environment.NewLine + Environment.NewLine)
|
.Split(Environment.NewLine + Environment.NewLine)
|
||||||
.Select(s => s.Split(Environment.NewLine)
|
.Select(s => s.Split(Environment.NewLine)
|
||||||
.Sum(Convert.ToInt32))
|
.Sum(Convert.ToInt32))
|
||||||
|
|||||||
@ -2,16 +2,15 @@
|
|||||||
{
|
{
|
||||||
using AdventOfCodeLibrary.Shared;
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
public class Day01Part2 : IAnswerable
|
public class Day01Part2 : Answerable
|
||||||
{
|
{
|
||||||
public int Year { get; set; } = 2022;
|
public override int Year { get; set; } = 2022;
|
||||||
public int Day { get; set; } = 1;
|
public override int Day { get; set; } = 1;
|
||||||
public int Part { get; set; } = 2;
|
public override int Part { get; set; } = 2;
|
||||||
public string DefaultInputFile { get; set; } = "Day 01/day-01-input.txt";
|
|
||||||
|
|
||||||
public string GetAwner(byte[] data)
|
public override string GetAwner(byte[] data)
|
||||||
{
|
{
|
||||||
return ByteHelper.GetAsString(data).TrimEnd()
|
return GetAsString(data).TrimEnd()
|
||||||
.TrimEnd()
|
.TrimEnd()
|
||||||
.Split(Environment.NewLine + Environment.NewLine)
|
.Split(Environment.NewLine + Environment.NewLine)
|
||||||
.Select(s => s.Split(Environment.NewLine)
|
.Select(s => s.Split(Environment.NewLine)
|
||||||
|
|||||||
@ -3,16 +3,16 @@
|
|||||||
using AdventOfCodeLibrary._2022.Day02;
|
using AdventOfCodeLibrary._2022.Day02;
|
||||||
using AdventOfCodeLibrary.Shared;
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
public class Day02Part1 : IAnswerable
|
public class Day02Part1 : Answerable
|
||||||
{
|
{
|
||||||
public int Year { get; set; } = 2022;
|
public override int Year { get; set; } = 2022;
|
||||||
public int Day { get; set; } = 2;
|
public override int Day { get; set; } = 2;
|
||||||
public int Part { get; set; } = 1;
|
public override int Part { get; set; } = 1;
|
||||||
|
|
||||||
public string GetAwner(byte[] data)
|
public override string GetAwner(byte[] data)
|
||||||
{
|
{
|
||||||
GameRules.BuildScoreDic();
|
GameRules.BuildScoreDic();
|
||||||
return ByteHelper.GetAsStringArray(data)
|
return GetAsStringArray(data)
|
||||||
.Select(GameRules.GetScore)
|
.Select(GameRules.GetScore)
|
||||||
.Sum()
|
.Sum()
|
||||||
.ToString();
|
.ToString();
|
||||||
|
|||||||
@ -3,16 +3,16 @@
|
|||||||
using AdventOfCodeLibrary._2022.Day02;
|
using AdventOfCodeLibrary._2022.Day02;
|
||||||
using AdventOfCodeLibrary.Shared;
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
public class Day02Part2 : IAnswerable
|
public class Day02Part2 : Answerable
|
||||||
{
|
{
|
||||||
public int Year { get; set; } = 2022;
|
public override int Year { get; set; } = 2022;
|
||||||
public int Day { get; set; } = 2;
|
public override int Day { get; set; } = 2;
|
||||||
public int Part { get; set; } = 2;
|
public override int Part { get; set; } = 2;
|
||||||
|
|
||||||
public string GetAwner(byte[] data)
|
public override string GetAwner(byte[] data)
|
||||||
{
|
{
|
||||||
GameRules.BuildWinDrawLoseTable();
|
GameRules.BuildWinDrawLoseTable();
|
||||||
return ByteHelper.GetAsStringArray(data)
|
return GetAsStringArray(data)
|
||||||
.Select(GameRules.GetScore)
|
.Select(GameRules.GetScore)
|
||||||
.Sum()
|
.Sum()
|
||||||
.ToString();
|
.ToString();
|
||||||
|
|||||||
@ -2,15 +2,15 @@
|
|||||||
{
|
{
|
||||||
using AdventOfCodeLibrary.Shared;
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
public class Day03Part1 : IAnswerable
|
public class Day03Part1 : Answerable
|
||||||
{
|
{
|
||||||
public int Year { get; set; } = 2022;
|
public override int Year { get; set; } = 2022;
|
||||||
public int Day { get; set; } = 3;
|
public override int Day { get; set; } = 3;
|
||||||
public int Part { get; set; } = 1;
|
public override int Part { get; set; } = 1;
|
||||||
|
|
||||||
public string GetAwner(byte[] data)
|
public override string GetAwner(byte[] data)
|
||||||
{
|
{
|
||||||
string[] rucksackData = ByteHelper.GetAsStringArray(data);
|
string[] rucksackData = GetAsStringArray(data);
|
||||||
int priorityCount = 0;
|
int priorityCount = 0;
|
||||||
|
|
||||||
// go throu each ruchsack
|
// go throu each ruchsack
|
||||||
|
|||||||
@ -2,15 +2,15 @@
|
|||||||
{
|
{
|
||||||
using AdventOfCodeLibrary.Shared;
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
public class Day03Part2 : IAnswerable
|
public class Day03Part2 : Answerable
|
||||||
{
|
{
|
||||||
public int Year { get; set; } = 2022;
|
public override int Year { get; set; } = 2022;
|
||||||
public int Day { get; set; } = 3;
|
public override int Day { get; set; } = 3;
|
||||||
public int Part { get; set; } = 2;
|
public override int Part { get; set; } = 2;
|
||||||
|
|
||||||
public string GetAwner(byte[] data)
|
public override string GetAwner(byte[] data)
|
||||||
{
|
{
|
||||||
string[] rucksackData = ByteHelper.GetAsStringArray(data);
|
string[] rucksackData = GetAsStringArray(data);
|
||||||
int priorityCount = 0;
|
int priorityCount = 0;
|
||||||
|
|
||||||
// go throu each ruchsack
|
// go throu each ruchsack
|
||||||
|
|||||||
@ -2,15 +2,15 @@
|
|||||||
{
|
{
|
||||||
using AdventOfCodeLibrary.Shared;
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
public class Day04Part1 : IAnswerable
|
public class Day04Part1 : Answerable
|
||||||
{
|
{
|
||||||
public int Year { get; set; } = 2022;
|
public override int Year { get; set; } = 2022;
|
||||||
public int Day { get; set; } = 4;
|
public override int Day { get; set; } = 4;
|
||||||
public int Part { get; set; } = 1;
|
public override int Part { get; set; } = 1;
|
||||||
|
|
||||||
public string GetAwner(byte[] data)
|
public override string GetAwner(byte[] data)
|
||||||
{
|
{
|
||||||
return ByteHelper.GetAsStringArray(data)
|
return GetAsStringArray(data)
|
||||||
.Where(line => !string.IsNullOrWhiteSpace(line))
|
.Where(line => !string.IsNullOrWhiteSpace(line))
|
||||||
.Select(line =>
|
.Select(line =>
|
||||||
line.Split(',')
|
line.Split(',')
|
||||||
|
|||||||
@ -2,15 +2,15 @@
|
|||||||
{
|
{
|
||||||
using AdventOfCodeLibrary.Shared;
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
public class Day04Part2 : IAnswerable
|
public class Day04Part2 : Answerable
|
||||||
{
|
{
|
||||||
public int Year { get; set; } = 2022;
|
public override int Year { get; set; } = 2022;
|
||||||
public int Day { get; set; } = 4;
|
public override int Day { get; set; } = 4;
|
||||||
public int Part { get; set; } = 2;
|
public override int Part { get; set; } = 2;
|
||||||
|
|
||||||
public string GetAwner(byte[] data)
|
public override string GetAwner(byte[] data)
|
||||||
{
|
{
|
||||||
return ByteHelper.GetAsStringArray(data)
|
return GetAsStringArray(data)
|
||||||
.Where(line => !string.IsNullOrWhiteSpace(line))
|
.Where(line => !string.IsNullOrWhiteSpace(line))
|
||||||
.Select(line =>
|
.Select(line =>
|
||||||
line.Split(',')
|
line.Split(',')
|
||||||
|
|||||||
84
Advent Of Code Library/2022/Day 05/CraneWork.cs
Normal file
84
Advent Of Code Library/2022/Day 05/CraneWork.cs
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace AdventOfCodeLibrary._2022.Day_05
|
||||||
|
{
|
||||||
|
internal class CraneWork
|
||||||
|
{
|
||||||
|
private List<Stack<char>> containerStacks = new List<Stack<char>>();
|
||||||
|
|
||||||
|
internal void ReadInitialContainerArrangement(string[] data)
|
||||||
|
{
|
||||||
|
// get all the existing stacks
|
||||||
|
string stackNumbers = data[data.Length - 1];
|
||||||
|
string[] containerStacksWithoutNumbser = data.Take(data.Length - 1).ToArray();
|
||||||
|
for (int stackIndex = 0; stackIndex < stackNumbers.Length; stackIndex++)
|
||||||
|
{
|
||||||
|
if (stackNumbers[stackIndex] == ' ')
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Stack<char> stack = new Stack<char>();
|
||||||
|
for (int containerIndex = containerStacksWithoutNumbser.Length - 1; containerIndex >= 0; containerIndex--)
|
||||||
|
{
|
||||||
|
char container = containerStacksWithoutNumbser[containerIndex][stackIndex];
|
||||||
|
if (container != ' ')
|
||||||
|
{
|
||||||
|
stack.Push(container);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
containerStacks.Add(stack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void DoCraneWork(string craneInstruction, bool is9000Crane = true)
|
||||||
|
{
|
||||||
|
string[] instructions = craneInstruction.Split(' ');
|
||||||
|
int numberToMove = Convert.ToInt32(instructions[1]);
|
||||||
|
|
||||||
|
// remove one because zero based index
|
||||||
|
int fromContainerStackIndex = Convert.ToInt32(instructions[3]) - 1;
|
||||||
|
int toContainerStackIndex = Convert.ToInt32(instructions[5]) - 1;
|
||||||
|
Stack<char> storage = new Stack<char>();
|
||||||
|
|
||||||
|
for (int toMove = numberToMove; toMove > 0; toMove--)
|
||||||
|
{
|
||||||
|
if (is9000Crane)
|
||||||
|
{
|
||||||
|
containerStacks[toContainerStackIndex].Push(containerStacks[fromContainerStackIndex].Pop());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// make a stack to store the containers in order
|
||||||
|
storage.Push(containerStacks[fromContainerStackIndex].Pop());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is9000Crane)
|
||||||
|
{
|
||||||
|
// move the stored conainers to the new pile
|
||||||
|
for (int toMove = numberToMove; toMove > 0; toMove--)
|
||||||
|
{
|
||||||
|
containerStacks[toContainerStackIndex].Push(storage.Pop());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal string GetTopContainers()
|
||||||
|
{
|
||||||
|
string result = string.Empty;
|
||||||
|
foreach (char topContainer in containerStacks.Select(s => s.Peek()))
|
||||||
|
{
|
||||||
|
result += topContainer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Advent Of Code Library/2022/Day 05/Day05Part1.cs
Normal file
25
Advent Of Code Library/2022/Day 05/Day05Part1.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
namespace AdventOfCodeLibrary._2022
|
||||||
|
{
|
||||||
|
using AdventOfCodeLibrary._2022.Day_05;
|
||||||
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
|
public class Day05Part1 : Answerable
|
||||||
|
{
|
||||||
|
public override int Year { get; set; } = 2022;
|
||||||
|
public override int Day { get; set; } = 5;
|
||||||
|
public override int Part { get; set; } = 1;
|
||||||
|
|
||||||
|
public override string GetAwner(byte[] data)
|
||||||
|
{
|
||||||
|
string[] initAndInstructions = GetAsString(data).Split(Environment.NewLine + Environment.NewLine);
|
||||||
|
CraneWork work = new CraneWork();
|
||||||
|
work.ReadInitialContainerArrangement(initAndInstructions[0].Split(Environment.NewLine));
|
||||||
|
foreach (string instruction in initAndInstructions[1].Split(Environment.NewLine))
|
||||||
|
{
|
||||||
|
work.DoCraneWork(instruction);
|
||||||
|
}
|
||||||
|
|
||||||
|
return work.GetTopContainers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
Advent Of Code Library/2022/Day 05/Day05Part2.cs
Normal file
25
Advent Of Code Library/2022/Day 05/Day05Part2.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
namespace AdventOfCodeLibrary._2022
|
||||||
|
{
|
||||||
|
using AdventOfCodeLibrary._2022.Day_05;
|
||||||
|
using AdventOfCodeLibrary.Shared;
|
||||||
|
|
||||||
|
public class Day05Part2 : Answerable
|
||||||
|
{
|
||||||
|
public override int Year { get; set; } = 2022;
|
||||||
|
public override int Day { get; set; } = 5;
|
||||||
|
public override int Part { get; set; } = 2;
|
||||||
|
|
||||||
|
public override string GetAwner(byte[] data)
|
||||||
|
{
|
||||||
|
string[] initAndInstructions = GetAsString(data).Split(Environment.NewLine + Environment.NewLine);
|
||||||
|
CraneWork work = new CraneWork();
|
||||||
|
work.ReadInitialContainerArrangement(initAndInstructions[0].Split(Environment.NewLine));
|
||||||
|
foreach (string instruction in initAndInstructions[1].Split(Environment.NewLine))
|
||||||
|
{
|
||||||
|
work.DoCraneWork(instruction, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return work.GetTopContainers();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
513
Advent Of Code Library/2022/Day 05/day-05-input.txt
Normal file
513
Advent Of Code Library/2022/Day 05/day-05-input.txt
Normal file
@ -0,0 +1,513 @@
|
|||||||
|
[M] [B] [N]
|
||||||
|
[T] [H] [V] [Q] [H]
|
||||||
|
[Q] [N] [H] [W] [T] [Q]
|
||||||
|
[V] [P] [F] [Q] [P] [C] [R]
|
||||||
|
[C] [D] [T] [N] [N] [L] [S] [J]
|
||||||
|
[D] [V] [W] [R] [M] [G] [R] [N] [D]
|
||||||
|
[S] [F] [Q] [Q] [F] [F] [F] [Z] [S]
|
||||||
|
[N] [M] [F] [D] [R] [C] [W] [T] [M]
|
||||||
|
1 2 3 4 5 6 7 8 9
|
||||||
|
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 1 from 2 to 7
|
||||||
|
move 6 from 9 to 8
|
||||||
|
move 1 from 9 to 1
|
||||||
|
move 1 from 9 to 1
|
||||||
|
move 3 from 3 to 6
|
||||||
|
move 3 from 3 to 9
|
||||||
|
move 1 from 9 to 2
|
||||||
|
move 5 from 7 to 9
|
||||||
|
move 9 from 1 to 6
|
||||||
|
move 3 from 4 to 9
|
||||||
|
move 2 from 9 to 2
|
||||||
|
move 1 from 4 to 2
|
||||||
|
move 1 from 3 to 9
|
||||||
|
move 8 from 9 to 4
|
||||||
|
move 14 from 6 to 7
|
||||||
|
move 1 from 3 to 2
|
||||||
|
move 5 from 4 to 2
|
||||||
|
move 5 from 5 to 7
|
||||||
|
move 4 from 2 to 1
|
||||||
|
move 2 from 4 to 9
|
||||||
|
move 1 from 4 to 3
|
||||||
|
move 3 from 5 to 7
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 2 from 8 to 7
|
||||||
|
move 2 from 1 to 2
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 2 from 1 to 3
|
||||||
|
move 5 from 6 to 5
|
||||||
|
move 4 from 5 to 7
|
||||||
|
move 3 from 8 to 4
|
||||||
|
move 20 from 7 to 1
|
||||||
|
move 11 from 7 to 5
|
||||||
|
move 1 from 6 to 9
|
||||||
|
move 3 from 9 to 2
|
||||||
|
move 12 from 1 to 9
|
||||||
|
move 2 from 8 to 3
|
||||||
|
move 4 from 2 to 8
|
||||||
|
move 8 from 2 to 1
|
||||||
|
move 4 from 8 to 9
|
||||||
|
move 1 from 2 to 5
|
||||||
|
move 12 from 9 to 7
|
||||||
|
move 4 from 4 to 9
|
||||||
|
move 4 from 9 to 5
|
||||||
|
move 13 from 5 to 4
|
||||||
|
move 4 from 4 to 7
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 2 from 9 to 5
|
||||||
|
move 9 from 1 to 2
|
||||||
|
move 1 from 8 to 3
|
||||||
|
move 5 from 4 to 2
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 7 from 2 to 8
|
||||||
|
move 6 from 1 to 6
|
||||||
|
move 6 from 8 to 7
|
||||||
|
move 6 from 2 to 1
|
||||||
|
move 3 from 9 to 3
|
||||||
|
move 7 from 3 to 7
|
||||||
|
move 4 from 4 to 9
|
||||||
|
move 1 from 8 to 9
|
||||||
|
move 1 from 3 to 9
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 1 from 9 to 6
|
||||||
|
move 5 from 1 to 9
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 2 from 9 to 1
|
||||||
|
move 8 from 6 to 7
|
||||||
|
move 4 from 9 to 7
|
||||||
|
move 2 from 5 to 2
|
||||||
|
move 2 from 1 to 9
|
||||||
|
move 14 from 7 to 4
|
||||||
|
move 22 from 7 to 2
|
||||||
|
move 2 from 7 to 4
|
||||||
|
move 3 from 7 to 5
|
||||||
|
move 9 from 4 to 7
|
||||||
|
move 6 from 2 to 4
|
||||||
|
move 8 from 4 to 3
|
||||||
|
move 14 from 2 to 9
|
||||||
|
move 2 from 3 to 9
|
||||||
|
move 3 from 2 to 9
|
||||||
|
move 4 from 4 to 2
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 5 from 7 to 8
|
||||||
|
move 1 from 1 to 3
|
||||||
|
move 4 from 5 to 2
|
||||||
|
move 6 from 3 to 9
|
||||||
|
move 1 from 3 to 4
|
||||||
|
move 4 from 8 to 9
|
||||||
|
move 2 from 4 to 6
|
||||||
|
move 4 from 5 to 3
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 3 from 3 to 1
|
||||||
|
move 33 from 9 to 5
|
||||||
|
move 5 from 2 to 1
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 18 from 5 to 1
|
||||||
|
move 1 from 2 to 8
|
||||||
|
move 6 from 5 to 4
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 4 from 1 to 2
|
||||||
|
move 19 from 1 to 2
|
||||||
|
move 4 from 6 to 8
|
||||||
|
move 4 from 1 to 8
|
||||||
|
move 14 from 2 to 9
|
||||||
|
move 5 from 2 to 4
|
||||||
|
move 1 from 8 to 2
|
||||||
|
move 8 from 2 to 5
|
||||||
|
move 5 from 8 to 4
|
||||||
|
move 4 from 9 to 7
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 16 from 5 to 4
|
||||||
|
move 15 from 4 to 5
|
||||||
|
move 1 from 9 to 5
|
||||||
|
move 5 from 7 to 6
|
||||||
|
move 2 from 7 to 6
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 7 from 6 to 7
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 12 from 5 to 7
|
||||||
|
move 7 from 5 to 9
|
||||||
|
move 12 from 7 to 2
|
||||||
|
move 1 from 7 to 4
|
||||||
|
move 7 from 4 to 7
|
||||||
|
move 2 from 9 to 4
|
||||||
|
move 5 from 4 to 9
|
||||||
|
move 8 from 2 to 3
|
||||||
|
move 4 from 2 to 4
|
||||||
|
move 9 from 4 to 8
|
||||||
|
move 6 from 3 to 5
|
||||||
|
move 8 from 7 to 3
|
||||||
|
move 1 from 4 to 3
|
||||||
|
move 7 from 8 to 9
|
||||||
|
move 4 from 5 to 4
|
||||||
|
move 6 from 3 to 1
|
||||||
|
move 4 from 3 to 4
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 6 from 4 to 9
|
||||||
|
move 1 from 6 to 5
|
||||||
|
move 17 from 9 to 4
|
||||||
|
move 3 from 7 to 3
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 2 from 5 to 3
|
||||||
|
move 2 from 1 to 3
|
||||||
|
move 2 from 8 to 9
|
||||||
|
move 1 from 5 to 1
|
||||||
|
move 14 from 4 to 5
|
||||||
|
move 2 from 3 to 2
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 10 from 9 to 4
|
||||||
|
move 12 from 9 to 4
|
||||||
|
move 9 from 4 to 5
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 13 from 5 to 9
|
||||||
|
move 2 from 5 to 1
|
||||||
|
move 1 from 2 to 9
|
||||||
|
move 3 from 4 to 2
|
||||||
|
move 12 from 4 to 7
|
||||||
|
move 8 from 5 to 7
|
||||||
|
move 1 from 1 to 9
|
||||||
|
move 1 from 6 to 4
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 1 from 4 to 8
|
||||||
|
move 5 from 3 to 4
|
||||||
|
move 10 from 9 to 6
|
||||||
|
move 3 from 6 to 2
|
||||||
|
move 7 from 6 to 5
|
||||||
|
move 6 from 5 to 4
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 2 from 7 to 2
|
||||||
|
move 5 from 4 to 9
|
||||||
|
move 2 from 5 to 8
|
||||||
|
move 1 from 1 to 3
|
||||||
|
move 2 from 1 to 7
|
||||||
|
move 6 from 7 to 9
|
||||||
|
move 9 from 9 to 8
|
||||||
|
move 1 from 1 to 3
|
||||||
|
move 4 from 2 to 7
|
||||||
|
move 11 from 7 to 3
|
||||||
|
move 11 from 8 to 6
|
||||||
|
move 7 from 3 to 1
|
||||||
|
move 4 from 7 to 2
|
||||||
|
move 3 from 2 to 9
|
||||||
|
move 8 from 1 to 5
|
||||||
|
move 2 from 7 to 5
|
||||||
|
move 2 from 2 to 9
|
||||||
|
move 2 from 3 to 9
|
||||||
|
move 11 from 4 to 7
|
||||||
|
move 7 from 9 to 5
|
||||||
|
move 6 from 6 to 5
|
||||||
|
move 2 from 2 to 9
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 6 from 9 to 4
|
||||||
|
move 3 from 9 to 1
|
||||||
|
move 4 from 3 to 5
|
||||||
|
move 6 from 7 to 1
|
||||||
|
move 2 from 6 to 3
|
||||||
|
move 2 from 9 to 2
|
||||||
|
move 3 from 3 to 2
|
||||||
|
move 3 from 6 to 8
|
||||||
|
move 2 from 7 to 5
|
||||||
|
move 20 from 5 to 6
|
||||||
|
move 8 from 5 to 1
|
||||||
|
move 1 from 5 to 9
|
||||||
|
move 2 from 8 to 4
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 16 from 1 to 8
|
||||||
|
move 8 from 8 to 9
|
||||||
|
move 4 from 2 to 4
|
||||||
|
move 1 from 1 to 5
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 3 from 8 to 4
|
||||||
|
move 14 from 4 to 6
|
||||||
|
move 5 from 8 to 7
|
||||||
|
move 6 from 7 to 8
|
||||||
|
move 29 from 6 to 2
|
||||||
|
move 3 from 9 to 8
|
||||||
|
move 21 from 2 to 3
|
||||||
|
move 1 from 8 to 3
|
||||||
|
move 6 from 9 to 4
|
||||||
|
move 8 from 3 to 5
|
||||||
|
move 7 from 8 to 4
|
||||||
|
move 7 from 3 to 9
|
||||||
|
move 3 from 7 to 2
|
||||||
|
move 12 from 4 to 8
|
||||||
|
move 2 from 3 to 1
|
||||||
|
move 2 from 9 to 1
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 1 from 6 to 3
|
||||||
|
move 3 from 1 to 8
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 4 from 6 to 1
|
||||||
|
move 5 from 2 to 7
|
||||||
|
move 1 from 1 to 2
|
||||||
|
move 5 from 1 to 2
|
||||||
|
move 2 from 8 to 1
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 9 from 8 to 4
|
||||||
|
move 3 from 7 to 9
|
||||||
|
move 7 from 5 to 7
|
||||||
|
move 2 from 5 to 9
|
||||||
|
move 4 from 9 to 2
|
||||||
|
move 3 from 3 to 2
|
||||||
|
move 5 from 2 to 7
|
||||||
|
move 2 from 8 to 2
|
||||||
|
move 2 from 7 to 3
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 2 from 1 to 2
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 1 from 8 to 1
|
||||||
|
move 12 from 7 to 1
|
||||||
|
move 5 from 2 to 7
|
||||||
|
move 7 from 4 to 2
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 5 from 3 to 8
|
||||||
|
move 7 from 1 to 9
|
||||||
|
move 4 from 7 to 1
|
||||||
|
move 7 from 1 to 5
|
||||||
|
move 12 from 9 to 2
|
||||||
|
move 27 from 2 to 4
|
||||||
|
move 3 from 8 to 9
|
||||||
|
move 6 from 2 to 5
|
||||||
|
move 6 from 1 to 8
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 9 from 5 to 2
|
||||||
|
move 3 from 9 to 2
|
||||||
|
move 13 from 4 to 5
|
||||||
|
move 10 from 2 to 7
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 11 from 5 to 7
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 13 from 4 to 3
|
||||||
|
move 23 from 7 to 4
|
||||||
|
move 1 from 6 to 9
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 7 from 3 to 5
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 19 from 4 to 1
|
||||||
|
move 2 from 4 to 1
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 1 from 5 to 7
|
||||||
|
move 11 from 5 to 1
|
||||||
|
move 2 from 5 to 4
|
||||||
|
move 2 from 6 to 9
|
||||||
|
move 3 from 8 to 2
|
||||||
|
move 2 from 8 to 1
|
||||||
|
move 3 from 2 to 1
|
||||||
|
move 1 from 9 to 5
|
||||||
|
move 6 from 1 to 3
|
||||||
|
move 1 from 9 to 7
|
||||||
|
move 2 from 7 to 5
|
||||||
|
move 2 from 8 to 6
|
||||||
|
move 1 from 3 to 2
|
||||||
|
move 2 from 8 to 5
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 3 from 4 to 1
|
||||||
|
move 3 from 5 to 1
|
||||||
|
move 2 from 5 to 1
|
||||||
|
move 2 from 6 to 9
|
||||||
|
move 1 from 9 to 6
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 8 from 1 to 6
|
||||||
|
move 7 from 1 to 8
|
||||||
|
move 9 from 1 to 6
|
||||||
|
move 1 from 5 to 3
|
||||||
|
move 3 from 8 to 4
|
||||||
|
move 11 from 3 to 4
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 10 from 6 to 8
|
||||||
|
move 13 from 1 to 6
|
||||||
|
move 3 from 4 to 5
|
||||||
|
move 7 from 8 to 6
|
||||||
|
move 3 from 8 to 5
|
||||||
|
move 6 from 5 to 3
|
||||||
|
move 22 from 6 to 9
|
||||||
|
move 4 from 3 to 6
|
||||||
|
move 4 from 9 to 5
|
||||||
|
move 1 from 1 to 5
|
||||||
|
move 2 from 3 to 4
|
||||||
|
move 2 from 1 to 5
|
||||||
|
move 1 from 9 to 2
|
||||||
|
move 5 from 8 to 3
|
||||||
|
move 2 from 9 to 2
|
||||||
|
move 11 from 6 to 9
|
||||||
|
move 3 from 2 to 7
|
||||||
|
move 1 from 6 to 7
|
||||||
|
move 12 from 9 to 8
|
||||||
|
move 4 from 7 to 1
|
||||||
|
move 12 from 4 to 8
|
||||||
|
move 2 from 4 to 7
|
||||||
|
move 1 from 1 to 8
|
||||||
|
move 1 from 5 to 1
|
||||||
|
move 19 from 8 to 4
|
||||||
|
move 4 from 5 to 1
|
||||||
|
move 1 from 7 to 4
|
||||||
|
move 1 from 7 to 1
|
||||||
|
move 3 from 3 to 4
|
||||||
|
move 2 from 8 to 4
|
||||||
|
move 1 from 5 to 7
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 8 from 1 to 8
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 1 from 3 to 9
|
||||||
|
move 1 from 3 to 5
|
||||||
|
move 1 from 5 to 2
|
||||||
|
move 7 from 8 to 7
|
||||||
|
move 16 from 4 to 7
|
||||||
|
move 1 from 7 to 4
|
||||||
|
move 3 from 8 to 2
|
||||||
|
move 14 from 7 to 4
|
||||||
|
move 1 from 5 to 8
|
||||||
|
move 5 from 7 to 5
|
||||||
|
move 16 from 4 to 5
|
||||||
|
move 3 from 5 to 4
|
||||||
|
move 3 from 2 to 1
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 11 from 4 to 2
|
||||||
|
move 3 from 8 to 6
|
||||||
|
move 2 from 1 to 8
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 18 from 5 to 1
|
||||||
|
move 1 from 8 to 7
|
||||||
|
move 3 from 7 to 9
|
||||||
|
move 18 from 9 to 3
|
||||||
|
move 3 from 6 to 9
|
||||||
|
move 7 from 1 to 6
|
||||||
|
move 1 from 8 to 4
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 3 from 6 to 4
|
||||||
|
move 5 from 9 to 2
|
||||||
|
move 2 from 4 to 7
|
||||||
|
move 7 from 2 to 8
|
||||||
|
move 1 from 7 to 3
|
||||||
|
move 2 from 6 to 8
|
||||||
|
move 1 from 9 to 5
|
||||||
|
move 1 from 6 to 8
|
||||||
|
move 1 from 4 to 8
|
||||||
|
move 1 from 5 to 3
|
||||||
|
move 1 from 7 to 5
|
||||||
|
move 8 from 8 to 7
|
||||||
|
move 10 from 2 to 6
|
||||||
|
move 1 from 9 to 3
|
||||||
|
move 6 from 6 to 2
|
||||||
|
move 5 from 6 to 2
|
||||||
|
move 7 from 2 to 7
|
||||||
|
move 12 from 1 to 6
|
||||||
|
move 2 from 2 to 1
|
||||||
|
move 1 from 2 to 5
|
||||||
|
move 4 from 7 to 6
|
||||||
|
move 12 from 3 to 1
|
||||||
|
move 2 from 7 to 2
|
||||||
|
move 9 from 3 to 8
|
||||||
|
move 1 from 2 to 6
|
||||||
|
move 1 from 5 to 4
|
||||||
|
move 9 from 6 to 5
|
||||||
|
move 1 from 7 to 6
|
||||||
|
move 1 from 4 to 9
|
||||||
|
move 9 from 6 to 7
|
||||||
|
move 7 from 8 to 3
|
||||||
|
move 6 from 3 to 1
|
||||||
|
move 4 from 8 to 3
|
||||||
|
move 5 from 3 to 1
|
||||||
|
move 1 from 9 to 8
|
||||||
|
move 2 from 8 to 9
|
||||||
|
move 5 from 5 to 7
|
||||||
|
move 14 from 7 to 8
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 2 from 2 to 1
|
||||||
|
move 3 from 5 to 3
|
||||||
|
move 2 from 3 to 1
|
||||||
|
move 1 from 4 to 6
|
||||||
|
move 6 from 8 to 6
|
||||||
|
move 6 from 8 to 3
|
||||||
|
move 3 from 6 to 1
|
||||||
|
move 2 from 8 to 9
|
||||||
|
move 19 from 1 to 6
|
||||||
|
move 3 from 9 to 3
|
||||||
|
move 6 from 3 to 4
|
||||||
|
move 6 from 6 to 2
|
||||||
|
move 4 from 3 to 9
|
||||||
|
move 1 from 7 to 9
|
||||||
|
move 2 from 5 to 7
|
||||||
|
move 5 from 9 to 6
|
||||||
|
move 6 from 7 to 2
|
||||||
|
move 11 from 2 to 5
|
||||||
|
move 2 from 7 to 4
|
||||||
|
move 4 from 4 to 3
|
||||||
|
move 2 from 4 to 8
|
||||||
|
move 12 from 1 to 2
|
||||||
|
move 1 from 8 to 2
|
||||||
|
move 8 from 5 to 7
|
||||||
|
move 2 from 4 to 9
|
||||||
|
move 2 from 7 to 1
|
||||||
|
move 4 from 2 to 3
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 1 from 1 to 5
|
||||||
|
move 2 from 9 to 1
|
||||||
|
move 2 from 7 to 3
|
||||||
|
move 2 from 5 to 2
|
||||||
|
move 1 from 5 to 7
|
||||||
|
move 2 from 7 to 8
|
||||||
|
move 1 from 5 to 7
|
||||||
|
move 5 from 3 to 4
|
||||||
|
move 3 from 1 to 7
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 15 from 6 to 1
|
||||||
|
move 4 from 4 to 1
|
||||||
|
move 4 from 2 to 3
|
||||||
|
move 8 from 3 to 2
|
||||||
|
move 5 from 2 to 4
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 1 from 8 to 9
|
||||||
|
move 1 from 3 to 1
|
||||||
|
move 3 from 7 to 3
|
||||||
|
move 5 from 7 to 6
|
||||||
|
move 4 from 2 to 9
|
||||||
|
move 6 from 2 to 6
|
||||||
|
move 4 from 9 to 6
|
||||||
|
move 12 from 1 to 5
|
||||||
|
move 6 from 4 to 1
|
||||||
|
move 1 from 3 to 6
|
||||||
|
move 4 from 5 to 8
|
||||||
|
move 7 from 5 to 3
|
||||||
|
move 3 from 8 to 2
|
||||||
|
move 1 from 2 to 3
|
||||||
|
move 1 from 9 to 5
|
||||||
|
move 1 from 4 to 5
|
||||||
|
move 1 from 8 to 5
|
||||||
|
move 8 from 6 to 9
|
||||||
|
move 10 from 1 to 4
|
||||||
|
move 3 from 6 to 1
|
||||||
|
move 9 from 3 to 6
|
||||||
|
move 1 from 3 to 8
|
||||||
|
move 1 from 2 to 4
|
||||||
|
move 6 from 9 to 1
|
||||||
|
move 1 from 1 to 4
|
||||||
|
move 10 from 1 to 6
|
||||||
|
move 1 from 8 to 6
|
||||||
|
move 13 from 6 to 7
|
||||||
|
move 1 from 2 to 1
|
||||||
|
move 1 from 9 to 6
|
||||||
|
move 9 from 7 to 5
|
||||||
|
move 1 from 9 to 4
|
||||||
|
move 3 from 7 to 1
|
||||||
|
move 3 from 5 to 6
|
||||||
|
move 10 from 4 to 7
|
||||||
|
move 5 from 6 to 5
|
||||||
|
move 3 from 4 to 5
|
||||||
|
move 13 from 6 to 9
|
||||||
|
move 7 from 5 to 3
|
||||||
|
move 6 from 3 to 2
|
||||||
|
move 5 from 6 to 4
|
||||||
|
move 4 from 2 to 8
|
||||||
26
Advent Of Code Library/Shared/Answerable.cs
Normal file
26
Advent Of Code Library/Shared/Answerable.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace AdventOfCodeLibrary.Shared
|
||||||
|
{
|
||||||
|
public abstract class Answerable
|
||||||
|
{
|
||||||
|
public abstract int Year { get; set; }
|
||||||
|
|
||||||
|
public abstract int Day { get; set; }
|
||||||
|
|
||||||
|
public abstract int Part { get; set; }
|
||||||
|
|
||||||
|
public string DefaultInputFile {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return $"../../../../Advent Of Code Library/{Year}/Day {Day:00}/day-{Day:00}-input.txt";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract string GetAwner(byte[] data);
|
||||||
|
|
||||||
|
internal static string GetAsString(byte[] bytes) => Encoding.UTF8.GetString(bytes);
|
||||||
|
|
||||||
|
internal static string[] GetAsStringArray(byte[] bytes) => Encoding.UTF8.GetString(bytes).Split(Environment.NewLine);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -4,23 +4,23 @@ namespace AdventOfCodeLibrary.Shared
|
|||||||
{
|
{
|
||||||
public class AnswerableListBuilder
|
public class AnswerableListBuilder
|
||||||
{
|
{
|
||||||
public static IEnumerable<IAnswerable> AnswerableList()
|
public static IEnumerable<Answerable> AnswerableList()
|
||||||
{
|
{
|
||||||
Type type = typeof(IAnswerable);
|
Type type = typeof(Answerable);
|
||||||
IEnumerable<IAnswerable?> instances =
|
IEnumerable<Answerable?> instances =
|
||||||
Assembly.GetExecutingAssembly().GetTypes()
|
Assembly.GetExecutingAssembly().GetTypes()
|
||||||
.Where(t =>
|
.Where(t =>
|
||||||
t.GetInterfaces().Contains(type) &&
|
t.GetInterfaces().Contains(type) &&
|
||||||
t.GetConstructor(Type.EmptyTypes) != null
|
t.GetConstructor(Type.EmptyTypes) != null
|
||||||
)
|
)
|
||||||
.Select(t => Activator.CreateInstance(t) as IAnswerable)
|
.Select(t => Activator.CreateInstance(t) as Answerable)
|
||||||
.Where(i => i != null);
|
.Where(i => i != null);
|
||||||
|
|
||||||
// try to filter null
|
// try to filter null
|
||||||
var noneNull = instances.Where(i => i != null);
|
var noneNull = instances.Where(i => i != null);
|
||||||
|
|
||||||
|
|
||||||
return new List<IAnswerable>();
|
return new List<Answerable>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +0,0 @@
|
|||||||
namespace AdventOfCodeLibrary.Shared
|
|
||||||
{
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
public class ByteHelper
|
|
||||||
{
|
|
||||||
public static string GetAsString(byte[] bytes) => Encoding.UTF8.GetString(bytes);
|
|
||||||
|
|
||||||
public static string[] GetAsStringArray(byte[] bytes) => Encoding.UTF8.GetString(bytes).Split(Environment.NewLine);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,20 +0,0 @@
|
|||||||
namespace AdventOfCodeLibrary.Shared
|
|
||||||
{
|
|
||||||
public interface IAnswerable
|
|
||||||
{
|
|
||||||
int Year { get; set; }
|
|
||||||
|
|
||||||
int Day { get; set; }
|
|
||||||
|
|
||||||
int Part { get; set; }
|
|
||||||
|
|
||||||
string DefaultInputFile {
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return $"../../../../Advent Of Code Library/{Year}/Day {Day:00}/day-{Day:00}-input.txt";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
string GetAwner(byte[] data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue
Block a user