Esempio n. 1
0
        public object SolvePartTwo()
        {
            var lines          = InputLineParser.GetAllLines(Day05Input.WORDS);
            var niceWordsCount = lines.Where(IsWordReallyNice).Count();

            return(niceWordsCount);
        }
Esempio n. 2
0
        public object SolvePartTwo()
        {
            var lines = InputLineParser.GetAllLines(Day14Input.REINDEERS);
            var track = new Track();

            foreach (var line in lines)
            {
                var reindeer = ReindeerParser.ParseReindeer(line);
                track.Commit(reindeer);
            }

            for (int i = 0; i < 2503; i++)
            {
                track.AdvanceAllBySecond();
                var temporaryLeaders = track.GetLeadersByTraveledDistance();
                foreach (var leader in temporaryLeaders)
                {
                    leader.AwardByPoints(1);
                }
            }

            var winner = track.GetWinnerByScore();

            return(winner.Score);
        }
Esempio n. 3
0
        public void Sample()
        {
            var circut = new Circut();
            var input  = @"
123 -> x
456 -> y
x AND y -> d
x OR y -> e
x LSHIFT 2 -> f
y RSHIFT 2 -> g
NOT x -> h
NOT y -> i";


            var lines = InputLineParser.GetAllLines(input);

            foreach (var line in lines)
            {
                var wire = WireParser.ParseWire(circut, line);
                circut.AllWires.Add(wire.ID, wire);
            }

            Assert.That(circut.AllWires["d"].GetValue(), Is.EqualTo(72));
            Assert.That(circut.AllWires["e"].GetValue(), Is.EqualTo(507));
            Assert.That(circut.AllWires["f"].GetValue(), Is.EqualTo(492));
            Assert.That(circut.AllWires["g"].GetValue(), Is.EqualTo(114));
            Assert.That(circut.AllWires["h"].GetValue(), Is.EqualTo(65412));
            Assert.That(circut.AllWires["i"].GetValue(), Is.EqualTo(65079));
            Assert.That(circut.AllWires["x"].GetValue(), Is.EqualTo(123));
            Assert.That(circut.AllWires["y"].GetValue(), Is.EqualTo(456));
        }
Esempio n. 4
0
        public object SolvePartOne()
        {
            var grid  = new BinaryLightingGrid();
            var lines = InputLineParser.GetAllLines(Day06Input.INSTRUCTIONS);

            foreach (var line in lines)
            {
                var instruction = new LightInstruction(line);
                grid.ProcessInstruction(instruction);
            }

            return(grid.HowManyLightsAreLit());
        }
Esempio n. 5
0
        public int CountAllAreas(string input)
        {
            var sum   = 0;
            var lines = InputLineParser.GetAllLines(input);

            foreach (var line in lines)
            {
                var present = new Present(line);
                sum += present.Area + present.GetSmallestArea();
            }

            return(sum);
        }
Esempio n. 6
0
        public int CountAllRibbons(string input)
        {
            var sum   = 0;
            var lines = InputLineParser.GetAllLines(input);

            foreach (var line in lines)
            {
                var present = new Present(line);
                sum += present.GetSmallestPerimeter() + present.Volume;
            }

            return(sum);
        }
Esempio n. 7
0
        public object SolvePartOne()
        {
            var circut = new Circut();
            var lines  = InputLineParser.GetAllLines(Day07Input.BOOKLET);

            foreach (var line in lines)
            {
                var wire = WireParser.ParseWire(circut, line);
                circut.AllWires.Add(wire.ID, wire);
            }

            var wireA = circut.AllWires["a"];

            return(wireA.GetValue());
        }
Esempio n. 8
0
        public object SolvePartOne()
        {
            var lines = InputLineParser.GetAllLines(Day14Input.REINDEERS);
            var track = new Track();

            foreach (var line in lines)
            {
                var reindeer = ReindeerParser.ParseReindeer(line);
                track.Commit(reindeer);
            }

            track.LetThemRunFor(2503);

            var distance = track.GetLeadersByTraveledDistance().Max(r => r.TraveledDistance);

            return(distance);
        }
Esempio n. 9
0
        public object SolvePartTwo()
        {
            var circut       = new Circut();
            var inputPartOne = Day07Input.BOOKLET;
            var inputPartTwo = inputPartOne.Replace("1674 -> b", "46065 -> b");
            var lines        = InputLineParser.GetAllLines(inputPartTwo);

            foreach (var line in lines)
            {
                var wire = WireParser.ParseWire(circut, line);
                circut.AllWires.Add(wire.ID, wire);
            }

            var wireA = circut.AllWires["a"];

            return(wireA.GetValue());
        }
Esempio n. 10
0
        public void NoticePersonalities(string letter)
        {
            var lines = InputLineParser.GetAllLines(letter);

            foreach (var line in lines)
            {
                var personality      = PersonalityParser.ParsePersonality(line);
                var existingAttendee = Attendees.SingleOrDefault(att => att.Name == personality.Name);
                if (existingAttendee == null)
                {
                    var newAttendee = new Attendee(personality.Name);
                    newAttendee.PotencialHapinnes.Add(personality.Neighbor, personality.Happiness);
                    Attendees.Add(newAttendee);
                }
                else
                {
                    existingAttendee.PotencialHapinnes.Add(personality.Neighbor, personality.Happiness);
                }
            }
        }
Esempio n. 11
0
        public void ParserReturnLines(string rawLines, int expectedNumberOfLines)
        {
            var parsedLines = InputLineParser.GetAllLines(rawLines);

            Assert.That(parsedLines.Count(), Is.EqualTo(expectedNumberOfLines));
        }
Esempio n. 12
0
        public string GetBathroomDesignCode(string input)
        {
            var lines = InputLineParser.GetAllLines(input);

            return(GetBathroomDesignCode(lines));
        }