Implemented Day 5 part 1 and 2 as well as its unit tests.
This commit is contained in:
parent
b47c738280
commit
4f77341a7c
@ -12,6 +12,7 @@
|
||||
<None Remove="Inputs\Day2.txt" />
|
||||
<None Remove="Inputs\Day3.txt" />
|
||||
<None Remove="Inputs\Day4.txt" />
|
||||
<None Remove="Inputs\Day5.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -19,6 +20,7 @@
|
||||
<EmbeddedResource Include="Inputs\Day2.txt" />
|
||||
<EmbeddedResource Include="Inputs\Day3.txt" />
|
||||
<EmbeddedResource Include="Inputs\Day4.txt" />
|
||||
<EmbeddedResource Include="Inputs\Day5.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
81
AdventOfCode2023/Day5/Day5_1.cs
Normal file
81
AdventOfCode2023/Day5/Day5_1.cs
Normal file
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AdventOfCode2023.Day5
|
||||
{
|
||||
public class Day5_1 : DayBase
|
||||
{
|
||||
string input = string.Empty;
|
||||
|
||||
Regex rxSeeds = new Regex(@"(?<=seeds:[\s\d]+)\d+");
|
||||
Regex rxSeedToSoil = new Regex(@"(?<=seed-to-soil map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxSoilToFertilizer = new Regex(@"(?<=soil-to-fertilizer map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxFertilizerToWater = new Regex(@"(?<=fertilizer-to-water map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxWaterToLight = new Regex(@"(?<=water-to-light map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxLightToTemperature = new Regex(@"(?<=light-to-temperature map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxTemperatureToHumidity = new Regex(@"(?<=temperature-to-humidity map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxHumidityToLocation = new Regex(@"(?<=humidity-to-location map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
|
||||
public Day5_1()
|
||||
{
|
||||
input = GetInput("Day5.txt");
|
||||
}
|
||||
|
||||
public Day5_1(string testInput)
|
||||
{
|
||||
input = testInput;
|
||||
}
|
||||
|
||||
public override string Execute()
|
||||
{
|
||||
List<ulong> seeds = rxSeeds.Matches(input).Select(x => ulong.Parse(x.Value)).ToList();
|
||||
List<Map> seedToSoilMaps = rxSeedToSoil.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> soilToFertilizer = rxSoilToFertilizer.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> fertilizerToWater = rxFertilizerToWater.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> waterToLight = rxWaterToLight.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> lightToTemperature = rxLightToTemperature.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> temperatureToHumidity = rxTemperatureToHumidity.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> humidityToLocation = rxHumidityToLocation.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
|
||||
List<ulong> locations = seeds.Select(x => seedToSoilMaps.Find(y => y.IsInSourceRange(x))?.Convert(x) ?? x).Select(x => soilToFertilizer.Find(y => y.IsInSourceRange(x))?.Convert(x) ?? x).Select(x => fertilizerToWater.Find(y => y.IsInSourceRange(x))?.Convert(x) ?? x).Select(x => waterToLight.Find(y => y.IsInSourceRange(x))?.Convert(x) ?? x).Select(x => lightToTemperature.Find(y => y.IsInSourceRange(x))?.Convert(x) ?? x).Select(x => temperatureToHumidity.Find(y => y.IsInSourceRange(x))?.Convert(x) ?? x).Select(x => humidityToLocation.Find(y => y.IsInSourceRange(x))?.Convert(x) ?? x).ToList();
|
||||
|
||||
return locations.Min().ToString();
|
||||
}
|
||||
}
|
||||
|
||||
internal class Map
|
||||
{
|
||||
private ulong _destinationRangeStart;
|
||||
private ulong _destinationRangeEnd;
|
||||
private ulong _sourceRangeStart;
|
||||
private ulong _rangeLength;
|
||||
private ulong _sourceRangeEnd;
|
||||
|
||||
public ulong DestinationRangeStart { get => _destinationRangeStart; }
|
||||
public ulong DestinationRangeEnd { get => _destinationRangeEnd; }
|
||||
|
||||
public Map(ulong destinationRangeStart, ulong sourceRangeStart, ulong rangeLength)
|
||||
{
|
||||
_destinationRangeStart = destinationRangeStart;
|
||||
_sourceRangeStart = sourceRangeStart;
|
||||
_rangeLength = rangeLength;
|
||||
_sourceRangeEnd = _sourceRangeStart + (_rangeLength - 1);
|
||||
_destinationRangeEnd = destinationRangeStart + (_rangeLength - 1);
|
||||
}
|
||||
|
||||
public bool IsInSourceRange(ulong input) => input >= _sourceRangeStart && input <= _sourceRangeEnd;
|
||||
|
||||
public bool IsInDestinationRange(ulong input) => input >= _destinationRangeStart && input <= _destinationRangeEnd;
|
||||
|
||||
public ulong Convert(ulong source)
|
||||
{
|
||||
return source + (_destinationRangeStart - _sourceRangeStart);
|
||||
}
|
||||
|
||||
public (ulong rangeStart, ulong rangeEnd) GetSourceRange() => (_sourceRangeStart, _sourceRangeEnd);
|
||||
}
|
||||
}
|
96
AdventOfCode2023/Day5/Day5_2.cs
Normal file
96
AdventOfCode2023/Day5/Day5_2.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Dynamic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace AdventOfCode2023.Day5
|
||||
{
|
||||
public class Day5_2 : DayBase
|
||||
{
|
||||
string input = string.Empty;
|
||||
|
||||
Regex rxSeeds = new Regex(@"(?<=seeds:[\s\d]+)\d+");
|
||||
Regex rxSeedToSoil = new Regex(@"(?<=seed-to-soil map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxSoilToFertilizer = new Regex(@"(?<=soil-to-fertilizer map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxFertilizerToWater = new Regex(@"(?<=fertilizer-to-water map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxWaterToLight = new Regex(@"(?<=water-to-light map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxLightToTemperature = new Regex(@"(?<=light-to-temperature map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxTemperatureToHumidity = new Regex(@"(?<=temperature-to-humidity map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
Regex rxHumidityToLocation = new Regex(@"(?<=humidity-to-location map:\r\n(\d+\s+\d+\s+\d+\r\n)*)(?<destinationRangeStart>\d+)\s+(?<sourceRangeStart>\d+)\s+(?<rangeLength>\d+)");
|
||||
|
||||
private readonly object lowestLocationLock = new object();
|
||||
private ulong lowestLocation = 0;
|
||||
|
||||
public Day5_2()
|
||||
{
|
||||
input = GetInput("Day5.txt");
|
||||
}
|
||||
|
||||
public Day5_2(string testInput)
|
||||
{
|
||||
input = testInput;
|
||||
}
|
||||
|
||||
public override string Execute()
|
||||
{
|
||||
List<ulong> entries = rxSeeds.Matches(input).Select(x => ulong.Parse(x.Value)).ToList();
|
||||
|
||||
var seeds = Enumerable.Range(0, entries.Count)
|
||||
.GroupBy(x => x / 2)
|
||||
.Select(x => x.Select(y => entries[y]).ToArray())
|
||||
.SelectMany(x => CreateRange(x[0], x[1]))
|
||||
.Select(x => (x, new ulong()));
|
||||
|
||||
List<Map> seedToSoilMaps = rxSeedToSoil.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> soilToFertilizer = rxSoilToFertilizer.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> fertilizerToWater = rxFertilizerToWater.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> waterToLight = rxWaterToLight.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> lightToTemperature = rxLightToTemperature.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> temperatureToHumidity = rxTemperatureToHumidity.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
List<Map> humidityToLocation = rxHumidityToLocation.Matches(input).Select(x => new Map(ulong.Parse(x.Groups["destinationRangeStart"].Value), ulong.Parse(x.Groups["sourceRangeStart"].Value), ulong.Parse(x.Groups["rangeLength"].Value))).ToList();
|
||||
|
||||
Parallel.ForEach(seeds, seed =>
|
||||
{
|
||||
var soilNumber = seedToSoilMaps.Find(y => y.IsInSourceRange(seed.x))?.Convert(seed.x) ?? seed.x;
|
||||
var fertilizerNumber = soilToFertilizer.Find(y => y.IsInSourceRange(soilNumber))?.Convert(soilNumber) ?? soilNumber;
|
||||
var waterNumber = fertilizerToWater.Find(y => y.IsInSourceRange(fertilizerNumber))?.Convert(fertilizerNumber) ?? fertilizerNumber;
|
||||
var lightNumber = waterToLight.Find(y => y.IsInSourceRange(waterNumber))?.Convert(waterNumber) ?? waterNumber;
|
||||
var temperatureNumber = lightToTemperature.Find(y => y.IsInSourceRange(lightNumber))?.Convert(lightNumber) ?? lightNumber;
|
||||
var humidityNumber = temperatureToHumidity.Find(y => y.IsInSourceRange(temperatureNumber))?.Convert(temperatureNumber) ?? temperatureNumber;
|
||||
var locationNumber = humidityToLocation.Find(y => y.IsInSourceRange(humidityNumber))?.Convert(humidityNumber) ?? humidityNumber;
|
||||
|
||||
lock(lowestLocationLock)
|
||||
{
|
||||
if (lowestLocation == 0 || locationNumber < lowestLocation)
|
||||
{
|
||||
lowestLocation = locationNumber;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return lowestLocation.ToString();
|
||||
}
|
||||
|
||||
internal List<Map> GetMapsFromMap(IReadOnlyList<Map> maps, Map currentMap)
|
||||
{
|
||||
var currentMapSourceRange = currentMap.GetSourceRange();
|
||||
return GetAssociatedMaps(maps, currentMapSourceRange.rangeStart, currentMapSourceRange.rangeEnd).ToList();
|
||||
}
|
||||
|
||||
internal IEnumerable<Map> GetAssociatedMaps(IReadOnlyList<Map> maps, ulong rangeStart, ulong rangeEnd) => maps.Where(x => (x.DestinationRangeStart <= rangeStart && x.DestinationRangeEnd >= rangeStart) || (x.DestinationRangeStart >= rangeStart && x.DestinationRangeStart <= rangeEnd));
|
||||
|
||||
public IEnumerable<ulong> CreateRange(ulong start, ulong count)
|
||||
{
|
||||
var limit = start + count;
|
||||
|
||||
while (start < limit)
|
||||
{
|
||||
yield return start;
|
||||
start++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
258
AdventOfCode2023/Inputs/Day5.txt
Normal file
258
AdventOfCode2023/Inputs/Day5.txt
Normal file
@ -0,0 +1,258 @@
|
||||
seeds: 1347397244 12212989 2916488878 1034516675 2821376423 8776260 2240804122 368941186 824872000 124877531 1597965637 36057332 4091290431 159289722 1875817275 106230212 998513229 159131132 2671581775 4213184
|
||||
|
||||
seed-to-soil map:
|
||||
2988689842 4194451945 100515351
|
||||
2936009234 3353543976 52680608
|
||||
588295233 2638661119 66434163
|
||||
3932833115 2936009234 88315480
|
||||
3525561241 3331695912 21848064
|
||||
1622262003 1969921080 210668061
|
||||
2160566101 909457337 162053391
|
||||
1832930064 1887384181 82536899
|
||||
3625461917 3024324714 307371198
|
||||
3547409305 3680043285 78052612
|
||||
1915466963 588295233 240773057
|
||||
3089205193 3758095897 436356048
|
||||
4021148595 3406224584 273818701
|
||||
2156240020 2705095282 4326081
|
||||
1164190025 2180589141 458071978
|
||||
2477360206 829068290 80389047
|
||||
2322619492 2709421363 154740714
|
||||
654729396 1377923552 509460629
|
||||
2557749253 1211672006 166251546
|
||||
2724000799 1071510728 140161278
|
||||
|
||||
soil-to-fertilizer map:
|
||||
3961802244 3774724750 90737174
|
||||
3164426550 3931513861 70563571
|
||||
147221566 1279409424 704464
|
||||
1394834067 2074132435 40845148
|
||||
3795834030 2142537807 47621185
|
||||
4083197470 4095560143 199407153
|
||||
2722903919 2876212954 93296050
|
||||
3467494732 2775293966 100918988
|
||||
1809650294 1815421878 66426374
|
||||
505665614 275280169 12031240
|
||||
2142537807 4002077432 60985377
|
||||
1577608496 331482268 177958690
|
||||
2590855103 2196397738 132048816
|
||||
1942888942 1978207624 24340152
|
||||
756722275 120895382 4815243
|
||||
3435289775 3899308904 32204957
|
||||
1967229094 715059087 147748489
|
||||
3955563498 2190158992 6238746
|
||||
356096070 125710625 149569544
|
||||
2520387506 2704826369 70467597
|
||||
517696854 2041922514 32209921
|
||||
1755567186 0 54083108
|
||||
348569226 1280113888 7526844
|
||||
761537518 1597328127 34415327
|
||||
1114796271 1631743454 128592301
|
||||
0 1494456232 102871895
|
||||
1070625412 287311409 44170859
|
||||
549906775 1287640732 206815500
|
||||
102871895 710084154 4974933
|
||||
1298474695 1881848252 96359372
|
||||
3843455215 2549697361 112108283
|
||||
3761987050 3865461924 33846980
|
||||
4052539418 2674168317 30658052
|
||||
1435679215 862807576 141929281
|
||||
795952845 1004736857 274672567
|
||||
3729489716 4063062809 32497334
|
||||
2203523184 3085216895 316864322
|
||||
2931907860 3402081217 11267883
|
||||
107846828 2002547776 39374738
|
||||
2816199969 2969509004 115707891
|
||||
3568413720 3413349100 161075996
|
||||
2943175743 2328446554 221250807
|
||||
3234990121 3574425096 200299654
|
||||
4282604623 2661805644 12362673
|
||||
147926030 509440958 200643196
|
||||
1876076668 54083108 66812274
|
||||
1243388572 1760335755 55086123
|
||||
|
||||
fertilizer-to-water map:
|
||||
2460553918 850437816 63304366
|
||||
1259757436 1986466040 193004355
|
||||
2879827793 2638634287 61837387
|
||||
39629536 0 3143529
|
||||
2160922553 2535779758 68016930
|
||||
2523858284 922523353 36811379
|
||||
52449107 1199799263 207670511
|
||||
2692884203 2603796688 34837599
|
||||
3755186617 147251641 492169035
|
||||
3266515480 3620937477 292130997
|
||||
1596851845 4077877285 217090011
|
||||
2727721802 913742182 8781171
|
||||
3055087322 3913068474 164808811
|
||||
2228939483 2179470395 229525704
|
||||
3668162112 1052896909 87024505
|
||||
3219896133 1539684314 30399976
|
||||
1510550909 1679599925 86300936
|
||||
0 3143529 39629536
|
||||
2560669663 1407469774 132214540
|
||||
1452761791 1142010145 57789118
|
||||
260119618 2700471674 920465803
|
||||
3250296109 1036677538 16219371
|
||||
1813941856 1026924408 9753130
|
||||
4247355652 2488168114 47611644
|
||||
1823694986 959334732 67589676
|
||||
2831305507 639420676 48522286
|
||||
2736502973 52449107 94802534
|
||||
1180585421 2408996099 79172015
|
||||
2941665180 1765900861 113422142
|
||||
2458465187 1139921414 2088731
|
||||
3558646477 1570084290 109515635
|
||||
1891284662 687942962 162494854
|
||||
2053779516 1879323003 107143037
|
||||
|
||||
water-to-light map:
|
||||
2196302869 3170532562 121192468
|
||||
3065704582 2916528129 254004433
|
||||
2858667310 1154274853 9085577
|
||||
3789349818 1163360430 70779786
|
||||
2064226029 1434838179 90165206
|
||||
1448515654 725716988 103420445
|
||||
2690533041 2124509945 168134269
|
||||
347894075 3345882022 38285799
|
||||
3966625235 2618593488 35838159
|
||||
4186823059 4134088017 89981817
|
||||
1701108140 1088713231 65561622
|
||||
2589948930 2518009377 100584111
|
||||
4283393470 4230658428 11573826
|
||||
0 3384167821 347894075
|
||||
1638541363 2061943168 62566777
|
||||
1296314418 573515752 152201236
|
||||
1065865126 194284013 230449292
|
||||
1766669762 1991838394 70104774
|
||||
830054797 2292644214 110248534
|
||||
3595088014 3291725030 12245358
|
||||
1978385607 1905997972 85840422
|
||||
3607333372 424733305 148782447
|
||||
3511869770 2833309885 83218244
|
||||
4134088017 4242232254 52735042
|
||||
2154391235 3303970388 41911634
|
||||
494720868 3732061896 335333929
|
||||
1836774536 1234140216 141611071
|
||||
2317495337 1633544379 272453593
|
||||
4002463394 2402892748 64932431
|
||||
940303331 829137433 125561795
|
||||
1551936099 954699228 27518372
|
||||
4276804876 4224069834 6588594
|
||||
3756115819 2467825179 33233999
|
||||
2867752887 0 19073457
|
||||
386179874 1525003385 108540994
|
||||
1579454471 1375751287 59086892
|
||||
3319709015 2501059178 16950199
|
||||
3336659214 19073457 175210556
|
||||
3860129604 982217600 106495631
|
||||
2886826344 2654431647 178878238
|
||||
|
||||
light-to-temperature map:
|
||||
977891457 1797846421 453265654
|
||||
3607226990 3913974738 161345346
|
||||
2303244644 3266224873 12707372
|
||||
1537599301 3278932245 264559714
|
||||
354466514 3168465761 62294113
|
||||
747844586 3543491959 55668994
|
||||
2982698313 3599160953 269886589
|
||||
2067998119 2251112075 27763866
|
||||
59336731 230685734 266868096
|
||||
3768572336 1500157846 31849471
|
||||
3856743875 939537646 438223421
|
||||
2095761985 59336731 146190926
|
||||
326204827 4075320084 28261687
|
||||
1502134302 3230759874 35464999
|
||||
1431157111 868560455 70977191
|
||||
2315952016 2579115195 227102616
|
||||
1802159015 1532007317 265839104
|
||||
2241952911 807268722 61291733
|
||||
3297512098 497553830 309714892
|
||||
852851251 4103581771 2643427
|
||||
3252584902 3869047542 44927196
|
||||
855494678 1377761067 122396779
|
||||
2543054632 4106225198 139404427
|
||||
2682459059 2278875941 300239254
|
||||
803513580 4245629625 49337671
|
||||
416760627 205527657 25158077
|
||||
3800421807 2806217811 56322068
|
||||
441918704 2862539879 305925882
|
||||
|
||||
temperature-to-humidity map:
|
||||
3507573 490548898 11693081
|
||||
545755853 699222305 569882925
|
||||
3794976513 167435410 77260251
|
||||
0 1526297837 3507573
|
||||
1335234764 1766508370 36536350
|
||||
2131780538 502241979 64264976
|
||||
3707588652 1679120509 87387861
|
||||
96082543 2288930706 220305732
|
||||
1371771114 1529805410 106547120
|
||||
481810045 3044354609 63945808
|
||||
15200654 1426594789 7560739
|
||||
3206337878 109359655 58075755
|
||||
2445677382 2019348918 269581788
|
||||
1909096745 3571407035 4209780
|
||||
3138678479 4049712539 66833109
|
||||
3400069156 3490205314 81201721
|
||||
4084645800 3846924477 65868498
|
||||
2353535073 1434155528 92142309
|
||||
1716598669 3935506457 114206082
|
||||
3264413633 4116545648 30901597
|
||||
1913306525 3628450464 218474013
|
||||
3205511588 3461720938 826290
|
||||
2748703371 2770603565 195642711
|
||||
2715259170 244990096 33149766
|
||||
1478318234 3108300417 88629505
|
||||
22761393 0 73321150
|
||||
3295315230 3575616815 45887125
|
||||
3872236764 278139862 212409036
|
||||
2196045514 1269105230 157489559
|
||||
2972004168 2509236438 123906332
|
||||
316388275 3296299168 165421770
|
||||
1685215763 3025113077 18894296
|
||||
2748408936 244695661 294435
|
||||
3704521599 4147447245 3067053
|
||||
1215008024 566506955 120226740
|
||||
1830804751 3912792975 22713482
|
||||
1704110059 686733695 12488610
|
||||
3488217401 1803044720 216304198
|
||||
1872711004 3044007373 347236
|
||||
1566947739 2652335541 118268024
|
||||
3481270877 3621503940 6946524
|
||||
2944346082 3462547228 27658086
|
||||
3095910500 1636352530 42767979
|
||||
1115638778 3196929922 99369246
|
||||
3341202355 2966246276 58866801
|
||||
1853518233 2633142770 19192771
|
||||
1873058240 73321150 36038505
|
||||
|
||||
humidity-to-location map:
|
||||
336906655 0 11018487
|
||||
4177510177 2085057023 105144397
|
||||
1299579245 2985741466 175347598
|
||||
643133711 2270603056 161424888
|
||||
2404489601 1000033728 105953201
|
||||
4282654574 2864154964 12312722
|
||||
3409171342 3327025690 30826088
|
||||
2119751049 2190201420 80401636
|
||||
3393269098 3357851778 15902244
|
||||
82121354 319849190 39107402
|
||||
1953814423 3161089064 165936626
|
||||
64524116 385149760 17597238
|
||||
3439997430 2057119912 27937111
|
||||
0 358956592 26193168
|
||||
347925142 11018487 93152804
|
||||
1484466972 2432027944 360604841
|
||||
2510442802 643133711 347359888
|
||||
26193168 402746998 38330948
|
||||
1190305465 2946259551 39481915
|
||||
2200152685 1105986929 204336916
|
||||
3467934541 2792632785 71522179
|
||||
804558599 3373754022 385746866
|
||||
3539456720 1310323845 638053457
|
||||
2857802690 3759500888 535466408
|
||||
121228756 104171291 215677899
|
||||
1229787380 2876467686 69791865
|
||||
1474926843 990493599 9540129
|
||||
1845071813 1948377302 108742610
|
@ -2,6 +2,7 @@
|
||||
using AdventOfCode2023.Day2;
|
||||
using AdventOfCode2023.Day3;
|
||||
using AdventOfCode2023.Day4;
|
||||
using AdventOfCode2023.Day5;
|
||||
|
||||
namespace AdventOfCode2023
|
||||
{
|
||||
@ -16,6 +17,8 @@ namespace AdventOfCode2023
|
||||
new Day3_2(),
|
||||
new Day4_1(),
|
||||
new Day4_2(),
|
||||
new Day5_1(),
|
||||
new Day5_2(),
|
||||
};
|
||||
|
||||
private static void ListDays()
|
||||
|
@ -106,5 +106,23 @@ namespace AdventOfCode2023Tests
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Day5
|
||||
|
||||
[Test]
|
||||
public void Day5_1Test()
|
||||
{
|
||||
var day5_1 = new Day5_1("seeds: 79 14 55 13\r\n\r\nseed-to-soil map:\r\n50 98 2\r\n52 50 48\r\n\r\nsoil-to-fertilizer map:\r\n0 15 37\r\n37 52 2\r\n39 0 15\r\n\r\nfertilizer-to-water map:\r\n49 53 8\r\n0 11 42\r\n42 0 7\r\n57 7 4\r\n\r\nwater-to-light map:\r\n88 18 7\r\n18 25 70\r\n\r\nlight-to-temperature map:\r\n45 77 23\r\n81 45 19\r\n68 64 13\r\n\r\ntemperature-to-humidity map:\r\n0 69 1\r\n1 0 69\r\n\r\nhumidity-to-location map:\r\n60 56 37\r\n56 93 4");
|
||||
Assert.That(day5_1.Execute(), Is.EqualTo("35"));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Day5_2Test()
|
||||
{
|
||||
var day5_2 = new Day5_2("seeds: 79 14 55 13\r\n\r\nseed-to-soil map:\r\n50 98 2\r\n52 50 48\r\n\r\nsoil-to-fertilizer map:\r\n0 15 37\r\n37 52 2\r\n39 0 15\r\n\r\nfertilizer-to-water map:\r\n49 53 8\r\n0 11 42\r\n42 0 7\r\n57 7 4\r\n\r\nwater-to-light map:\r\n88 18 7\r\n18 25 70\r\n\r\nlight-to-temperature map:\r\n45 77 23\r\n81 45 19\r\n68 64 13\r\n\r\ntemperature-to-humidity map:\r\n0 69 1\r\n1 0 69\r\n\r\nhumidity-to-location map:\r\n60 56 37\r\n56 93 4");
|
||||
Assert.That(day5_2.Execute(), Is.EqualTo("46"));
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
global using NUnit.Framework;
|
||||
global using AdventOfCode2023;
|
||||
global using AdventOfCode2023.Day1;
|
||||
global using AdventOfCode2023.Day2;
|
||||
global using AdventOfCode2023.Day3;
|
||||
global using AdventOfCode2023.Day4;
|
||||
global using AdventOfCode2023.Day4;
|
||||
global using AdventOfCode2023.Day5;
|
Loading…
Reference in New Issue
Block a user