Exemple #1
0
        public void RoundTrips(string line, string password)
        {
            var scrambled = Scrambler.ProcessLine(line, password);

            Console.Out.WriteLine(scrambled);
            var unscrambled = Scrambler.UnProcessLine(line, scrambled);

            Assert.AreEqual(password, unscrambled);
        }
Exemple #2
0
        public void Examples(string line, string password, string expectedPassword)
        {
            var newPassword = Scrambler.ProcessLine(line, password);

            Assert.AreEqual(expectedPassword, newPassword);

            var rtPassword = Scrambler.UnProcessLine(line, newPassword);

            Assert.AreEqual(password, rtPassword);
        }
Exemple #3
0
        public void Part2()
        {
            var    scrambledPassword = "******";
            string unscrambled       = File.ReadAllLines($"{TestContext.CurrentContext.TestDirectory}\\input.txt").Reverse().Aggregate(scrambledPassword, (password, line) =>
            {
                var thisUnscrambled = Scrambler.UnProcessLine(line, password);
                return(thisUnscrambled);
            });

            Console.Out.WriteLine(unscrambled);
        }
Exemple #4
0
        public void Part1()
        {
            var    initialPassword = "******";
            string scrambled       = File.ReadAllLines($"{TestContext.CurrentContext.TestDirectory}\\input.txt").Aggregate(initialPassword, (password, line) =>
            {
                var thisScrambled = Scrambler.ProcessLine(line, password);
                var orig          = Scrambler.UnProcessLine(line, thisScrambled);
                Assert.AreEqual(password, orig);
                return(thisScrambled);
            });

            Console.Out.WriteLine(scrambled);
        }