-
Notifications
You must be signed in to change notification settings - Fork 0
/
bird_watcher.go
28 lines (23 loc) · 692 Bytes
/
bird_watcher.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package birdwatcher
// TotalBirdCount return the total bird count by summing
// the individual day's counts.
func TotalBirdCount(birdsPerDay []int) int {
total := 0
for _, birds := range birdsPerDay {
total += birds
}
return total
}
// BirdsInWeek returns the total bird count by summing
// only the items belonging to the given week.
func BirdsInWeek(birdsPerDay []int, week int) int {
return TotalBirdCount(birdsPerDay[(week-1)*7 : week*7])
}
// FixBirdCountLog returns the bird counts after correcting
// the bird counts for alternate days.
func FixBirdCountLog(birdsPerDay []int) []int {
for i := 0; i < len(birdsPerDay); i += 2 {
birdsPerDay[i]++
}
return birdsPerDay
}