Exemplo n.º 1
0
        static void SolveDay4()
        {
            var adventClient = new AdventHttpClient();
            var adventInput  = new AdventInputProvider(adventClient);
            var day4         = new Day4(adventInput);

            var longestSleepingResult = day4.FindLongestSleepingGuardAndMinuteToSneak().Result;

            Console.WriteLine($"Day 4 Best Minute to go and longest sleeping guard id and minute multiplication result: {longestSleepingResult}");

            var mostFrequentlySleepingResult = day4.FindGuardMostFrequentlyAsleepAndMinuteToSneak().Result;

            Console.WriteLine($"Day 4 Best Minute to go and most frequently sleeping guard id and minute multiplication result: {mostFrequentlySleepingResult}");
        }
Exemplo n.º 2
0
        static void SolveDay5()
        {
            var adventClient = new AdventHttpClient();
            var adventInput  = new AdventInputProvider(adventClient);
            var day5         = new Day5(adventInput);

            var reducedPolymer = day5.GetReducedPolymer().Result;

            Console.WriteLine($"Day 5 Count of units in reduced polymer of fabric: {reducedPolymer.Length}");

            var mostReducedPolymer = day5.GetShortestPossiblePolymer().Result;

            Console.WriteLine($"Day 5 Count of units in most reduced polymer of fabric: {mostReducedPolymer.Length}");
        }
Exemplo n.º 3
0
        static void SolveDay3()
        {
            var adventClient = new AdventHttpClient();
            var adventInput  = new AdventInputProvider(adventClient);
            var day3         = new Day3(adventInput);

            var overlappingInches = day3.CountFabricInchesOverlaping().Result;

            Console.WriteLine($"Day 3 Overlapping Inches: {overlappingInches}");

            var nonOverlappingClaimId = day3.GetNonOverlapingClaimId().Result;

            Console.WriteLine($"Day 3 Non Overlapping Claim Id: {nonOverlappingClaimId}");
        }
Exemplo n.º 4
0
        static void SolveDay2()
        {
            var adventClient = new AdventHttpClient();
            var adventInput  = new AdventInputProvider(adventClient);
            var day2         = new Day2(adventInput);

            var checksum = day2.CalculateChecksum().Result;

            Console.WriteLine($"Day 2 checksum: {checksum}");

            var boxId = day2.GetStringOfCommonLettersFromMostSimilarBoxIds().Result;

            Console.WriteLine($"Day 2 BoxId : {boxId}");
        }
Exemplo n.º 5
0
        static void SolveDay1()
        {
            // TODO: dependancy injection
            var adventClient = new AdventHttpClient();
            var adventInput  = new AdventInputProvider(adventClient);
            var day1         = new Day1(adventInput);

            var frequency = day1.CalculateFrequency().Result;

            Console.WriteLine($"Day 1 frequency: {frequency}");

            var duplicateFrequency = day1.GetFirstFrequencyDuplication().Result;

            Console.WriteLine($"Day 1 frequency duplication: {duplicateFrequency}");
        }
Exemplo n.º 6
0
        public async Task ShouldParseElfFabricClaimStringToObject(Mock <IAdventHttpClient> adventClient)
        {
            // Arrange
            adventClient.Setup(c => c.GetInputStringListAsync(It.IsAny <string>())).ReturnsAsync(ElfsClaimStringList());

            var adventInput = new AdventInputProvider(adventClient.Object);

            // Act
            var elfsClaims = await adventInput.GetElfsFabricClaims();

            var elfClaim = elfsClaims.First();

            // Asset
            Assert.Equal(3, elfsClaims.Count());

            Assert.Equal(1, elfClaim.Id);
            Assert.Equal(2, elfClaim.OffsetLeft);
            Assert.Equal(7, elfClaim.OffsetTop);
            Assert.Equal(8, elfClaim.Width);
            Assert.Equal(3, elfClaim.Height);
        }
Exemplo n.º 7
0
        public async Task ShouldParseGuardActionsAndGroupByGuardId(Mock <IAdventHttpClient> adventClient)
        {
            // Arrange
            adventClient.Setup(c => c.GetInputStringListAsync(It.IsAny <string>())).ReturnsAsync(GetGuardActions());

            var adventInput = new AdventInputProvider(adventClient.Object);

            // Act
            var guards       = (await adventInput.GetGuards()).ToList();
            var guardActions = guards.First(g => g.Id == 1).Actions;

            // Asset
            Assert.Equal(3, guards.Count());

            Assert.Equal(ActionType.BeginsShift, guardActions[0].Type);
            Assert.Equal(DateTime.Parse("1518-01-01 00:01"), guardActions[0].Timestamp);

            Assert.Equal(ActionType.FallsAsleep, guardActions[1].Type);
            Assert.Equal(ActionType.WakesUp, guardActions[2].Type);

            Assert.Equal(ActionType.BeginsShift, guardActions[3].Type);
            Assert.Equal(DateTime.Parse("1518-07-01 00:01"), guardActions[3].Timestamp);
        }