Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
This comment is hidden because it contains spoiler information about the solution
Listen, say whatever you want. This is a Kata with 30% None disapproval - that is the lowest frankly I've ever seen on this site. Not to mention, have you read the comments here? Do you not see a contrast between this and other kata? Why the cognitive disonance?
Have you considered why 30% of people disapprove and flood the comments for a kata that is essentially a basic algebra problem? No? you don't think there may be issues?
You can't assume anything is "logical". The order is which things happen is arbitrary. It could happen either way and is entirely up to the description of the problem to clarify.
I did think of my months counter that way, after rearranging things and realizing that was how to pass the test cases. If you think this is how it should, why not specify it like you did here? That is exactly what I'm asking for
It is parallel, but not the exact same question and elaborating on a subtopic. Please read the other comments to see how many times my notion has been repeated. The updated description posted by another user captures this quite well.
I made a mistake here and did not clearly elaborate what I meant to say. I am claiming issue here with exactly which months an adjustment to the depriciation is applied; again, you can read the other comments to see my sentiment repeated.
This should be within the parameters and return section, not adjacent to it.
This is the best part of the description.
I don't understand the kickback. In any interview, exam situation, edge cases and parameters are specified with borderline unnecessary scrutiny. Here is flopped at will and very hard to decipher. There is an explicit reason that this kata is ranked so lowly, and it is absolutely not because people have an issue with introductory alegbra conceptually.
Lastly, I did understand the task. I am writing here because I solved it. I am also writing here because solving it was a poor use of my time and was a "what did the author intend?" guessing game than an actual programming challenge. Depending on how you arbitrarily interpret your specifications this problem can be done in minutes, brute-force rearranging the order of your code until you chance upon the correct arrangement. It's a few simple lines at most.
This question, as many have stated, has very unclear documentation. This isn't a difficult question by any means, a basic compounded percentage problem. This question however is extremely unclear on multiple points in its description. The ones I caught:
The order of each event occuring (depriciation, purchasing and saving) is unclear. The correct order to get the result the test cases one needs to FIRST adjust the percentage if necessary. The ordering for these operations is ultimately arbitrary, but the depriciation percent happening before or after calculations is important to get the exact result.
The months where depriciation occurs isn't clear. Month 0 is used as a corner case test, but it isn't clear if month 0 is the first month with depriciation or not. To get this correct, it is before any calculations have taken place (ie, old car is worth 12000 and new is 8000 on the spot, meaning you can purchase it right away with 4000 in savings). Month 1 is therefore the first month that calculations and savings have taken place. This is again, arbitrary to decide but must be clearly stated.
The exact method for increasing depriciation is unclear. Does it increase after calculations or before? Again, the trend here is this decision is arbtrary but not clear. This must be explictly stated - right now, the adjustment to the percentage happens before any calculations take place.
The months that have depriciation are not clear stated. Make it clear that month 0 is before any calculations, month 1 is with calculations and no adjustments, and then month 2 calculates the depriciation at the beginning of the month, the pattern continues etc.
The rounding is arbitrary - it could just as easily be a floor as a round and neither perfectly makes sense (it is necessary, given that the result is a floating point number). Make it clear the answer needs to be rounded to the nearest integer (it is stated but not exactly clear).
Please, please remove the constants from the description as though they are set in stone. Accurately refer to the fact that the monthly savings are a variable instead of simply saying "1000" but inconsistently refering to other variables correctly as variables.
Ultimately, this is a very simple Kata, a little bit of a brain teaser to make programmers aware of floating point accuracy and such. But with something as sensitive to results like this, the instructions have to be watertight. Otherwise you will dissuade/discourage many programmers who are getting very close answers that are slightly off, where the only solution is to continously reorder operations until you can guess what the submitter was thinking at the time.
This comment is hidden because it contains spoiler information about the solution