1
0
www.mikescher.com/www/statics/aoc/2018/02_solution-2.linq
2019-12-02 14:27:20 +01:00

11 lines
399 B
C#

<Query Kind="Statements" />
var data = File.ReadAllLines(Path.Combine(Path.GetDirectoryName(Util.CurrentQueryPath), @"02_input.txt"));
data
.Select(d1 => data.Where(d2 => d1.Zip(d2.ToCharArray(), (a,b) => a!=b).Count(p=>p)==1 ))
.Where(p => p.Any())
.Select(p => p.First())
.Aggregate((a, b) => new string(a.Zip(b.ToCharArray(), (u,v)=>(u==v?u:'_')).ToArray()) )
.Replace("_", "")
.Dump();