WIP day 5 p2 with ranges
This commit is contained in:
parent
0d70d7bd29
commit
e42b027728
@ -1,4 +1,5 @@
|
||||
using AdventOfCode.Core;
|
||||
using AdventOfCode.Core.Shared.Grid;
|
||||
|
||||
namespace AdventOfCode.Solutions._2023
|
||||
{
|
||||
@ -78,30 +79,11 @@ namespace AdventOfCode.Solutions._2023
|
||||
List<InOutMapper> location = MapData(data, stringSeperator, data.Count);
|
||||
|
||||
long[] seedData = data[0].Split(' ').Skip(1).Select(long.Parse).ToArray();
|
||||
List<Line> ranges = [];
|
||||
long lowestLocation = long.MaxValue;
|
||||
|
||||
List<long> proccessed = [];
|
||||
// change to use ranges and shift those
|
||||
for (int seedDataIndex = 0; seedDataIndex < seedData.Length; seedDataIndex += 2)
|
||||
for(int index = 0; index < seedData.Length / 2; index++)
|
||||
{
|
||||
for (long seedLocaton = seedData[seedDataIndex]; seedLocaton < seedData[seedDataIndex] + seedData[seedDataIndex + 1]; seedLocaton++)
|
||||
{
|
||||
if (proccessed.Contains(seedLocaton))
|
||||
continue;
|
||||
|
||||
long soilLocation = GetTargetLocation(soil, seedLocaton);
|
||||
long fertilizerLocation = GetTargetLocation(fertilizer, soilLocation);
|
||||
long waterLocation = GetTargetLocation(water, fertilizerLocation);
|
||||
long lightLocation = GetTargetLocation(light, waterLocation);
|
||||
long temperatureLocation = GetTargetLocation(temperature, lightLocation);
|
||||
long humidityLocation = GetTargetLocation(humidity, temperatureLocation);
|
||||
long locationLocation = GetTargetLocation(location, humidityLocation);
|
||||
|
||||
if (locationLocation < lowestLocation)
|
||||
lowestLocation = locationLocation;
|
||||
|
||||
proccessed.Add(seedLocaton);
|
||||
}
|
||||
ranges.Add(new Line(new Point(seedData[index], 0), seedData[index + 1]));
|
||||
}
|
||||
|
||||
return lowestLocation.ToString();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user