Пример #1
0
        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"));
        }
Пример #2
0
        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());
        }
Пример #3
0
        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");
        }
Пример #4
0
        public void TiesAreBrokenAlphabetically()
        {
            var cc = new ChecksumComputer();

            Assert.Equal("abcde", cc.Compute("a-b-c-d-e-f-g-h"));
        }