mirror of
https://github.com/jcreek/advent-of-code.git
synced 2026-07-12 18:53:47 +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>
|
||||
</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>
|
||||
|
||||
+11
-9
@@ -1,4 +1,6 @@
|
||||
using System.Diagnostics;
|
||||
using Creek.HelpfulExtensions;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Day14
|
||||
{
|
||||
@@ -135,20 +137,20 @@ namespace Day14
|
||||
for (int i = 0; i < temporaryTemplate.Count() - 1; i++)
|
||||
{
|
||||
char insertValue;
|
||||
|
||||
//using ("First".DisposableStopWatch())
|
||||
//{
|
||||
rules.TryGetValue((temporaryTemplate[i], temporaryTemplate[i + 1]), out insertValue);
|
||||
//}
|
||||
|
||||
if (char.IsLetter(insertValue))
|
||||
{
|
||||
temporaryList.AddAfter(pointer, insertValue);
|
||||
temporaryList.AddAfter(pointer, insertValue);
|
||||
|
||||
// Move on an extra position as we have added a node
|
||||
pointer = pointer.Next;
|
||||
}
|
||||
|
||||
pointer = pointer.Next;
|
||||
// Move on an extra position as we have added a node
|
||||
pointer = pointer.Next.Next;
|
||||
}
|
||||
|
||||
polymerTemplate = String.Join("", temporaryList);
|
||||
//polymerTemplate = string.Concat(temporaryList); // this is slower
|
||||
}
|
||||
|
||||
static void CompleteStep(ref string polymerTemplate, ref string[] lines, List<Rule> rules)
|
||||
|
||||
Reference in New Issue
Block a user