aoc 1+2
This commit is contained in:
22
www/statics/aoc/2018/05_solution-2.linq
Normal file
22
www/statics/aoc/2018/05_solution-2.linq
Normal file
@@ -0,0 +1,22 @@
|
||||
<Query Kind="Statements" />
|
||||
|
||||
|
||||
var poly0 = File.ReadAllText(Path.Combine(Path.GetDirectoryName(Util.CurrentQueryPath), @"05_input.txt")).Trim();
|
||||
|
||||
var r = new List<(char, int)>();
|
||||
|
||||
for (var cc = 'a'; cc <= 'z'; cc++)
|
||||
{
|
||||
var poly = poly0;
|
||||
poly = poly.Replace(cc + "", "");
|
||||
poly = poly.Replace(char.ToUpper(cc) + "", "");
|
||||
for (; ; )
|
||||
{
|
||||
var len = poly.Length;
|
||||
for (var i = 'a'; i <= 'z'; i++) poly = poly.Replace(i + "" + char.ToUpper(i), "");
|
||||
for (var i = 'a'; i <= 'z'; i++) poly = poly.Replace(char.ToUpper(i) + "" + i, "");
|
||||
if (len == poly.Length) { r.Add((cc, poly.Length)); break; }
|
||||
}
|
||||
}
|
||||
|
||||
r.OrderBy(p => p.Item2).First().Item2.Dump();
|
||||
Reference in New Issue
Block a user