예제 #1
0
        public void Validate_pqrstuv1048970()
        {
            AdventCoin   coin     = new AdventCoin("pqrstuv", 1048970);
            const string expected = "000006136EF2FF3B291C85725F17325C";
            string       actual   = coin.Md5Hash;

            Assert.AreEqual(actual, expected);
        }
예제 #2
0
        public void Validate_abcdef609043()
        {
            AdventCoin   coin     = new AdventCoin("abcdef", 609043);
            const string expected = "000001DBBFA3A5C83A2D506429C7B00E";
            string       actual   = coin.Md5Hash;

            Assert.AreEqual(actual, expected);
        }
예제 #3
0
        private static void Main(string[] args)
        {
            AdventCoin coin = new AdventCoin("ckczppom", 0);

            // Part 1
            string part1 = GetLowestNumber(coin, "00000");

            // Part 2
            coin.Value = 0;
            string part2 = GetLowestNumber(coin, "000000");

            Console.WriteLine(part1);
            Console.WriteLine(part2);
            Console.Write("Press any key...");
            Console.ReadKey();
        }
예제 #4
0
        private static string GetLowestNumber(AdventCoin coin, string s)
        {
            bool mined = false;

            while (!mined)
            {
                if (coin.Value % 100000 == 0)
                {
                    Console.WriteLine($"Processed {coin.Value} values...");
                }
                if (coin.Match(s))
                {
                    mined = true;
                    break;
                }
                coin.Value++;
            }
            return($"Coin starting with {s} mined with value {coin.Value}. Hash: {coin.Md5Hash}");
        }