Beispiel #1
0
        public void ShouldCountPlanOverlapFromBigInput()
        {
            var plans  = PuzzleInputParser.ParseStrings("Day3/Input.txt");
            var fabric = new PrototypeFabric(1000, plans);

            fabric.CountAreaOfOverlaps().Should().Be(116491);
        }
Beispiel #2
0
        public void ShouldFindFirstNonOverlappingPlanFromBigInput()
        {
            var plans  = PuzzleInputParser.ParseStrings("Day3/Input.txt");
            var fabric = new PrototypeFabric(1000, plans);

            fabric.GetFirstNonOverlappingPlanId().Should().Be("707");
        }
        public void ShouldFindCrashLocationFromSmallExample()
        {
            var sut   = new CartTracks(PuzzleInputParser.ParseStrings("Day13/SmallInput.txt"));
            var crash = sut.MoveCartsUntilCrash();

            crash.X.Should().Be(7);
            crash.Y.Should().Be(3);
        }
        public void ShouldFindLastCarThatHasntCrashed()
        {
            var sut  = new CartTracks(PuzzleInputParser.ParseStrings("Day13/BigInput.txt"));
            var cart = sut.MoveCartsUntilAllButOneHaveCrashed();

            cart.CurrentTrack.X.Should().Be(2);
            cart.CurrentTrack.Y.Should().Be(84);
        }
        public void ShouldFindCrashLocationFromBigInput()
        {
            var sut   = new CartTracks(PuzzleInputParser.ParseStrings("Day13/BigInput.txt"));
            var crash = sut.MoveCartsUntilCrash();

            crash.X.Should().Be(76);
            crash.Y.Should().Be(108);
        }
Beispiel #6
0
        public void ShouldCalculateRegionClosestToMostCoordinatesFromBigInput()
        {
            var sut = new CoordinateGrid(PuzzleInputParser.ParseStrings("Day6/Input.txt"), 10000);

            sut.CalculateManhattanDistancesForGrid();

            sut.RegionClosestToMostCoordinates.Should().Be(37093);
        }
Beispiel #7
0
        public void ShouldCalculateCoordinateFurthestFromOtherCoordinatesFromBigInput()
        {
            var sut = new CoordinateGrid(PuzzleInputParser.ParseStrings("Day6/Input.txt"), 10000);

            sut.CalculateManhattanDistancesForGrid();

            sut.CoordinateFurthestFromOtherCoordinates.Area.Should().Be(5358);
        }
Beispiel #8
0
        public void ShouldFindGuardMostFrequentlyAsleepAtSameMinuteFromBigInput()
        {
            var shiftLogs = PuzzleInputParser.ParseStrings("Day4/Input.txt");
            var sut       = new GuardShiftTracker(shiftLogs);

            var guard = sut.FindGuardMostFrequentlyAsleepAtSameMinute();

            guard.Id.Should().Be(269);
            guard.MinuteAsleepMost.Should().Be(39);
            (guard.Id * guard.MinuteAsleepMost).Should().Be(10491);
        }
Beispiel #9
0
        public void ShouldFindSleepiestGuardFromBigInput()
        {
            var shiftLogs = PuzzleInputParser.ParseStrings("Day4/Input.txt");
            var sut       = new GuardShiftTracker(shiftLogs);

            var guard = sut.FindGuardWithMostMinutesAsleep();

            guard.Id.Should().Be(3557);
            guard.MinuteAsleepMost.Should().Be(30);
            (guard.Id * guard.MinuteAsleepMost).Should().Be(106710);
        }
Beispiel #10
0
        public void ShouldPrintPossibleTextForBigInput()
        {
            var points = PointOfLightParser.Parse(PuzzleInputParser.ParseStrings("Day10/Input.txt")).ToList();

            var sut = new Sky(points);

            sut.MoveTimeUntilStarsSpellMessage();
            sut.Print();

            PuzzleInputParser.ParseString("Day10/Output.txt").Should().Be(PuzzleInputParser.ParseString("Day10/BigOutput.txt"));
            sut.Seconds.Should().Be(10681);
        }
        public void should_count_wooden_areas_and_lumberyards_in_big_input()
        {
            var sut = new LumberArea(PuzzleInputParser.ParseStrings("Day18/Input.txt"));

            sut.PassMinutes(10);

            var forestCount     = sut.CountAllWoodedAreas();
            var lumberyardCount = sut.CountAllLumberyards();

            forestCount.Should().Be(709);
            lumberyardCount.Should().Be(502);

            (forestCount * lumberyardCount).Should().Be(355918);
        }
Beispiel #12
0
 public void ShouldDetermineStepForBigInput()
 {
     _sut.GetTimeToCompleteInstructions(PuzzleInputParser.ParseStrings("Day7/Input.txt"), 60, 5).Should().Be(946);
 }
Beispiel #13
0
 public void ShouldDetermineStepOrderForBigInput()
 {
     _sut.GetStepOrder(PuzzleInputParser.ParseStrings("Day7/Input.txt")).Should().Be("FHICMRTXYDBOAJNPWQGVZUEKLS");
 }
Beispiel #14
0
 public BoxChecksumTests()
 {
     _sut   = new BoxWarehouse();
     _input = PuzzleInputParser.ParseStrings("Day2/Input.txt").ToList();
 }
        public void should_observe_change_pattern_over_many_minutes()
        {
            var sut = new LumberArea(PuzzleInputParser.ParseStrings("Day18/Input.txt"));

            var minute = 0;

            var forestCount     = sut.CountAllWoodedAreas();
            var lumberyardCount = sut.CountAllLumberyards();

            while (minute < 1000)
            {
                sut.PassMinute();
                minute++;

                forestCount     = sut.CountAllWoodedAreas();
                lumberyardCount = sut.CountAllLumberyards();

                _output.WriteLine($"Minute {minute} - {forestCount}");
                _output.WriteLine($"Minute {minute} - {lumberyardCount}");
            }

            // At minute 506, this starts to repeat for the forest counts
            // Minute 506 - 586
            // Minute 507 - 580
            // Minute 508 - 573
            // Minute 509 - 572
            // Minute 510 - 568
            // Minute 511 - 568
            // Minute 512 - 567
            // Minute 513 - 570
            // Minute 514 - 570
            // Minute 515 - 573
            // Minute 516 - 572
            // Minute 517 - 575
            // Minute 518 - 573
            // Minute 519 - 576
            // Minute 520 - 576
            // Minute 521 - 581
            // Minute 522 - 586
            // Minute 523 - 591
            // Minute 524 - 593
            // Minute 525 - 600
            // Minute 526 - 602
            // Minute 527 - 603
            // Minute 528 - 606
            // Minute 529 - 609
            // Minute 530 - 606
            // Minute 531 - 606
            // Minute 532 - 601
            // Minute 533 - 596

            // and this for the lumber counts
            // Minute 506 - 358
            // Minute 507 - 358
            // Minute 508 - 351
            // Minute 509 - 344
            // Minute 510 - 339
            // Minute 511 - 337
            // Minute 512 - 332
            // Minute 513 - 331
            // Minute 514 - 329
            // Minute 515 - 331
            // Minute 516 - 332
            // Minute 517 - 335
            // Minute 518 - 337
            // Minute 519 - 336
            // Minute 520 - 338
            // Minute 521 - 337
            // Minute 522 - 338
            // Minute 523 - 339
            // Minute 524 - 342
            // Minute 525 - 341
            // Minute 526 - 346
            // Minute 527 - 350
            // Minute 528 - 354
            // Minute 529 - 353
            // Minute 530 - 354
            // Minute 531 - 355
            // Minute 532 - 357
            // Minute 533 - 360

            var forestPatternStartingAt506 = new int[]
            {
                586,
                580,
                573,
                572,
                568,
                568,
                567,
                570,
                570,
                573,
                572,
                575,
                573,
                576,
                576,
                581,
                586,
                591,
                593,
                600,
                602,
                603,
                606,
                609,
                606,
                606,
                601,
                596,
            };

            var lumberyardPatternStartingAt506 = new int[]
            {
                358,
                358,
                351,
                344,
                339,
                337,
                332,
                331,
                329,
                331,
                332,
                335,
                337,
                336,
                338,
                337,
                338,
                339,
                342,
                341,
                346,
                350,
                354,
                353,
                354,
                355,
                357,
                360
            };

            // Figure out formula, verify it works
            forestPatternStartingAt506[(1000 - 506) % forestPatternStartingAt506.Length]
            .Should()
            .Be(forestCount);

            lumberyardPatternStartingAt506[(1000 - 506) % lumberyardPatternStartingAt506.Length]
            .Should()
            .Be(lumberyardCount);
        }