Beta
Calculate daily accurate interest for a bank account
14Odd
Loading description...
Algorithms
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Fixed tests are written incorrectly: user function should be called per test block, and not in batch in advance, because user logs will cluster together before any test blocks, which cannot be correlated to the specific test assertion (and is pretty unreadable too).
Also, tests are not displaying expected value (
0 is not the expected balance.
), which is unacceptable.ALSO, failure assertion message for the random tests is wrong: every one of them displays
Transactions: [('2015-01-01 10:12:13', 123.45), ('2015-01-01 15:12:13', 123.45), ('2015-02-07 18:00:00', 123.45)]
but this is the first fixed test, not the actualtransactions
being tested.The third parameter should be renamed to 'initial_balance'.
Needs Random Tests
You are right, I wanted to add some random tests but haven't yet. Is there a better way to access my solution to use it in the tests to calculate the result for the random input than copying it to the test code under a random name?
It's common to put the reference solution in the complete test. If you are considering about anti-cheat, firstly, you may have to think of what to prevent.
I added random tests now, thanks for your help.
So should interest rate stay the same or be deducted?
If the balance is negative, let's say -100 for 10 days and interest per year (assuming 365 for this reply) is 0.01 or 1%, then you would calculate -100 * 10 days * (0.01 / 365) = -0,027397260273973 So, yes it would be deducted, you would have to pay interest to the bank for that period.