We break down how, in Kotlin, to build “related” reports for a console expense tracker: we lock in the data format (
List<Pair<String, Int>>), make a shared category-normalization step via
trim() and
lowercase(), separate computation from output, and then implement the
total,
byCategory,
threshold, and
top reports based on
fold,
groupBy, sorting, and filtering.