Report generator with extensions for nested collections
Kotlin
Hard
extensions
Task «Report generator with extensions for nested collections»
Write a Kotlin program that uses extension functions for `List<Map<String, Any>>` to generate a report: sequentially apply filtering by a string key value, sorting by an integer key, grouping by a string key, and calculating the sum of an integer field within each group. Input data: a number N (number of records), then N lines of the form 'key1=val1,key2=val2,...'. Output data: for each group, print 'group_key: sum', where sum is the sum of the 'score' field values for the records in the group. If no records remain after filtering, print 'empty'.
Input Format
Integer N (1 ≤ N ≤ 1000). Then N lines, each containing 'key=value' pairs separated by commas. Keys: 'name' (String), 'group' (String), 'score' (Int). Values may contain only Latin letters, digits, and spaces. All entries are valid.
Output Format
Strings of the form 'group_key: sum' for each group after processing, sorted in ascending order by group_key. If the resulting list is empty, output 'empty'.
Examples
Example 1
INPUT
1
name=Frank,group=B,score=100
OUTPUT
B: 100
main.kt