You're an avid bird watcher that keeps track of how many birds have visited your garden in the last seven days.
You have six tasks, all dealing with the numbers of birds that visited your garden.
For comparison purposes, you always keep a copy of last week's counts nearby, which were: 0, 2, 5, 3, 7, 8, and 4. Define the lastWeek binding that contains last week's counts:
lastWeek
// => [| 0; 2; 5; 3; 7; 8; 4 |]Implement the yesterday function to return how many birds visited your garden yesterday. The bird counts are ordered by day, with the first element being the count of the oldest day, and the last element being today's count.
yesterday [| 3; 5; 0; 7; 4; 1 |]
// => 4Implement the total function to return the total number of birds that have visited your garden:
total [| 3; 5; 0; 7; 4; 1 |]
// => 20Implement the dayWithoutBirds function that returns true if there was a day at which zero birds visited the garden; otherwise, return false:
dayWithoutBirds [| 3; 5; 0; 7; 4; 1 |]
// => trueImplement the incrementTodaysCount function to increment today's count and return the updated counts:
let birdCount = [| 3; 5; 0; 7; 4; 1 |]
incrementTodaysCount birdCount
// => [| 3; 5; 0; 7; 4; 2 |]Over the last year, you've found that some weeks have the same, unusual patterns:
- On each even day of the week, there were no birds
- On each even day of the week, exactly 10 birds were spotted
- On each odd day of the week, exactly 5 birds were spotted
Implement the unusualWeek function that returns true if the bird count pattern of this week matches one of the unusual patterns:
unusualWeek [| 1; 0; 5; 0; 12; 0; 2 |]
// => true
unusualWeek [| 5; 0; 5; 12; 5; 3; 5|]
// => true(Note that day-parity is 1-indexed, not 0-indexed - the first element in the array corresponds with an odd day)