mirror of
https://github.com/jcreek/advent-of-code.git
synced 2026-07-13 19:23:46 +00:00
feat(*): Update 2021-14 part 2 - slightly more efficient but nowhere close to being done
This commit is contained in:
@@ -14,4 +14,11 @@
|
|||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Creek.HelpfulExtensions" Version="1.4.3" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="6.0.0" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+10
-8
@@ -1,4 +1,6 @@
|
|||||||
using System.Diagnostics;
|
using Creek.HelpfulExtensions;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace Day14
|
namespace Day14
|
||||||
{
|
{
|
||||||
@@ -135,20 +137,20 @@ namespace Day14
|
|||||||
for (int i = 0; i < temporaryTemplate.Count() - 1; i++)
|
for (int i = 0; i < temporaryTemplate.Count() - 1; i++)
|
||||||
{
|
{
|
||||||
char insertValue;
|
char insertValue;
|
||||||
rules.TryGetValue((temporaryTemplate[i], temporaryTemplate[i + 1]), out insertValue);
|
|
||||||
|
|
||||||
if (char.IsLetter(insertValue))
|
//using ("First".DisposableStopWatch())
|
||||||
{
|
//{
|
||||||
|
rules.TryGetValue((temporaryTemplate[i], temporaryTemplate[i + 1]), out insertValue);
|
||||||
|
//}
|
||||||
|
|
||||||
temporaryList.AddAfter(pointer, insertValue);
|
temporaryList.AddAfter(pointer, insertValue);
|
||||||
|
|
||||||
// Move on an extra position as we have added a node
|
// Move on an extra position as we have added a node
|
||||||
pointer = pointer.Next;
|
pointer = pointer.Next.Next;
|
||||||
}
|
|
||||||
|
|
||||||
pointer = pointer.Next;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
polymerTemplate = String.Join("", temporaryList);
|
polymerTemplate = String.Join("", temporaryList);
|
||||||
|
//polymerTemplate = string.Concat(temporaryList); // this is slower
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CompleteStep(ref string polymerTemplate, ref string[] lines, List<Rule> rules)
|
static void CompleteStep(ref string polymerTemplate, ref string[] lines, List<Rule> rules)
|
||||||
|
|||||||
Reference in New Issue
Block a user