コード例 #1
0
        static async Task Main(string[] args)
        {
            var policies = (await File.ReadAllLinesAsync("input.txt")).Select(x => PasswordPolicy.Parse(x));

            Console.WriteLine(policies.Count(x => x.CheckPasswordPart1()));
            Console.WriteLine(policies.Count(x => x.CheckPasswordPart2()));
        }
コード例 #2
0
ファイル: PuzzleOne.cs プロジェクト: catalinQue/test
        public string Solve()
        {
            var inputs = Inputs.GetInputsValues("2");
            var lines  = inputs.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
            var count  = 0;

            foreach (var line in lines)
            {
                if (PasswordPolicy.ValidateOne(PasswordPolicy.Parse(line)))
                {
                    count++;
                }
            }
            return(count.ToString());
        }