Beispiel #1
0
        internal void Solve()
        {
            var reindeers = new Reindeers(input);

            var points = new Dictionary <Reindeer, int>();

            foreach (var reindeer in reindeers)
            {
                points.Add(reindeer, 0);
            }

            for (int time = 1; time < RACE_DURATION; time++)
            {
                var distances = reindeers.ToDictionary(x => x, x => x.DistanceTravelled(time));

                var distanceWinners = distances.Where(x => x.Value == distances.Max(x => x.Value));
                foreach (var distanceWinner in distanceWinners)
                {
                    points[distanceWinner.Key]++;
                }
            }

            var winner = points.Where(x => x.Value == points.Max(x => x.Value)).First();

            Console.WriteLine($"{winner.Key.Name} won by scoring {winner.Value} points.");
        }
Beispiel #2
0
        internal void Solve()
        {
            var reindeers = new Reindeers(input);

            var distances = new Dictionary <Reindeer, int>();

            foreach (var reindeer in reindeers)
            {
                distances.Add(reindeer, reindeer.DistanceTravelled(RACE_DURATION));
            }

            var winner = distances.Where(x => x.Value == distances.Max(x => x.Value)).First();

            Console.WriteLine($"{winner.Key.Name} won by flying {winner.Value} km.");
        }