feat(*): Update 2021-14 part 2 - slightly more efficient but nowhere close to being done

This commit is contained in:
Josh Creek
2021-12-14 23:18:08 +00:00
parent a35f71f02e
commit 479a23c235
2 changed files with 18 additions and 9 deletions
+7
View File
@@ -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
View File
@@ -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)