예제 #1
0
        public static int GetValidCount()
        {
            int valid    = 0;
            var patterns = AdventOfCode.Utilities.File.GetLines("\r\n", "Data\\Day2.txt");

            foreach (var p in patterns)
            {
                var pp = new PasswordPolicy(p);
                if (pp.ValidByIndex)
                {
                    valid++;
                }
            }
            return(valid);
        }
예제 #2
0
        private static bool IsRightPasswordPartTwo(PasswordPolicy passwordPolicy)
        {
            int counter = 0;

            if (passwordPolicy.Password[passwordPolicy.Min - 1] == passwordPolicy.SingleCharacter)
            {
                counter++;
            }
            if (passwordPolicy.Password[passwordPolicy.Max - 1] == passwordPolicy.SingleCharacter)
            {
                counter++;
            }

            return(MAX_OCCURENCES == counter);
        }
예제 #3
0
        public void Day2()
        {
            Console.WriteLine("Day: 2");
            List <PasswordPolicy> passwordList = new List <PasswordPolicy>();

            IEnumerable <string> rawLines = File.ReadLines("D:\\payno\\Documents\\GitHub\\AdventOfCode2020\\AdventOfCode\\InputData\\Day2Input.txt");

            // get passwords
            foreach (var line in rawLines)
            {
                PasswordPolicy p = new PasswordPolicy();

                var lower = line.Split('-');
                p.LowerLimit = int.Parse(lower[0]);

                var rest = lower[1].Split(' ');

                p.UpperLimit = int.Parse(rest[0]);

                p.RequiredCharacter = char.Parse(rest[1].Remove(1, 1));

                p.password = rest[2];

                passwordList.Add(p);
            }


            int i = 0;

            //get how many are valid
            foreach (var p in passwordList)
            {
                p.ComputeIsValid();
                if (p.IsValid)
                {
                    i++;
                }
            }

            Console.WriteLine($"Valid Passwords: {i}");
        }
예제 #4
0
        public static void Day2()
        {
            var list = new[] { "16-18 h: hhhhhhhhhhhhhhhhhh", "17-18 d: ddddddddddddddddzn", "15-18 c: cccccccccccccczcczc", "3-9 r: pplzctdrc", "4-14 d: lxdmddfddddddd", "8-14 v: pvxlknfvplgktv", "11-13 h: hphhhhhhhfhshhhhh", "1-4 l: hbljb", "1-2 x: wxqzlvt", "1-5 g: dxggdggb", "5-13 f: lfgdplfffxffswck", "6-7 z: zzzzgzzzz", "1-7 c: cccclcchrkctfhc", "3-7 c: ccjccqzcc", "15-16 x: rxxchpvgxxhxkxxw", "3-5 h: hbxjg", "3-7 q: sffnxxqvdfsnqlhqpq", "8-11 h: hhhhhhhlhhh", "7-8 w: bxwzdlwr", "4-5 x: xxxxp", "4-7 x: xxxxxxxx", "2-18 l: lllllllllllllllllrll", "6-10 n: nnnnnngnznn", "12-13 c: ccccccccccchc", "2-6 g: ggqngxgbggc", "4-5 k: xdztx", "4-9 m: txskmsnxvqjhlp", "9-11 w: wwtxmsjwjwlw", "12-16 g: cgggpkhggqkgrjcbx", "9-11 s: sxsssmssvszs", "17-18 c: cccccccccclccsccchcc", "7-8 z: stpgzwlqm", "9-19 q: qqqqqqqqqqqqqqqqqqqq", "4-5 p: hpvtpfgwp", "8-9 m: mmmmmmqmm", "11-12 s: ssswsssssspts", "2-4 j: jjdr", "17-18 k: kvkkmlkkkkkkfklkkkkk", "1-4 b: bbbwb", "2-12 c: cccccccccccccc", "14-15 l: llllllllllplllllllll", "7-10 c: czcccsvnrbccc", "11-12 d: nfmvdlxbfwzq", "8-10 t: tvtttttzts", "5-6 g: wggghg", "11-16 d: ztfdkggclvzmvsxd", "16-17 v: vvvvvvbvvpvxvvvhv", "3-7 w: vrswklnfnjzkm", "1-18 s: bsssssssssssssssshss", "8-10 g: vdzldttzgm", "19-20 n: nnnnnnnnnnnnnnnnnnrb", "1-4 x: xxxqxxxxx", "11-13 m: xmmxmmmmgmwmmm", "4-5 j: pzfjjsjjmcm", "1-7 j: jsjsmjj", "7-8 j: nqkkljhbj", "4-5 w: wmsbqhmwdjns", "4-7 j: jbjjcjcf", "2-7 f: jhsxldwf", "3-4 f: vmff", "5-7 z: fscmzjqs", "2-10 g: ggtfwzpbkgqqlzwmbm", "5-6 j: jjwbdjj", "13-15 b: bbbbbbbbkbbbvbbbb", "4-6 t: qdthtt", "1-8 m: kmmmmmmvmmmmm", "4-8 g: gbgqgtcglvgggcg", "3-4 h: ghjn", "3-8 b: mgbzbjvbkbpbd", "11-17 k: kkkktskgkkkfgzkkk", "1-6 f: ftnvfgtrlcs", "3-13 r: hrrzrfrfpvdlrnrcrcs", "3-8 l: gzljpllvl", "3-11 h: hchjhhnhhnhvhhhhx", "9-16 s: srssssssssskpldsqss", "4-10 n: nnbnnnwnnwnnnxnn", "3-4 n: nnnp", "11-19 z: nznpcdnxkwznzlpvcwzj", "4-7 w: wwwrwtwncwvwwwwx", "3-4 s: bkgs", "2-16 z: nzlcmlvqdcmmcnphb", "1-15 z: zzzzzzzzzzzzzzzzzz", "9-10 t: tmgttdtqtttttwbgttt", "1-2 h: hhhhhmhmkgxhnhw", "4-5 h: hlhhh", "9-15 h: xhhhhhchhhznphh", "5-8 w: jwphwwwj", "4-5 z: lztsz", "10-11 c: mhtdcdhggccgfck", "3-8 t: ccttgcktz", "1-12 m: smmmmxmmmgmx", "1-12 r: srrrrrrrrrrlrrrrr", "2-5 h: khhzhrqr", "3-4 m: mmztmm", "2-5 f: fbffqf", "1-11 p: zpppppppnphppx", "5-12 z: pqrzlwztvzjfzbt", "8-12 b: bbbbbbbdbbbcb", "3-4 g: ghqg", "7-10 m: mmmmmmmmmmmm", "5-14 q: jblkqbqpmqwsqt", "6-8 r: rrrtrlzltfrrrgrr", "9-14 r: rrrrrzrrjrrrgmr", "9-10 m: tmshdggksmv", "10-17 d: dddddddddcddddddf", "6-7 f: ffffffx", "9-19 j: jfjljzjcjjzjjjfjpjj", "2-6 h: jhxmhh", "1-7 g: wgggggzggxmggg", "5-6 n: nlgnlx", "4-7 t: thzttttt", "4-6 x: xhnxjx", "14-16 p: ppppppppppppppppp", "2-4 s: ssps", "7-15 k: bzfljhskslxlznwvphg", "6-7 j: dkjjsgk", "9-11 p: ppppppppkpmpp", "5-8 t: tzcttttttt", "8-11 d: dddddddgddld", "3-9 w: dwwhwbwwwwwzwtwxw", "2-3 x: xxwxmw", "1-5 g: gdlvg", "4-6 c: cccmcrccccccc", "1-11 f: ffffffffffnff", "10-11 l: lgqgnwlhgdlvdlv", "3-7 v: cjvvvvnvjvjvgvkx", "4-5 v: vvvsv", "13-15 t: tttttrtttttttth", "11-12 q: nccsqqhqqqqqlqqqqq", "2-7 p: pspppppppp", "4-6 g: gglggg", "17-18 p: hwpkcxvppzxxvpjzpp", "1-3 b: dlfz", "11-12 p: ppppppppppfpdppp", "1-2 s: ssszdss", "2-15 b: nbsblthmngvbqvbh", "1-6 q: sqqqqbqq", "4-11 q: tgmtqqrxfsvrzhc", "8-13 q: qqqqzqqqqqqmqqqjqq", "9-17 n: nnnnnnnnnnnnnnnnpnnn", "6-9 h: rmhrlkhskbhhq", "5-6 n: qnnjnn", "4-6 l: lxlllkvdltgcfl", "12-15 f: fflffffpfvftffwff", "13-16 t: fpwmwmvtqbvxtvtt", "7-8 w: kwwwjgwmwbw", "1-2 x: xxnvmbcmxhnkkgfrr", "3-7 f: rpcnzvjgh", "13-15 r: rrwrkrrrrrrrdrbr", "11-13 h: ghnzvhhhhwhchmh", "7-8 h: hhhhhhnv", "5-6 l: kgllll", "1-4 k: kqsjblck", "6-8 c: crxxccccgc", "2-13 g: fvmhpbqkgvbwqvbldb", "4-7 g: ggglggmgggkggg", "6-7 n: znnrnpnn", "12-15 j: jjqjzjjchjmjzsgppss", "4-5 k: kkkkk", "12-16 r: rrrrrrrrrrrcrrznrz", "10-12 w: hdwsvqpwzvtx", "9-11 b: brbtbwbbjbbbbbb", "6-8 q: nqkvkqdqrq", "3-5 n: pjcnd", "9-11 q: qqqqqqqqpqqqq", "6-7 b: zdbbfpqbvbbgbnq", "11-14 g: dxvgpggnpngpqgn", "8-11 z: zzzzzzzczzq", "8-18 z: nzczzlkcchpzdkrpvzrd", "2-4 d: fwdhl", "12-13 m: mmmqllmmmmhnf", "6-8 b: bmbbcbbbznnbd", "18-19 z: zkzzzzzzzzzzzzzzzzz", "4-10 m: smkkrpqznmnfdprq", "7-8 j: jjjjjjhsj", "10-15 t: trpttgcttttttbtt", "6-7 t: tttttltttttttt", "7-13 x: bxxcxxvxknqcxsx", "6-10 j: zjrrtjwxfjhhtcsktslf", "3-5 m: zjmms", "11-14 v: vvvvvvvkvvvvvvv", "1-2 c: ccch", "13-14 v: vvvsvvvvvvvvvv", "9-12 g: fgkgxgggcjdg", "4-6 t: ttpxtgntzwtx", "10-12 g: gggggggggkgbg", "1-3 l: llllw", "7-12 d: nddvldndjcdpdddz", "2-5 w: wwtlwwvdww", "6-11 c: fcccccccdcc", "12-19 s: sjsssssssssssshssss", "19-20 t: ttttttttttttttttttkf", "7-11 z: zpfgzczcxzmclzzz", "2-7 d: sddlpvdqzzlqfkjkbb", "2-7 k: dkmlkckm", "4-8 w: wwwwwwswww", "1-3 d: pddd", "1-9 r: chrrrrrrr", "17-19 t: ttttttttttttttttptvt", "17-18 v: xvvvkvvvvxvsvhbvvv", "6-11 j: njjjjcpjjjbjhqj", "1-3 s: ssss", "15-16 k: kkkckkqgkkxkkkrp", "6-7 b: mgzhbbb", "9-12 w: wjwxwwpxxtwvwwjnnw", "2-5 x: xxlwcpzfx", "4-11 j: jjjxjjjjjjcj", "6-17 c: qcccsvvzfpccccfchcc", "3-4 c: scbjdmjhtlcdvbq", "8-9 b: fngpbvfsctl", "15-16 r: rrrrrrrqrrrrrrdlt", "5-10 v: tvqlvvvtrvlfkwsvlvn", "6-8 q: qqsqfqqqq", "8-9 m: mmmmmmmms", "8-12 r: rxrrprvcrrjd", "19-20 c: cncccqwnbsvccclcjkcc", "2-4 b: mmjg", "12-13 l: slwjlqlslllll", "2-8 m: fmmppmmmmtmzmmmm", "4-13 l: llllmllllllllltz", "6-11 f: ffffffhtffff", "1-6 g: gngfzbgx", "1-5 f: fwfmfrfxf", "16-17 t: ttttttttttttttttt", "2-7 w: twsdwvj", "6-13 m: mmksmfnmdxtmhmmxm", "1-6 b: bbbjbbnbzwgrb", "13-15 c: ccccccccccccccsccc", "7-8 k: kskkkgkkk", "6-7 g: gggmgbzg", "17-18 k: mckjkfkdfqkxgtrcrch", "4-5 g: xglggggs", "2-4 d: ddddddd", "5-7 s: nlpzsss", "5-12 w: ngwpwprvlftr", "15-17 p: psgjvphpbppzpprpp", "1-5 m: lljdr", "6-8 h: hnzhhqxh", "4-7 g: mmccqwfvlqrks", "12-14 l: lllllllllllllll", "2-3 c: cqfc", "15-16 z: zzzzzzzzzzzzzzzz", "6-7 v: gkzxvvvdbvnp", "7-8 z: zzzjzzvc", "13-18 v: vvvvvvvvvvvvkvvvvlv", "1-12 p: pppppppkppppppp", "10-12 v: vvvvvvvvvtvvv", "5-6 s: qkpsqz", "5-6 t: tgthtlt", "1-5 z: zzzzzz", "6-7 j: jjjjjjhj", "4-5 b: lbbqdfrbbv", "4-6 n: jvmxtfwnqpdhn", "2-5 r: mcmrf", "8-10 s: sssssssggsss", "6-9 f: ffbflgzsfftxqg", "1-18 p: pppppppppppppppppp", "3-13 b: bbbbdfbbbbbnbbbblcb", "5-6 d: drddpk", "4-5 h: jhhhdh", "12-18 x: wxtsqsrxtsxxxvhxfxx", "5-6 q: qmxdnz", "6-16 q: qqwqfqqqzqqqqfqqq", "4-10 x: xxxgxxxznx", "2-3 x: xndnnb", "4-5 g: hcgff", "5-6 s: wsgjpgssssssdssssss", "16-18 k: kkkkkkkkkkkkkkkkkk", "5-6 k: kkkkpqkk", "13-19 r: rrrrrrrrgrkrrrrrrrr", "10-11 s: vgnbshssjcpss", "3-5 f: qfhjmjkcgv", "3-4 q: nrtnvbsmbwpq", "8-18 j: jjjrjjdtjmjjkjwzjjk", "4-14 t: tttgtttttttbtxt", "5-6 q: qqqqtj", "14-17 b: bbbbbhjffbbtbbbbb", "9-18 x: rxxxwxxxxxxxxxxxxc", "3-9 f: hgjjfkvlflhbtxpb", "7-19 n: nnmndnknnlnjnnnnnnz", "5-8 m: mbmlmmfpgmwmm", "7-8 j: jjjjjsdkjg", "3-8 p: hlpjkpjjvbrgpw", "10-11 t: tttttttttptt", "6-10 b: bbbbbthbbd", "3-11 l: xvlknhhglhcgvk", "7-17 j: mpxjmcwwqqjtprwgjj", "14-17 v: vvvvvvvvsvvvvhvvvv", "16-17 p: pppppppdpwpppppppp", "3-4 h: hhdr", "8-9 v: bvvvvvvfs", "6-12 p: pdpppbppnqpxp", "3-6 w: jlwwjvcwwhwjrgwzjkqw", "3-4 c: zqkzcc", "2-7 h: hzhhhhv", "1-9 g: mgjlggdznj", "3-6 x: nxjxxkxhfx", "7-11 m: pmpmmmmmmmmmtmm", "9-11 t: tttttttttttt", "3-4 n: nnnpqnbfnnnzn", "10-17 b: bbqbbbjbbhbbgbthxb", "2-8 n: qfqnjhhjsvcvcnnjnnhn", "3-6 n: jsgnnn", "1-2 n: nntknsnsp", "5-7 s: ssssssss", "8-9 l: kllllllllh", "4-9 k: vkkkkkkkkk", "3-8 x: hxdxbxnmxx", "5-8 f: pfmvlbffff", "13-18 n: rnncfnnntnrgxnnsnn", "1-2 d: jxdd", "3-5 p: bcfdp", "2-4 k: hklkk", "13-17 w: wwwwxwwwwldwwwwwm", "4-5 z: gzzzgczz", "14-15 g: gggggggggggggqg", "9-10 x: jzwnmqhgqkxhxb", "3-4 z: fszz", "13-14 l: nlllllllllrlflllx", "1-3 r: rrrr", "15-16 c: ccccccckcccccccccl", "1-6 h: hhhhhhhphhhhjfhhwjh", "5-7 r: gvcprfrrgtqjkgsbcb", "12-14 v: vvvhvvvvvvvvvvvvv", "18-19 l: llllllrllllllllllpgd", "13-14 x: xxxxxxxxxxxxxxx", "7-13 d: pcgbdmkhnnxqdhb", "9-11 c: ccccccccjcf", "14-17 m: mmmmmmmmmmmsmmmkmkm", "7-16 p: jblsmjhskpmcflvzqbb", "1-3 p: pqpzfpw", "6-8 h: whhtglkhshhzhh", "1-9 x: xxjxxxxxxxx", "2-3 d: ddgwh", "3-4 z: rzzz", "12-13 p: ppppppppppppppkp", "2-6 f: fbffjbxz", "4-7 f: dmkrhsfnffg", "4-6 p: ppppppppp", "17-19 d: ddnwdddddddnddddndgd", "4-8 n: bxchqdknggfjqzcvdwzv", "3-19 z: zzzzzzzzzzzzzzzzzzpz", "2-11 h: hhthvhrhpkhfrljhf", "7-8 s: sssssgsg", "1-3 p: hpsp", "4-5 d: wdkdd", "2-4 j: fjpd", "2-8 l: dsvhdlpl", "11-15 b: bkbbqpbqbbbbbbfbr", "4-9 j: vffrxjvglzq", "17-19 q: qqqqqqqqqqqqqqqqqqqq", "2-9 g: sbpcvnmsghrm", "3-6 r: kxwwnfbqv", "9-12 w: qxwwwwdwwcww", "4-8 t: tttztttxt", "5-6 k: sklmkk", "1-15 t: qttstmlgtxjfwthj", "12-15 s: sssssssssssssssss", "1-8 d: ddtddbddj", "7-14 m: rmmhmmmmzvmmmkxmmmdm", "5-6 n: nnnnnwn", "7-8 m: mmmmmmghmm", "1-3 q: qpqqgkc", "3-10 q: qqqqqzqqqqqqb", "1-7 p: ppppppqp", "3-5 c: nbkfmcccpkjccv", "14-15 q: qqqqxqqqqqqqqqq", "8-9 p: plgpblsfp", "10-13 w: wwtwwwwwwwwvwww", "8-15 k: kkwjkkkknkdkkkkk", "6-7 l: lllllmkl", "8-9 l: lllllllxgl", "10-12 p: gpmpppppppvpvpqpx", "4-7 x: rxbxxxzqx", "1-10 h: dhhhhhhhhxh", "12-18 v: vnwvgvprbfgvvgnvvv", "4-17 n: xbdnmnrrcfmczhjxndr", "8-9 k: kkkkkckqskkk", "9-12 l: rblxmkxmlfflnfpg", "6-11 q: vqlqqqqqqqqqqqqnq", "8-10 j: lxpjjjjjwjglcjhjjj", "4-6 x: xtxxjx", "1-2 w: wwwww", "5-8 h: hhhhkhjhhwh", "7-10 s: stjsssdssdl", "2-12 p: xwnzxpzwnxzc", "4-5 v: vkvvvvk", "1-6 k: ksgmxkkdcfqgxcxm", "16-17 g: ggggggggggggggggg", "9-10 g: ggggggggmcg", "9-12 m: mmmmjzmpmmmx", "2-3 r: lrrlrtmbcl", "2-3 s: sqss", "9-11 k: kkkkkkkkdknkdpkbkkk", "13-15 t: tttttttttttttttt", "3-5 p: ppkfkn", "4-5 d: dddtk", "9-13 b: hbmtbzspcqtwqfkbbbdb", "5-7 d: dddtddhdddddddmddddd", "6-7 q: qqqqqsl", "8-9 k: kkkkkkkkk", "3-7 d: gdcwjglkw", "6-8 s: srtgjdsn", "8-9 r: fxrgqrsrs", "5-10 x: xxxxlqxxxxxxxxx", "2-3 s: ssskpmzhqpp", "2-10 q: qqqqqqqqqqq", "5-12 r: srnqrrhkgrjr", "1-3 s: fsmsssss", "1-2 f: ptbtfm", "9-10 b: lbbgrbqhnhbcnmb", "1-3 x: xxnx", "1-3 w: gjfh", "3-8 q: qwqtdvqql", "3-5 f: zfmcgpdlp", "6-8 h: vhhhhhbh", "4-12 c: lkbcvnztjnpxvlcf", "4-6 w: wwwwwwwpwwd", "10-15 v: vvwvvvdvvzslhvz", "4-7 c: jpvmlffcgdkmcl", "6-7 l: llllwlll", "8-9 m: mmlmlmmnmmm", "14-15 m: mmmmmmmmmjnmmmmkz", "3-6 t: thttttt", "3-14 t: kvltjtmkbvhtbt", "6-7 j: jjjjvjjj", "5-6 m: dmnmmmknqwmmmkm", "8-12 s: ssksssssssssr", "2-6 r: srvrqrdwxnprrvpqhd", "6-11 l: lhllkdxlllln", "2-4 t: qmmd", "3-12 s: sssssssssssrs", "17-18 t: ttttttttttttttttqf", "2-5 r: qcbrr", "14-16 h: hhghppchchfhhhlhm", "15-17 g: nprhksgfwwjgggkkc", "7-8 g: gggggggn", "5-15 g: drgkscpgchvzmjs", "1-3 l: fsztllllll", "4-5 p: ptftp", "5-6 j: jjjjjj", "1-4 f: ffjfhz", "9-10 q: qqtqwslqqg", "6-20 h: hgklqhcmhfmxvcnxvxch", "7-8 c: jcwbrvcc", "8-10 m: mwmmmmmsmvmsf", "8-9 v: cfvrvbvzvvvgvpk", "14-17 s: srkhgbthtssxszqvsbsx", "4-7 b: sbpffpbxv", "9-11 z: zzzzzzzzzzzfztz", "9-12 v: hmvvvvvvgvhkvvcvvvb", "1-6 c: fkcjcwqccs", "13-15 r: rrrrrrrrrrrrrrrrrnr", "3-4 g: ghgg", "6-7 b: wbbbbbbbbbb", "7-8 t: trttdtttjbktt", "3-4 t: wtttct", "2-4 c: xccc", "5-7 s: ssspvlrslxn", "1-3 s: lsss", "4-6 h: hjhjhghh", "11-17 s: ssjrsscslskssqssn", "1-4 j: rzjjjv", "7-8 f: tvssgbrkqdtc", "5-8 w: wrjklbblzwdclwnwjwx", "4-8 r: srrrrrrr", "1-7 g: ggggggg", "7-9 m: msmcmmmbwgxkmmnmm", "7-10 w: wrwwwvwwww", "7-11 g: rgkzgdgpldgc", "11-16 p: pppdpzvzpppqrwppv", "3-5 n: hnnnnn", "10-12 n: nnnnqnnnnmnwnn", "6-9 k: spdbkgkxzlqkkkkk", "2-5 j: jjjjjjjj", "2-4 n: njnzn", "7-8 c: cclmcchjcbc", "13-16 k: jkrxkmtxfkxfccdklk", "8-9 f: fffffffjkfffnpffvfff", "8-10 x: xgmdzfxxsc", "7-12 k: fknkjrklsrkkkhqknkv", "10-12 l: lslzlpllblllll", "3-4 f: fffvfff", "16-19 j: jjfjjjjjjhjjjjjjjjj", "1-3 h: hhhhhhhhhhhhhhw", "8-11 n: nnntnpdnvkqt", "9-10 n: nnnmnnnnnnnnnn", "3-5 c: qbcccchvccf", "8-9 s: sssssjsmqj", "4-5 w: zwwrxwwfwpwwz", "7-9 m: mmmmmmvmf", "5-9 w: wwwvtwwwm", "11-13 j: zjjjjjjjjjjljjjcjjj", "2-9 c: zblcmvmcfc", "16-17 g: gggggggggggggggqk", "12-15 p: pfcpppsgppxbjvqppppp", "4-6 l: ssldtlc", "5-8 h: shtphhdhhhhm", "17-20 n: nnnnnnnnmnnnnnhnsnnp", "12-17 s: sscsrsssdsssssrssss", "2-9 j: tjlffpwkjmnj", "1-6 p: cpxfpdvjb", "10-14 b: bbbbbbbbbhbnbbsbb", "3-4 h: hhhnh", "1-3 j: rkgjvqkgs", "16-17 w: wjwzdwwwwwsxbtlfs", "9-11 r: rrrrrrrrrrrr", "1-5 d: dtzqdd", "5-7 p: pprpppp", "6-7 n: nnnnnnn", "1-10 k: kkgcklpqzkk", "2-4 n: lvxnntjnpwhrsxlnhn", "3-6 h: hlhhhxhzh", "6-7 c: zccccccc", "1-4 z: ztczzzzzzzznzztnlkjz", "5-6 c: cccnccshkcpgjhn", "3-4 h: hhbh", "1-4 m: gmtm", "13-18 d: tldhjsdhdthhldzfgjxg", "4-5 d: dddddd", "1-3 r: rrrr", "7-8 b: bbbbbbbt", "12-14 z: zzqzbhzzzzzzzz", "5-7 v: vqblwrw", "8-9 c: tccccdcrccccqc", "9-11 m: mmhmmmnmqmtm", "3-10 n: dnwzhrfnqt", "3-4 t: xnkfpcqtcqkctxrrm", "2-7 l: lllllllll", "2-7 g: rdnskwgwcgnrzncqtnp", "11-13 s: ssssssssssqsw", "10-12 m: mmmmmmmmmcmqqmmpmm", "4-8 n: gnqnptxnhgpnnnn", "6-7 t: tttttcct", "2-3 s: sssssss", "9-10 h: hhhhhphrms", "3-6 d: vdxdddddd", "8-15 k: kkkbkkckkkkkkzgkkk", "4-10 n: ncntnnnnnnn", "3-9 r: snrkcrrcvrx", "7-11 s: sssssgwsshks", "1-4 h: hfch", "10-18 l: llllxllllflllfllsnll", "13-16 x: xpwcxpxxxxfqxnxx", "2-3 m: mvmmm", "3-5 l: ljlzs", "8-13 t: tgttttmmrfthttwt", "2-9 t: vttjddjxtfrlw", "3-5 r: frrrr", "4-5 s: pssnm", "4-5 h: jcphhsnrm", "2-3 d: pjdd", "2-3 g: gdgk", "10-13 v: svtvvvvvxwvvwv", "4-5 l: lqlll", "13-14 s: sffbffsmssscss", "2-3 j: fkkfmzqjnfvdjr", "16-18 z: zmqzzgzkzzzglhzzlzj", "3-4 h: hhfh", "11-13 s: sssssnsspshswhsssss", "7-9 g: gvgggrmgzr", "1-5 p: hppxnlkgcpppppppp", "1-13 q: qqqqqqqqqlgqqqqqn", "3-5 x: xxzxpx", "3-15 x: xcndrhtnpbqwgsxtzqn", "9-13 d: nrhbddvslmwbs", "8-10 g: grggggxggxgg", "10-11 h: hrfprqnhbhh", "2-3 r: rpzr", "14-15 d: ddddddddrdddddd", "7-8 b: zbbbbgbbbbpbbv", "12-18 v: vvvvvvvvvvvfvvvvvvv", "7-13 r: snkkjtnkrntjfd", "1-7 g: ngdndgg", "1-10 h: hhzhhhhrhhhhhhhh", "6-7 x: dxrxxzs", "6-7 x: xxxxxxxxxx", "8-11 v: vcvvvvxvvkcvlvvvvvv", "3-4 n: nrzh", "8-12 x: xxxpvxxttxxfmnx", "9-10 r: rrrrgrrrzr", "2-8 v: lbtvvvzqvzsg", "3-5 d: dkfbwlrg", "13-14 k: kkkkkkkkkkkkkk", "6-8 x: xqgbwxxxppgxz", "1-4 n: pnnr", "6-9 l: hglpllcnl", "1-4 x: xxxx", "3-5 n: lnzwmhjnndjdmknnqtnc", "8-13 t: tttttttnttttjttt", "7-11 s: ssssssssssvbn", "1-5 l: lllllll", "2-6 v: rvvzvvzcgv", "6-8 c: tccckcrc", "2-3 q: wnqq", "2-3 p: pplpp", "3-4 f: kxfwcfsk", "1-6 m: mmmmmm", "3-4 n: zgnnprvnns", "17-18 z: zzzzzzzzzzzzzzzzwhz", "3-11 w: wflwwwvwwhrgwwrwwwww", "9-13 g: ggggggggpggggg", "2-6 r: trvcwrr", "5-7 p: prtjptws", "7-10 b: bfbjwjlkbsbbwgk", "3-5 z: zzzzzzzzwhzzzdznz", "4-7 p: lphppppppp", "4-5 n: nvnnnsnn", "7-9 b: znbhbtgbw", "1-11 w: jwwwwwwwwwgw", "10-13 w: lwwwwwbwmwwfqwwr", "5-12 p: ppppqppppppt", "1-10 j: jjpjjjjjjjjjjjjjjj", "6-9 g: gxgfgjmggggg", "7-12 c: cdccccgcccgc", "7-15 m: mmmmmmmmmmmmmmmmmmv", "4-7 n: ndwjpvgnh", "5-9 s: cszftmnqmssfqs", "1-11 m: zmmmcdcmfmdbmltmf", "16-17 s: zrshsssxssssssxfs", "6-17 m: kphrlmrcmpskjcmmmg", "3-4 j: jxjj", "2-3 f: ffbfs", "4-7 v: vvvvvvvv", "1-7 f: fffffffff", "1-17 d: dtdftddsdddddddsdd", "8-10 c: ccrccccccsc", "2-8 m: hqmmmmmpm", "2-5 j: jjnjjjj", "7-8 s: vsszssssss", "3-18 g: ngpggmgggggggggggfgg", "14-16 r: rrrkrqrlrrrjrrrpwtr", "2-3 h: hshs", "10-16 r: mrxdnzxmvrplhmrr", "6-7 q: hwqmqqqqqql", "3-6 z: rgtqkw", "1-13 k: lkkkkkkkkkkkckkk", "3-5 t: ttxtt", "3-9 s: ljsvzbfwshssrc", "6-7 z: zbwzjgw", "1-11 n: ptnqltlkrxv", "8-9 l: lsllllllhl", "2-8 v: vvvvvvvzvvv", "5-8 s: ssslnsssssssssl", "7-8 k: kpkkkkkchlk", "15-18 v: vtvvvvwvvvvvvmvvvb", "11-13 m: mqmpjsmmlkvnmnfmwqmq", "14-15 k: kkkkkkkkkkkkkljk", "13-14 t: tffbtznjgtcnts", "5-6 z: kkkpzzctq", "4-5 h: jhbhzr", "5-7 v: vqvvgxv", "6-10 d: dddddpdddtdd", "11-12 g: ggggggggggvggg", "13-18 f: ffvfffxhrfhrcffpgnff", "6-10 x: nsxgwsjxfthhxxgxg", "2-5 w: wfvpmwtwg", "9-10 l: lljwlllfxcll", "2-5 b: rbbbmbbbbbbbbbvbbb", "5-13 p: jjffpmbpppmtpf", "1-5 r: rrzrrrrkrr", "1-2 m: mmmmmgmm", "16-18 z: zzzzzzzzzzzgzdzqzz", "6-7 l: llwfxll", "6-9 j: jjzhjjjjjjj", "4-7 k: hwskvkk", "2-3 d: dddddq", "4-6 b: bbbbbbhbbbbbbbbbbbbb", "7-14 l: lnhmlwzxlsldlx", "2-4 m: msmmh", "4-10 z: vhkrzzcbzzrzdcq", "4-7 p: dnppppwp", "5-7 z: mzzzzzzz", "5-7 b: bbbbbbb", "1-5 t: rrbtt", "7-11 x: bjxqxtxzlfxpmkpqtnd", "7-9 k: kkkkkkkkkk", "8-9 d: dhfddpndbhqdtdwdtn", "18-19 k: tnkzkdkkkgkkbckkkkk", "8-11 f: cfnqkzffgxf", "2-4 x: xxwxxsx", "8-11 m: mmmkmpcmmvgxmmmcmm", "13-14 z: wfzlzzzzzrdxzlzz", "2-4 n: frns", "4-5 q: qhqqqq", "12-18 w: fwwwwdxxzvzzgwpwlk", "12-13 n: nnjnnnnnwnnxgnn", "8-11 c: tcjcbcwctkccr", "4-6 m: jvmhtq", "1-2 b: bbbbb", "11-12 q: vqfqvqdnsxqq", "7-9 m: mgmjmtmmzmmhrm", "9-10 t: ktvnttttxl", "8-10 r: rcrrdrrdgsrr", "7-8 m: bvlmhxfxnlmfbz", "3-5 c: bhczc", "1-3 w: nwwnwwxww", "3-5 l: jcllld", "1-10 b: bbtbqbtbbbbtbbbbbbb", "5-7 x: vsxxxxxx", "3-4 k: gdkv", "8-10 k: kpkkwzkrkjkkkm", "3-6 l: hhlmll", "16-17 x: xxxxxxxxxxxxxtxmx", "1-4 w: wrkw", "1-4 t: gzpkttttt", "2-3 z: zzzq", "13-14 q: qqqqqqqqqqqqqq", "2-19 d: vdwfzsfqtqbglgrfdvd", "4-6 x: dxtnxzx", "3-5 g: ggggg", "6-7 m: mmmmmjj", "15-16 t: tvtttttvbttttttt", "5-6 k: kdztgkx", "1-3 d: dddd", "5-14 h: hhptkkcpqphhdgw", "13-14 j: hvmrjdcjhjjfgbmw", "10-14 h: hhbhchhhhwhhnhhhthh", "2-3 f: jcstlgbdf", "3-4 w: kwww", "2-12 b: bbbbbbbbbbbfbbbbbbbb", "2-4 x: xxxs", "10-11 c: qmrtcpztvcc", "7-12 l: llptfltlllllzllzl", "14-16 m: mmmmmmmmqmmmmtmr", "10-18 m: mgmmmnmmbbvmmmmmmgmm", "4-18 q: kqlrkhrqljbgwpmpnq", "3-4 c: czcdc", "2-13 k: jnmzxwvgfldnz", "11-12 b: bbbbbbrbbbbb", "6-11 p: psfpzrpfpqkzpvppt", "9-11 p: mpspjjxcpqpdppppph", "4-17 t: tdtftttttttlttdtttwq", "12-15 r: krrrrrmrrrrdrrmp", "2-3 x: xczx", "1-7 j: mjjgjjdjj", "2-8 x: jmlxxxxxxxrxxxx", "6-7 l: qntxbml", "7-12 k: kkkkkkvkkkkfkk", "2-7 z: nsgtlfdrsp", "7-9 m: mvmmgmjmm", "3-7 t: ttttttt", "2-9 b: gbczjbbbblbbb", "8-12 j: jjjjjjjljjjsj", "9-11 h: dmrjmzdwhhhqz", "6-10 j: jjjjjjvvjfcp", "1-6 t: tqsznxwnnrnmjt", "5-8 f: rpffhjnlkxplffhm", "8-9 d: fddddddddddcdndddrdd", "4-5 k: jkkfckkk", "3-5 l: llglkqllll", "3-5 k: zkzknkkk", "5-7 d: nddddnq", "9-10 j: vjgjlfcjjjfxjjmjrzwk", "2-4 m: fdxm", "5-7 c: cvqgkhvtbccc", "7-20 j: rscsdsjzflbldrwqvkjj", "4-5 p: pbxpppp", "3-4 h: vnhhvlbtbqshhcsxhs", "4-12 k: hkdkfxkknkkkkck", "4-5 g: gggvq", "4-5 h: zhtch", "8-12 m: tpmmxzmgmmln", "9-15 c: ccckfccjznpclnccxc", "9-12 p: pppppppptcpfpppppppp", "15-17 g: ttdlnvrknskcgvrgnm", "7-12 r: rrrrtrtrrrrjlrrr", "4-5 c: rccclxc", "3-5 d: hbgzddt", "4-5 x: cxxxx", "3-4 k: kkpc", "8-9 j: jjjjjjjrhv", "5-6 p: ppcppp", "14-15 h: hqhhhhhghhhhhlrhh", "5-10 z: zzzzzzzzzzzzz", "6-7 m: mhdmmzpmmmp", "1-2 j: knjj", "2-7 m: mmqnmjmtkz", "2-3 j: jzjjjjj", "12-15 g: gggggggggggngggg", "6-9 h: hrtllxbqgcrf", "3-4 c: ccccc", "7-11 g: jclgcjgngkzggg", "6-9 s: qwnvpsvbsmwqpqrst", "17-18 k: kpdkzkkkkkkkkkfkksk", "1-3 v: svnv", "4-6 k: kkndkkkkk", "12-15 z: zzzzzzzzzzzdzzzz", "3-9 z: zzzzzzzzr", "7-10 w: vgwwwcwwww", "10-15 n: vgxnnnqnnnhwsbnxpnnk", "2-4 v: fxhvh", "11-12 h: hhjhhhnchhhhhhhh", "3-9 z: vzzczzzkzbh", "5-8 k: kskkkkktkk", "3-7 s: sswssxt", "4-7 g: rggdggg", "4-7 c: zccpcccc", "6-11 z: mzlrssckpzvzslcwzzzz", "8-9 v: vvvvvvvvvvvvvv", "1-4 f: fffffffffffffffff", "8-10 f: tjfffmgrfl", "3-5 k: kfwnp", "6-7 t: pvtstmq", "3-7 x: cvxkwxxgpjxskkvsxp", "1-7 c: cctcckccccxc", "1-3 g: vfxvfxmhpgg", "13-16 m: fmjplfbgzzkrmcmv", "3-6 l: llmllc", "17-19 j: hjzjrbpjzjdjjvbzjjv", "7-12 q: qqqqqqqqqqqq", "9-13 n: nnnnnnnnqnnnxnnv", "17-18 n: nnnnnnnnnnnnsnnnzh", "6-15 f: rswffffffkfffkxfjf", "3-6 v: vvvvvvv", "9-11 d: ddddddddmdf", "19-20 k: kkkkkkkkkkkkhkkkkktg", "9-11 f: ffffqfffnfl", "6-9 r: rrrrvrrrr", "5-6 g: kgdfggggng", "17-18 w: wwwwwwwwwwwwwwwwrm", "5-14 t: tttttttttttttqtt", "13-15 n: nnnbnnnnnnnntnn", "4-13 g: rlhgcffsgshcg", "4-12 z: mbfztgsbkscpqwl", "18-20 p: mmflppmwzscjcgsxdddd", "1-6 k: kkkkkkkk", "18-19 n: qxkljbmdgsfsnknfhjb", "1-2 h: nxnhh", "2-11 f: fxffffffffxffffkffff", "4-11 k: mqvktsksvkkwjbtvg", "13-14 m: kmtmzqmmjmmmmmmwkm", "3-5 t: ttswxtt", "11-12 b: bbbbbbhbbblbbbb", "9-10 w: lkhccgmwvd", "2-3 t: thttl", "12-13 b: bbbbbbbbbbblb", "8-9 w: wdwwjbwblwww", "4-5 h: hqphz", "9-14 h: hhhhhxhhzhhhhht", "9-10 x: xxxxxxxxxxx", "4-7 m: dgltmmrdvmfmd", "9-10 h: vltrhtgblsmlmnbvml", "6-10 p: gkpppbppspp", "8-9 c: scjdvbpwn", "4-15 f: fpfnffffffffffhn", "10-14 s: sssscswsssssss", "4-10 j: jxdjfscnmgj", "6-12 w: ksjdxwckwwwwwfzwsgz", "1-8 j: jjjjjjjtj", "1-3 d: kgpvfv", "2-12 w: wwwtwwwvwwwwrwwwwww", "4-6 f: fkbdftxqtxjwfvf", "7-8 p: pppppppk", "12-14 g: gmgvgffnggjkgggg", "3-4 x: wxkgxxxx", "3-7 n: nnnddmcjcrtnnfhnx", "4-5 k: kkbmxkk", "12-13 b: bbbkxbbbbbnbbtbbgb", "9-11 h: hhhhhhhhhhhh", "4-6 q: lmgvsfqxmqhvzqqt", "13-15 t: ttttvtttttttfhm", "1-3 x: hxlw", "9-14 v: gjrvgrmvvvdcvv", "5-15 z: zzzzczzzzzzzzzzzz", "1-8 s: tssssssss", "10-15 h: vhvhxthvhhhchhshfh", "1-9 l: lllpllqklmlk", "12-14 z: zjzzzzzzzhzkzz", "3-8 w: wlzzflnmflwdnp", "5-7 s: sgsdssss", "5-13 h: hnhshhnklhqbhh", "4-6 b: xsbbbxbbpbbbbb", "14-16 c: cccjgccccccccmvc", "5-11 r: nrrrrrrsdjrrk", "6-12 s: gssjtjssfhjsssssss", "5-6 j: jjjjrs", "14-15 d: dddddddddddddddd", "10-11 z: zczzzzzzzzzczzzzzz", "2-4 q: qqqj", "7-13 f: fffffhfffffff", "13-14 q: qqqqqqqqqqqqjfqqq", "8-9 w: wwwtcwqjw", "5-6 x: xcrfxx", "13-19 r: rdwfrghfrcnjcdjxtrmr", "6-9 h: hhdhhhmlg", "7-11 p: ppgpppgppdq", "5-6 m: msmrtxm", "14-15 j: kjkzrslzdzgrfjjjj", "14-15 f: fqjfffwsffzhmff", "15-16 d: ddddddddddddddvmdd", "10-11 w: wslwwcwkzrvkg", "1-3 v: kvvvv", "6-12 q: qqqqqbqqqqqzqqqqqq", "15-17 m: mmmmmmmmbmmmmmfmxd", "1-10 t: sttttttttvt", "8-9 q: qqqqqbqwq", "14-15 t: ftgtttgftxttwtt", "5-9 p: bzkpxnfnj", "2-9 h: hhngqknrhd", "10-11 h: hhhhbhvhqhhhh", "5-8 v: dvstzxwtp", "3-5 q: qmzpbmmwsqwzr", "7-8 r: rrcrrrrr", "3-4 w: wwwt", "1-2 l: pzzl", "4-13 h: trpbbrhnxnkbrkmgdk", "4-5 v: fgxmv", "5-11 d: dddgddxrdbmsddj", "7-8 s: ssssssss", "5-7 m: dfmksgsdmcbjrmk", "4-7 s: tsqcssrzs", "4-5 j: jjjjjjl", "6-10 s: vkwshtpqjxslssxm", "3-4 z: zzdfzz", "1-5 m: fkhmw", "6-11 f: twtfbvwbbsfff", "2-9 f: fzwfjljxfxfkjfl", "1-2 d: ssddd", "5-9 k: kkzkscklbqtkkk", "6-16 v: vjfbmnplzwtkxlvdqwn", "5-8 g: ggnlkgdh", "11-12 s: qbswtxnplqss", "3-6 r: rrrrrr", "10-11 w: wmhwswwwwfwww", "3-9 c: tcncldghxp", "3-8 q: wqtqgbpz", "17-20 b: bbhblqlbggtsqcbcbbkt", "7-15 f: fftffcxgfzttffmbrff", "11-12 v: vvvlvrvvwvvqskvvxv", "9-11 h: hdjcxnkhxhkqhh", "5-12 l: llllqllllllnl", "17-18 z: zbzzbzzzzzzzzzzptc", "2-6 c: cgmrpjdhkcp", "4-10 x: xxxjxtxvxxvx", "11-15 s: sspsvsjsssskzbsss", "2-4 z: rsfd", "4-16 r: rrrrrrlkrrrrrrrrr", "10-11 x: xxxxxxxxxpxxxxx", "1-10 j: tjjsvjmxcb", "4-5 t: tttbbtvttptttsthw", "7-11 m: xmxzrnmksbm", "2-6 t: vxdspsgtftlptvqft", "6-10 k: kkkkmmdkkl", "3-5 l: sssglkvfvdskkghdhkxs", "4-6 m: mljkmwmnmm", "4-7 l: lllllrh", "5-11 x: bsmxjxxcmcxxx", "1-2 t: tttt", "9-11 p: xpppppppcppd", "15-16 w: wxzxtwzjrmvkwzdwjt", "13-15 l: pnhkxsqfrldsltltcf", "4-10 v: vvvrvvvvvvv", "6-11 m: qpbmsmbsxpmzg", "1-7 m: tmmmlmcmmm", "10-14 s: ssshsssscxssszs", "1-7 q: tdqxmqkxgkt", "2-4 m: bcmq", "3-4 d: ddjd", "13-17 r: rrrrrrrrvprrrrsrx", "3-8 p: fjwbkcdt", "1-6 k: gskwbl", "7-8 z: wzgzhlzs", "5-6 v: xvvvlmvvsvbsv", "1-18 f: ffjcfbvrtftffxvfff", "3-8 l: lbtjlllqc", "4-7 v: vnvvdsvl", "15-18 d: ddddpdddddddddcgdrdd", "3-9 f: fffffffff", "1-5 v: svvjvvlpvwmvvgc", "13-14 z: zzzzzzzzzzzzmz", "6-8 p: zcwptpgppfpppc", "8-14 j: cjrzvhjjmdpzjjqs", "16-19 s: sszsssssssssssssssss", "7-9 r: rrrkrrrrrnrrmj", "2-4 l: ldln", "3-5 p: pppvprp", "1-5 k: kkkkkk", "1-4 g: ggxz", "2-4 x: xwsgv", "15-16 v: vvvvjvqvfsktgvlvvvv", "17-19 x: xxxxxxxxxxxxxxxxcxx", "1-8 m: mmmmmhmpmms", "2-6 f: lffzdfsf", "2-3 p: jphqlvzfmpnmt", "2-11 g: ggrjthgdmggkgssq", "5-6 r: rwgrrr", "4-7 t: tttptmlthlfst", "5-7 v: bhhdvhhv", "8-11 n: nnnnnnnmnnnnn", "7-20 r: rxrqlrwrnrsrrvbvtrrm", "9-13 s: pfslddbsshsssrsrssls", "3-10 q: vwbwhvdfqqvghjzf", "9-14 b: bbbbbbbbbbbbbvb", "2-3 f: pfff", "3-9 r: trhrrrrrgrrn", "7-11 z: zzzzzzzzzzzz", "4-6 s: xwssttdqtc", "7-9 t: ttzmqqdtqtt", "6-19 g: gggggggggggggggggggg" };

            var passwordList = new List <Password>();

            foreach (var s in list)
            {
                var pass = s.Split(new[] { '-', ' ' });
                passwordList.Add(new Password {
                    minCharacters       = int.Parse(pass[0]), maxCharacters = int.Parse(pass[1]),
                    characterToValidate = pass[2].Trim(':').First(), passwordToValidate = pass[3]
                });
            }

            // Day 1 Part 1
            Console.WriteLine(PasswordPolicy.CheckPasswordsPart1(passwordList).Count());

            // Day 1 Part 2
            Console.WriteLine(PasswordPolicy.CheckPasswordsPart2(passwordList).Count());
        }
        public void TestGetInputData()
        {
            List <PasswordPolicy> passwordList = PasswordPolicy.GetInputData(PuzzleFilePath);

            Assert.AreEqual(1000, passwordList.Count());
        }
        public void TestPasswordPolicyCheck(int minOccurence, int maxOccurence, char policyLetter, string password, bool expectedValid)
        {
            bool passwordValid = PasswordPolicy.Check(minOccurence, maxOccurence, policyLetter, password);

            Assert.AreEqual(passwordValid, expectedValid);
        }
예제 #7
0
 public bool Check(string password)
 {
     return(PasswordPolicy.Check(this.MinOccurence, this.MaxOccurence, this.PolicyLetter, password));
 }
예제 #8
0
        private static bool IsRightPassword(PasswordPolicy passwordPolicy)
        {
            int characterNumber = passwordPolicy.Password.Count(character => character == passwordPolicy.SingleCharacter);

            return((characterNumber >= passwordPolicy.Min) && (characterNumber <= passwordPolicy.Max));
        }