Easy Balance Checking
Description:
You are given a (small) check book as a - sometimes - cluttered (by non-alphanumeric characters) string:
"1000.00
125 Market 125.45
126 Hardware 34.95
127 Video 7.45
128 Book 14.32
129 Gasoline 16.10"
The first line shows the original balance. Each other line (when not blank) gives information: check number, category, check amount. (Input form may change depending on the language).
First you have to clean the lines keeping only letters, digits, dots and spaces.
Then return a report as a string (underscores show spaces -- don't put them in your solution. They are there so you can see them and how many of them you need to have):
"Original_Balance:_1000.00
125_Market_125.45_Balance_874.55
126_Hardware_34.95_Balance_839.60
127_Video_7.45_Balance_832.15
128_Book_14.32_Balance_817.83
129_Gasoline_16.10_Balance_801.73
Total_expense__198.27
Average_expense__39.65"
On each line of the report you have to add the new balance and then in the last two lines the total expense and the average expense. So as not to have a too long result string we don't ask for a properly formatted result.
Notes
- See input examples in Sample Tests.
- It may happen that one (or more) line(s) is (are) blank.
- Round to 2 decimals your calculated results (Elm: without traling 0)
- The line separator of results may depend on the language
\n
or\r\n
. See examples in the "Sample tests". - R language: Don't use R's base function "mean()" that could give results slightly different from expected ones.
Similar Kata:
Stats:
Created | Oct 6, 2017 |
Published | Oct 6, 2017 |
Warriors Trained | 11266 |
Total Skips | 782 |
Total Code Submissions | 32225 |
Total Times Completed | 2974 |
Shell Completions | 38 |
Python Completions | 837 |
JavaScript Completions | 1095 |
Ruby Completions | 125 |
Java Completions | 404 |
Julia Completions | 9 |
Scala Completions | 28 |
R Completions | 11 |
PowerShell Completions | 23 |
Go Completions | 93 |
Nim Completions | 4 |
PHP Completions | 90 |
Rust Completions | 74 |
C# Completions | 116 |
Clojure Completions | 13 |
Racket Completions | 4 |
TypeScript Completions | 79 |
F# Completions | 10 |
Kotlin Completions | 43 |
Pascal Completions | 2 |
Perl Completions | 9 |
Elm Completions | 2 |
D Completions | 3 |
Prolog Completions | 4 |
Total Stars | 207 |
% of votes with a positive feedback rating | 77% of 542 |
Total "Very Satisfied" Votes | 364 |
Total "Somewhat Satisfied" Votes | 102 |
Total "Not Satisfied" Votes | 75 |
Total Rank Assessments | 5 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 7 kyu |