using System.Collections.Generic;
using System.Globalization;
public record Animal(bool isMammal, string name) {}
public enum Location { Europe, Africa, America, Asia, NorthPole }
public record AnimalObservation(DateTime time, Location location, Animal animal) {}
public static void Main()
var observations = new List<AnimalObservation> {
new AnimalObservation(DateTime.Parse("2008-11-01T19:35:00.0000000Z"), Location.Europe, new Animal(true, "beaver")),
new AnimalObservation(DateTime.Parse("2008-11-01T19:35:00.0000000Z"), Location.Europe, new Animal(false, "bird")),
new AnimalObservation(DateTime.Parse("2008-11-01T19:35:00.0000000Z"), Location.Europe, new Animal(false, "bird")),
new AnimalObservation(DateTime.Parse("2008-11-01T19:35:00.0000000Z"), Location.Europe, new Animal(false, "bird")),
new AnimalObservation(DateTime.Parse("2008-11-02T19:35:00.0000000Z"), Location.Europe, new Animal(true, "beaver")),
new AnimalObservation(DateTime.Parse("2008-11-02T19:35:00.0000000Z"), Location.Europe, new Animal(false, "bird")),
new AnimalObservation(DateTime.Parse("2008-11-02T19:35:00.0000000Z"), Location.Europe, new Animal(false, "bird")),
new AnimalObservation(DateTime.Parse("2008-11-03T19:35:00.0000000Z"), Location.Europe, new Animal(true, "beaver")),
new AnimalObservation(DateTime.Parse("2008-11-03T19:35:00.0000000Z"), Location.Europe, new Animal(false, "bird")),
new AnimalObservation(DateTime.Parse("2008-11-04T19:35:00.0000000Z"), Location.Europe, new Animal(true, "beaver")),
new AnimalObservation(DateTime.Parse("2008-11-04T19:35:00.0000000Z"), Location.Europe, new Animal(false, "bird")),
mammalPercentages(observations);
public static void mammalPercentages(IEnumerable<AnimalObservation> observations) {
var percentageInfos = observations
time = NormalizeTime(x.time)
mammalPercentage = (double)g.Count(x => x.animal.isMammal) / g.Count()
foreach (var percentageInfo in percentageInfos) {
Console.WriteLine($"In {percentageInfo.location} at {percentageInfo.time.ToString("d", CultureInfo.InvariantCulture)} there was {percentageInfo.mammalPercentage.ToString("p", CultureInfo.InvariantCulture)} of mammals");
DateTime NormalizeTime(DateTime time) {