Your question is Covering Missing Edge Cases. Take a moment with it on the right.
Talk me through your thinking if you like. When you're confident, submit your answer and I'll grade it like a real screen (7/10 or better passes).
You're a backend engineer at Tide, a business banking platform. This function auto-categorizes a transaction description into a spending category for the bookkeeping dashboard. It passed every test the original author wrote, but support keeps getting tickets about wrong or crashing categorization.
import "strings"
func CategorizeTransaction(description string, amountPence int) string {
lower := strings.ToLower(description)
if strings.Contains(lower, "amazon") || strings.Contains(lower, "staples") {
return "Office Supplies"
}
if strings.Contains(lower, "uber") || strings.Contains(lower, "taxi") {
return "Travel"
}
if strings.Contains(lower, "aws") || strings.Contains(lower, "google cloud") {
return "Software & Hosting"
}
firstChar := description[0]
if firstChar >= '0' && firstChar <= '9' {
return "Uncategorized - Merchant Code"
}
return "Uncategorized"
}
What edge cases are missing from this implementation, and how would you address them at Tide Fintech? Explain each gap and the change you would make.