Lactation Periods

Company: intuit_24oct

Difficulty: medium

Problem Statement

Lactation Periods Problem Description A dairy farm keeps a log of lactation dates for its animals. Each record of the log is a pair: an Animal_ID and a date on which that animal started a lactation. For one animal, sort its lactation dates in chronological order. A lactation period is the number of days between two consecutive dates in that order. The average lactation period of the animal is the mean of all its lactation periods: the sum of the gaps divided by the number of gaps (the number of dates of that animal minus one). For every animal in the log, report its average lactation period. Function Description Complete the function solve . Parameters: animalIDs (string[n]): animalIDs[i] is the animal of record i . lactDates (string[n]): lactDates[i] is the lactation date of record i , in the format YYYY-MM-DD . Returns: a 2D array of strings with one row [Animal_ID, average] per distinct animal, where average is the average lactation period written with exactly one digit after the de