public void ChecksumIsCorrectForSamples() { var cc = new ChecksumComputer(); Assert.Equal("abxyz", cc.Compute("aaaaa-bbb-z-y-x")); Assert.Equal("oarel", cc.Compute("not-a-real-room")); }
public string Solve(string[] input) { var parser = new EntryParser(); var list = input.Select(parser.Parse); var cc = new ChecksumComputer(); var realRooms = list.Where(r => r.DeclaredChecksum == cc.Compute(r.EncryptedName)); return(realRooms.Sum(r => r.SectorId).ToString()); }
public string Solve(string[] input) { var parser = new EntryParser(); var list = input.Select(parser.Parse); var cc = new ChecksumComputer(); var realRooms = list.Where(r => r.DeclaredChecksum == cc.Compute(r.EncryptedName)); var shifter = new Shifter(); var decrypted = realRooms.Select(r => new { name = shifter.Shift(r.EncryptedName, r.SectorId), r.SectorId }); var northPole = decrypted.FirstOrDefault(x => x.name.Contains("northpole")); return(northPole?.SectorId.ToString() ?? "Not found"); }
public void TiesAreBrokenAlphabetically() { var cc = new ChecksumComputer(); Assert.Equal("abcde", cc.Compute("a-b-c-d-e-f-g-h")); }