We're a lending platform giving loans to businesses. We want to create a summary of loans by transforming input data.
The input to this exercise is as follows:
Perky Blenders Coffee, 56101, 100000, B, 8%
Laird Hatters LTD, 14190, 25000, C, 15%, 75000, D, 20%
The input consists of rows that are separated by line-feeds/new-lines (\n
).
Each row has fields that are separated by commas and each row can vary in length.
A row consists of the following fields:
- The business name.
- The main business nature code.
- A repeating set of triplets with the loan amount, risk band, and interest rate. There could be any number of these triplets.
For example, the following row is broken down as shown:
Laird Hatters LTD, 14190, 25000, C, 15%, 75000, D, 20%
|---------------||-------||-----------||---------||--------||-----------||---------||--------|
NAME CODE LOAN AMOUNT RISK BAND INTEREST LOAN AMOUNT RISK BAND INTEREST
|__________Triplet 1_____________||__________Triplet 2_____________|
We want to show:
- The total amount we have loaned.
- Each business name with the average loan amount we have issued them.
You are allowed to feed the input into your solution however you prefer, e.g.:
- a variable containing the data
- a file
- from stdin
- a test harness