Code formatting and warning fixing.
This commit is contained in:
@@ -10,8 +10,8 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="xunit" Version="2.6.3" />
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0"/>
|
||||
<PackageReference Include="xunit" Version="2.6.3"/>
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.5">
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
@@ -19,7 +19,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\AdventOfCode2023\AdventOfCode2023.csproj" />
|
||||
<ProjectReference Include="..\AdventOfCode2023\AdventOfCode2023.csproj"/>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -5,24 +5,24 @@ public class Day01_Tests
|
||||
[Fact]
|
||||
public void ResolvePart1__Example()
|
||||
{
|
||||
var day = new Day01();
|
||||
Day01? day = new Day01();
|
||||
|
||||
string result = day.ResolvePart1(new[] {
|
||||
string result = day.ResolvePart1([
|
||||
"1abc2",
|
||||
"pqr3stu8vwx",
|
||||
"a1b2c3d4e5f",
|
||||
"treb7uchet",
|
||||
});
|
||||
]);
|
||||
|
||||
Assert.Equal("142", result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart2__Example()
|
||||
{
|
||||
var day = new Day01();
|
||||
Day01? day = new Day01();
|
||||
|
||||
string result = day.ResolvePart2(new[] {
|
||||
string result = day.ResolvePart2([
|
||||
"two1nine",
|
||||
"eightwothree",
|
||||
"abcone2threexyz",
|
||||
@@ -30,7 +30,7 @@ public class Day01_Tests
|
||||
"4nineeightseven2",
|
||||
"zoneight234",
|
||||
"7pqrstsixteen",
|
||||
});
|
||||
]);
|
||||
|
||||
Assert.Equal("281", result);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Day02_Tests
|
||||
Assert.Equal(0, game.Sets[2].Blue);
|
||||
Assert.Equal(2, game.Sets[2].Green);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Game_FromString__ValidExample2()
|
||||
{
|
||||
@@ -35,35 +35,35 @@ public class Day02_Tests
|
||||
Assert.Equal(0, game.Sets[2].Blue);
|
||||
Assert.Equal(5, game.Sets[2].Green);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example()
|
||||
{
|
||||
Day02 day = new();
|
||||
|
||||
string result = day.ResolvePart1(new[] {
|
||||
|
||||
string result = day.ResolvePart1([
|
||||
"Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green",
|
||||
"Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue",
|
||||
"Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red",
|
||||
"Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red",
|
||||
"Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green",
|
||||
});
|
||||
]);
|
||||
|
||||
Assert.Equal("8", result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart2__Example()
|
||||
{
|
||||
Day02 day = new();
|
||||
|
||||
string result = day.ResolvePart2(new[] {
|
||||
|
||||
string result = day.ResolvePart2([
|
||||
"Game 1: 3 blue, 4 red; 1 red, 2 green, 6 blue; 2 green",
|
||||
"Game 2: 1 blue, 2 green; 3 green, 4 blue, 1 red; 1 green, 1 blue",
|
||||
"Game 3: 8 green, 6 blue, 20 red; 5 blue, 4 red, 13 green; 5 green, 1 red",
|
||||
"Game 4: 1 green, 3 red, 6 blue; 3 green, 6 red; 3 green, 15 blue, 14 red",
|
||||
"Game 5: 6 red, 1 blue, 3 green; 2 blue, 1 red, 2 green",
|
||||
});
|
||||
]);
|
||||
|
||||
Assert.Equal("2286", result);
|
||||
}
|
||||
|
||||
@@ -5,26 +5,26 @@ public class Day03_Tests
|
||||
[Fact]
|
||||
public void SearchNextSchemaNumber__NoNumbers__Null()
|
||||
{
|
||||
string[] inputs = new[] {
|
||||
string[] inputs = [
|
||||
"..........",
|
||||
"..........",
|
||||
"..........",
|
||||
};
|
||||
];
|
||||
Day03.SchemaNumber? number = Day03.SearchNextSchemaNumber(inputs, 0, 0);
|
||||
|
||||
|
||||
Assert.Null(number);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void SearchNextSchemaNumber__OneNumber__Valid()
|
||||
{
|
||||
string[] inputs = new[] {
|
||||
string[] inputs = [
|
||||
"..........",
|
||||
"....420...",
|
||||
"..........",
|
||||
};
|
||||
];
|
||||
Day03.SchemaNumber? number = Day03.SearchNextSchemaNumber(inputs, 0, 0);
|
||||
|
||||
|
||||
Assert.NotNull(number);
|
||||
Assert.Equal(1, number.Value.Row);
|
||||
Assert.Equal(4, number.Value.Column);
|
||||
@@ -35,13 +35,13 @@ public class Day03_Tests
|
||||
[Fact]
|
||||
public void SearchNextSchemaNumber__TwoNumbersSkipFirst__ValidSecond()
|
||||
{
|
||||
string[] inputs = new[] {
|
||||
string[] inputs = [
|
||||
"69........",
|
||||
"....420...",
|
||||
"..........",
|
||||
};
|
||||
];
|
||||
Day03.SchemaNumber? number = Day03.SearchNextSchemaNumber(inputs, 0, 4);
|
||||
|
||||
|
||||
Assert.NotNull(number);
|
||||
Assert.Equal(1, number.Value.Row);
|
||||
Assert.Equal(4, number.Value.Column);
|
||||
@@ -49,7 +49,7 @@ public class Day03_Tests
|
||||
Assert.Equal(420, number.Value.Value);
|
||||
}
|
||||
|
||||
private string[] _example = new[] {
|
||||
private string[] _example = [
|
||||
"467..114..",
|
||||
"...*......",
|
||||
"..35..633.",
|
||||
@@ -60,24 +60,24 @@ public class Day03_Tests
|
||||
"......755.",
|
||||
"...$.*....",
|
||||
".664.598..",
|
||||
};
|
||||
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example()
|
||||
{
|
||||
Day03 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example);
|
||||
|
||||
Assert.Equal("4361", result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart2__Example()
|
||||
{
|
||||
Day03 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example);
|
||||
|
||||
Assert.Equal("467835", result);
|
||||
|
||||
@@ -2,20 +2,20 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day04_Tests
|
||||
{
|
||||
private readonly string[] _example = {
|
||||
private readonly string[] _example = [
|
||||
"Card 1: 41 48 83 86 17 | 83 86 6 31 17 9 48 53",
|
||||
"Card 2: 13 32 20 16 61 | 61 30 68 82 17 32 24 19",
|
||||
"Card 3: 1 21 53 59 44 | 69 82 63 72 16 21 14 1",
|
||||
"Card 4: 41 92 73 84 69 | 59 84 76 51 58 5 54 83",
|
||||
"Card 5: 87 83 26 28 32 | 88 30 70 12 93 22 82 36",
|
||||
"Card 6: 31 18 13 56 72 | 74 77 10 23 35 67 36 11",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example()
|
||||
{
|
||||
Day04 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example);
|
||||
|
||||
Assert.Equal("13", result);
|
||||
@@ -25,7 +25,7 @@ public class Day04_Tests
|
||||
public void ResolvePart2__Example()
|
||||
{
|
||||
Day04 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example);
|
||||
|
||||
Assert.Equal("30", result);
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day05_Tests
|
||||
{
|
||||
private readonly string[] _example = {
|
||||
private readonly string[] _example = [
|
||||
"seeds: 79 14 55 13",
|
||||
"",
|
||||
"seed-to-soil map:",
|
||||
@@ -36,13 +36,13 @@ public class Day05_Tests
|
||||
"humidity-to-location map:",
|
||||
"60 56 37",
|
||||
"56 93 4",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example()
|
||||
{
|
||||
Day05 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example);
|
||||
|
||||
Assert.Equal("35", result);
|
||||
@@ -52,7 +52,7 @@ public class Day05_Tests
|
||||
public void ResolvePart2__Example()
|
||||
{
|
||||
Day05 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example);
|
||||
|
||||
Assert.Equal("46", result);
|
||||
@@ -61,22 +61,22 @@ public class Day05_Tests
|
||||
[Fact]
|
||||
public void AlmanacMapping_ParseNext__Empty__Null()
|
||||
{
|
||||
Day05.LinesReader reader = new(Array.Empty<string>());
|
||||
Day05.LinesReader reader = new([]);
|
||||
Day05.AlmanacMapping? mapping = Day05.AlmanacMapping.ParseNext(reader);
|
||||
|
||||
|
||||
Assert.Null(mapping);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void AlmanacMapping_ParseNext__Example1()
|
||||
{
|
||||
Day05.LinesReader reader = new(new[] {
|
||||
Day05.LinesReader reader = new([
|
||||
"seed-to-soil map:",
|
||||
"50 98 2",
|
||||
"52 50 48",
|
||||
});
|
||||
]);
|
||||
Day05.AlmanacMapping? mapping = Day05.AlmanacMapping.ParseNext(reader);
|
||||
|
||||
|
||||
Assert.NotNull(mapping);
|
||||
Assert.Equal("seed-to-soil", mapping.Name);
|
||||
Assert.Equal(2, mapping.RangeMappings.Count);
|
||||
@@ -90,11 +90,11 @@ public class Day05_Tests
|
||||
const long value1 = 100;
|
||||
long valueMapped1 = mapping.Apply(value1);
|
||||
Assert.Equal(100, valueMapped1);
|
||||
|
||||
|
||||
const long value2 = 99;
|
||||
long valueMapped2 = mapping.Apply(value2);
|
||||
Assert.Equal(51, valueMapped2);
|
||||
|
||||
|
||||
const long value3 = 45;
|
||||
long valueMapped3 = mapping.Apply(value3);
|
||||
Assert.Equal(45, valueMapped3);
|
||||
@@ -109,7 +109,7 @@ public class Day05_Tests
|
||||
DestinationStart = 1000,
|
||||
Length = 10,
|
||||
};
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// #####.........................
|
||||
Day05.AlmanacRangeMapping range_Lower = new() {
|
||||
@@ -124,7 +124,7 @@ public class Day05_Tests
|
||||
Assert.Equal(5, range_Lower_Result.PreClip.Value.Length);
|
||||
Assert.Null(range_Lower_Result.Clipped);
|
||||
Assert.Null(range_Lower_Result.PostClip);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// ##########....................
|
||||
Day05.AlmanacRangeMapping range_LowerTouching = new() {
|
||||
@@ -139,7 +139,7 @@ public class Day05_Tests
|
||||
Assert.Equal(10, range_LowerTouching_Result.PreClip.Value.Length);
|
||||
Assert.Null(range_LowerTouching_Result.Clipped);
|
||||
Assert.Null(range_LowerTouching_Result.PostClip);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// .........................#####
|
||||
Day05.AlmanacRangeMapping range_Upper = new() {
|
||||
@@ -154,7 +154,7 @@ public class Day05_Tests
|
||||
Assert.Equal(25, range_Upper_Result.PostClip.Value.OriginStart);
|
||||
Assert.Equal(25, range_Upper_Result.PostClip.Value.DestinationStart);
|
||||
Assert.Equal(5, range_Upper_Result.PostClip.Value.Length);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// ....................##########
|
||||
Day05.AlmanacRangeMapping range_UpperTouching = new() {
|
||||
@@ -169,7 +169,7 @@ public class Day05_Tests
|
||||
Assert.Equal(20, range_UpperTouching_Result.PostClip.Value.OriginStart);
|
||||
Assert.Equal(20, range_UpperTouching_Result.PostClip.Value.DestinationStart);
|
||||
Assert.Equal(10, range_UpperTouching_Result.PostClip.Value.Length);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// ..........$$$$$$$$$$..........
|
||||
Day05.AlmanacRangeMapping range_IntersectCover = new() {
|
||||
@@ -184,7 +184,7 @@ public class Day05_Tests
|
||||
Assert.Equal(1000, range_IntersectCover_Result.Clipped.Value.DestinationStart);
|
||||
Assert.Equal(10, range_IntersectCover_Result.Clipped.Value.Length);
|
||||
Assert.Null(range_IntersectCover_Result.PostClip);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// ...............$$$$$..........
|
||||
Day05.AlmanacRangeMapping range_IntersectInsideToEnd = new() {
|
||||
@@ -199,7 +199,7 @@ public class Day05_Tests
|
||||
Assert.Equal(1005, range_IntersectInsideToEnd_Result.Clipped.Value.DestinationStart);
|
||||
Assert.Equal(5, range_IntersectInsideToEnd_Result.Clipped.Value.Length);
|
||||
Assert.Null(range_IntersectInsideToEnd_Result.PostClip);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// ...............$$$$$#####.....
|
||||
Day05.AlmanacRangeMapping range_IntersectInsideToOutside = new() {
|
||||
@@ -217,7 +217,7 @@ public class Day05_Tests
|
||||
Assert.Equal(20, range_IntersectInsideToOutside_Result.PostClip.Value.OriginStart);
|
||||
Assert.Equal(20, range_IntersectInsideToOutside_Result.PostClip.Value.DestinationStart);
|
||||
Assert.Equal(5, range_IntersectInsideToOutside_Result.PostClip.Value.Length);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// .....#####$$$$$...............
|
||||
Day05.AlmanacRangeMapping range_IntersectOutsideToInside = new() {
|
||||
@@ -235,7 +235,7 @@ public class Day05_Tests
|
||||
Assert.Equal(1000, range_IntersectOutsideToInside_Result.Clipped.Value.DestinationStart);
|
||||
Assert.Equal(5, range_IntersectOutsideToInside_Result.Clipped.Value.Length);
|
||||
Assert.Null(range_IntersectOutsideToInside_Result.PostClip);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// .....#####$$$$$$$$$$..........
|
||||
Day05.AlmanacRangeMapping range_IntersectOutsideToEnd = new() {
|
||||
@@ -253,7 +253,7 @@ public class Day05_Tests
|
||||
Assert.Equal(1000, range_IntersectOutsideToEnd_Result.Clipped.Value.DestinationStart);
|
||||
Assert.Equal(10, range_IntersectOutsideToEnd_Result.Clipped.Value.Length);
|
||||
Assert.Null(range_IntersectOutsideToEnd_Result.PostClip);
|
||||
|
||||
|
||||
// ..........■■■■■■■■■■..........
|
||||
// .....#####$$$$$$$$$$#####.....
|
||||
Day05.AlmanacRangeMapping range_IntersectOutsideToOutside = new() {
|
||||
|
||||
@@ -2,16 +2,16 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day06_Tests
|
||||
{
|
||||
private readonly string[] _example = {
|
||||
private readonly string[] _example = [
|
||||
"Time: 7 15 30",
|
||||
"Distance: 9 40 200",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example()
|
||||
{
|
||||
Day06 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example);
|
||||
|
||||
Assert.Equal("288", result);
|
||||
@@ -21,7 +21,7 @@ public class Day06_Tests
|
||||
public void ResolvePart2__Example()
|
||||
{
|
||||
Day06 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example);
|
||||
|
||||
Assert.Equal("71503", result);
|
||||
|
||||
@@ -2,19 +2,19 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day07_Tests
|
||||
{
|
||||
private readonly string[] _example = {
|
||||
private readonly string[] _example = [
|
||||
"32T3K 765",
|
||||
"T55J5 684",
|
||||
"KK677 28",
|
||||
"KTJJT 220",
|
||||
"QQQJA 483",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example()
|
||||
{
|
||||
Day07 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example);
|
||||
|
||||
Assert.Equal("6440", result);
|
||||
@@ -24,7 +24,7 @@ public class Day07_Tests
|
||||
public void ResolvePart2__Example()
|
||||
{
|
||||
Day07 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example);
|
||||
|
||||
Assert.Equal("5905", result);
|
||||
@@ -35,26 +35,26 @@ public class Day07_Tests
|
||||
{
|
||||
Day07.CamelCard card_FiveOfAKind = new("AAAAA");
|
||||
Assert.Equal(Day07.CamelCard.Types.FiveOfAKind, card_FiveOfAKind.Type);
|
||||
|
||||
|
||||
Day07.CamelCard card_FourOfAKind = new("AA8AA");
|
||||
Assert.Equal(Day07.CamelCard.Types.FourOfAKind, card_FourOfAKind.Type);
|
||||
|
||||
|
||||
Day07.CamelCard card_FullHouse = new("23332");
|
||||
Assert.Equal(Day07.CamelCard.Types.FullHouse, card_FullHouse.Type);
|
||||
|
||||
|
||||
Day07.CamelCard card_ThreeOfAKind = new("TTT98");
|
||||
Assert.Equal(Day07.CamelCard.Types.ThreeOfAKind, card_ThreeOfAKind.Type);
|
||||
|
||||
|
||||
Day07.CamelCard card_TwoPair = new("23432");
|
||||
Assert.Equal(Day07.CamelCard.Types.TwoPair, card_TwoPair.Type);
|
||||
|
||||
|
||||
Day07.CamelCard card_OnePair = new("A23A4");
|
||||
Assert.Equal(Day07.CamelCard.Types.OnePair, card_OnePair.Type);
|
||||
|
||||
|
||||
Day07.CamelCard card_HighCard = new("23456");
|
||||
Assert.Equal(Day07.CamelCard.Types.HighCard, card_HighCard.Type);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void CamelCard_CompareTo__Examples()
|
||||
{
|
||||
@@ -62,7 +62,7 @@ public class Day07_Tests
|
||||
Day07.CamelCard card_02 = new("2AAAA");
|
||||
Assert.Equal(-1, card_01.CompareTo(card_02));
|
||||
Assert.Equal(1, card_02.CompareTo(card_01));
|
||||
|
||||
|
||||
Day07.CamelCard card_77888 = new("77888");
|
||||
Day07.CamelCard card_77788 = new("77788");
|
||||
Assert.Equal(-1, card_77888.CompareTo(card_77788));
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day08_Tests
|
||||
{
|
||||
private readonly string[] _example1 = {
|
||||
private readonly string[] _example1 = [
|
||||
"RL",
|
||||
"",
|
||||
"AAA = (BBB, CCC)",
|
||||
@@ -12,37 +12,37 @@ public class Day08_Tests
|
||||
"EEE = (EEE, EEE)",
|
||||
"GGG = (GGG, GGG)",
|
||||
"ZZZ = (ZZZ, ZZZ)",
|
||||
};
|
||||
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example1()
|
||||
{
|
||||
Day08 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example1);
|
||||
|
||||
Assert.Equal("2", result);
|
||||
}
|
||||
|
||||
private readonly string[] _example2 = {
|
||||
private readonly string[] _example2 = [
|
||||
"LLR",
|
||||
"",
|
||||
"AAA = (BBB, BBB)",
|
||||
"BBB = (AAA, ZZZ)",
|
||||
"ZZZ = (ZZZ, ZZZ)",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example2()
|
||||
{
|
||||
Day08 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example2);
|
||||
|
||||
Assert.Equal("6", result);
|
||||
}
|
||||
|
||||
private readonly string[] _example3 = {
|
||||
private readonly string[] _example3 = [
|
||||
"LR",
|
||||
"",
|
||||
"11A = (11B, XXX)",
|
||||
@@ -53,16 +53,15 @@ public class Day08_Tests
|
||||
"22C = (22Z, 22Z)",
|
||||
"22Z = (22B, 22B)",
|
||||
"XXX = (XXX, XXX)",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart2__Example3()
|
||||
{
|
||||
Day08 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example3);
|
||||
|
||||
Assert.Equal("6", result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,17 +2,17 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day09_Tests
|
||||
{
|
||||
private readonly string[] _example = {
|
||||
private readonly string[] _example = [
|
||||
"0 3 6 9 12 15",
|
||||
"1 3 6 10 15 21",
|
||||
"10 13 16 21 30 45",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example()
|
||||
{
|
||||
Day09 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example);
|
||||
|
||||
Assert.Equal("114", result);
|
||||
@@ -22,7 +22,7 @@ public class Day09_Tests
|
||||
public void ResolvePart2__Example()
|
||||
{
|
||||
Day09 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example);
|
||||
|
||||
Assert.Equal("2", result);
|
||||
@@ -35,7 +35,7 @@ public class Day09_Tests
|
||||
long result = extrapolator.Extrapolate();
|
||||
Assert.Equal(18, result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Extrapolator_Extrapolate__Example2()
|
||||
{
|
||||
@@ -43,7 +43,7 @@ public class Day09_Tests
|
||||
long result = extrapolator.Extrapolate();
|
||||
Assert.Equal(28, result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Extrapolator_Extrapolate__Example3()
|
||||
{
|
||||
@@ -59,7 +59,7 @@ public class Day09_Tests
|
||||
long result = extrapolator.ExtrapolatePast();
|
||||
Assert.Equal(-3, result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Extrapolator_ExtrapolatePast__Example2()
|
||||
{
|
||||
@@ -67,7 +67,7 @@ public class Day09_Tests
|
||||
long result = extrapolator.ExtrapolatePast();
|
||||
Assert.Equal(0, result);
|
||||
}
|
||||
|
||||
|
||||
[Fact]
|
||||
public void Extrapolator_ExtrapolatePast__Example3()
|
||||
{
|
||||
|
||||
@@ -2,25 +2,25 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day10_Tests
|
||||
{
|
||||
private readonly string[] _example1 = {
|
||||
private readonly string[] _example1 = [
|
||||
"7-F7-",
|
||||
".FJ|7",
|
||||
"SJLL7",
|
||||
"|F--J",
|
||||
"LJ.LJ",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example1()
|
||||
{
|
||||
Day10 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example1);
|
||||
|
||||
Assert.Equal("8", result);
|
||||
}
|
||||
|
||||
private readonly string[] _example2 = {
|
||||
|
||||
private readonly string[] _example2 = [
|
||||
"...........",
|
||||
".S-------7.",
|
||||
".|F-----7|.",
|
||||
@@ -30,20 +30,20 @@ public class Day10_Tests
|
||||
".|..|.|..|.",
|
||||
".L--J.L--J.",
|
||||
"...........",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart2__Example2()
|
||||
{
|
||||
Day10 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example2);
|
||||
|
||||
Assert.Equal("4", result);
|
||||
}
|
||||
|
||||
|
||||
private readonly string[] _example3 = {
|
||||
|
||||
private readonly string[] _example3 = [
|
||||
"FF7FSF7F7F7F7F7F---7",
|
||||
"L|LJ||||||||||||F--J",
|
||||
"FL-7LJLJ||||||LJL-77",
|
||||
@@ -54,13 +54,13 @@ public class Day10_Tests
|
||||
"7-L-JL7||F7|L7F-7F7|",
|
||||
"L.L7LFJ|||||FJL7||LJ",
|
||||
"L7JLJL-JLJLJL--JLJ.L",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart2__Example3()
|
||||
{
|
||||
Day10 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart2(_example3);
|
||||
|
||||
Assert.Equal("10", result);
|
||||
|
||||
@@ -2,7 +2,7 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day11_Tests
|
||||
{
|
||||
private readonly string[] _example1 = {
|
||||
private readonly string[] _example1 = [
|
||||
"...#......",
|
||||
".......#..",
|
||||
"#.........",
|
||||
@@ -13,16 +13,15 @@ public class Day11_Tests
|
||||
"..........",
|
||||
".......#..",
|
||||
"#...#.....",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example1()
|
||||
{
|
||||
Day11 day = new();
|
||||
|
||||
|
||||
string result = day.ResolvePart1(_example1);
|
||||
|
||||
Assert.Equal("374", result);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,14 +2,14 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day12_Tests
|
||||
{
|
||||
private readonly string[] _example1 = {
|
||||
private readonly string[] _example1 = [
|
||||
"???.### 1,1,3",
|
||||
".??..??...?##. 1,1,3",
|
||||
"?#?#?#?#?#?#?#? 1,3,1,6",
|
||||
"????.#...#... 4,1,1",
|
||||
"????.######..#####. 1,6,5",
|
||||
"?###???????? 3,2,1",
|
||||
};
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example1()
|
||||
|
||||
@@ -10,14 +10,14 @@ namespace AdventOfCode2023.Tests;
|
||||
|
||||
public class Day24_Tests
|
||||
{
|
||||
private string[] _example1 = {
|
||||
private string[] _example1 = [
|
||||
"19, 13, 30 @ -2, 1, -2",
|
||||
"18, 19, 22 @ -1, -1, -2",
|
||||
"20, 25, 34 @ -2, -2, -4",
|
||||
"12, 31, 28 @ -1, -2, -1",
|
||||
"20, 19, 15 @ 1, -5, -3",
|
||||
};
|
||||
|
||||
];
|
||||
|
||||
[Fact]
|
||||
public void ResolvePart1__Example1()
|
||||
{
|
||||
@@ -36,36 +36,35 @@ public class Day24_Tests
|
||||
Day24.Hail hailC = new("20, 25, 34 @ -2, -2, -4");
|
||||
Day24.Hail hailD = new("12, 31, 28 @ -1, -2, -1");
|
||||
Day24.Hail hailE = new("20, 19, 15 @ 1, -5, -3");
|
||||
|
||||
|
||||
(bool intersect_A_B, _, _, _) = hailA.Intersect2D(hailB);
|
||||
Assert.True(intersect_A_B);
|
||||
|
||||
|
||||
(bool intersect_A_C, _, _, _) = hailA.Intersect2D(hailC);
|
||||
Assert.True(intersect_A_C);
|
||||
|
||||
|
||||
(bool intersect_A_D, _, _, _) = hailA.Intersect2D(hailD);
|
||||
Assert.True(intersect_A_D);
|
||||
|
||||
|
||||
(bool intersect_A_E, _, _, _) = hailA.Intersect2D(hailE);
|
||||
Assert.True(intersect_A_E);
|
||||
|
||||
|
||||
(bool intersect_B_C, _, _, _) = hailB.Intersect2D(hailC);
|
||||
Assert.False(intersect_B_C);
|
||||
|
||||
|
||||
(bool intersect_B_D, _, _, _) = hailB.Intersect2D(hailD);
|
||||
Assert.True(intersect_B_D);
|
||||
|
||||
|
||||
(bool intersect_B_E, _, _, _) = hailB.Intersect2D(hailE);
|
||||
Assert.True(intersect_B_E);
|
||||
|
||||
|
||||
(bool intersect_C_D, _, _, _) = hailC.Intersect2D(hailD);
|
||||
Assert.True(intersect_C_D);
|
||||
|
||||
|
||||
(bool intersect_C_E, _, _, _) = hailC.Intersect2D(hailE);
|
||||
Assert.True(intersect_C_E);
|
||||
|
||||
|
||||
(bool intersect_D_E, _, _, _) = hailD.Intersect2D(hailE);
|
||||
Assert.True(intersect_D_E);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user