The current instructions are correct.
This should return 1300:
CategoryExpenses(records, p1, "rent")
Because:
p1 := DaysPeriod{From: 1, To: 30}
And there is just a single record for the rent
category in this period:
{Day: 28, Amount: 1300, Category: "rent"}
Hence, the 1300
comes from the Amount
of this record.
By contrast, this should return 0:
CategoryExpenses(records, p2, "rent")
Because:
p2 := DaysPeriod{From: 31, To: 60}
And records
doesn’t actually have any record for any day after day 28:
records := []Record{
{Day: 1, Amount: 15, Category: "groceries"},
{Day: 11, Amount: 300, Category: "utility-bills"},
{Day: 12, Amount: 28, Category: "groceries"},
{Day: 26, Amount: 300, Category: "university"},
{Day: 28, Amount: 1300, Category: "rent"},
}