6 kyu
Buying a car
362 of 18,068g964
Loading description...
Fundamentals
Mathematics
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.
For 5 testcase in golang i used
int(math.Round(sum-priceNew))
for correct round.Really frustrating when expected 954 and you got 955 :(
Add rounding up to the description (1.55 = 2)
i'm getting roundings issues
Trying this in Ocaml and quickly gave up as it seems I needed to do lots of float<->int conversions.
JS still uses node 8, should be updated to modern versions.
done
I honestly and respectfully think it is hard to explain the problem that bad. Don't waste your time with this kata, I did so I can advise you and complain about it.
Not a kata issue. Unless you pin-point which section of the problem is unclear and suggest rewording improvements, but that is at-most a suggestion
The problem is not very clear.. if the price goes down by 1.5% every month, why is the example provided is not showing the 1.5% down every month? Waste of my time...
Quite an interesting task, it took me 2 evenings, I realized that it is difficult for me to navigate percentages, and I need to read the task more carefully. I'm pleased with the result.
This comment has been hidden.
i need to use malloc
This comment has been hidden.
Note due to formating issues codewars changes some of my * to italics.
Note there is no formattign issues is formatting is used: https://docs.codewars.com/references/markdown#code-block
Not an issue, you should have labelled it as a question.
This comment has been hidden.
C fork
Approved, thanks!
savingPerMonth instead of savingperMonth
Too easy for 6kyu
python new test frame work + snake_case
Approved
Really do NOT love overly math-y problem in bash. Literally the wrong tool for the job. Oh well, I got some experience with
bc
syntax I guess.the example code is very good and only reason I could solve the question.
When your first solution fails, check the examples for clues as to how the actual problem works. I had to toss this one into a spreadsheet to get a clear idea of how it actually worked. This is no different than every programming project ever.
This guy always have the craziest and confusing descriptions XD. This kata doesn't specify why the old car price matter
old price matters since the oldcar gets sold when the new car is bought. So the value of the oldcar is also important in the context of this question.
This comment has been hidden.
This comment has been hidden.
I don't see why it is an issue...
Nice!
I passed all of the tests instead of third(main one), it says Expected: '[0, 4000]', instead got: '[0, 3999]'. What's the problem, if my code returning 3999.1, so logigaly it must be rounded to 3999, not 4000!? Random rests passed with no issue.
This comment has been hidden.
Kata hint != kata suggestion
This comment has been hidden.
Accomplised in c++.
This comment has been hidden.
Interpreting instructions in a real-world application is not always easy either. I like to think of these as practice for dense or unclear legacy code or hard to read documentation. It is also often the case that the author's first language is not English, in which case I'm sure a suggestion for clearer instruction would be helpful
I totally agree with Matteo. The only reason why I wasted my time with this problem is to be able to properly complain about such a loss of time. It is not about English not being your mother tongue though. English is not my mother tongue neither and I can give complete and non contradictory instructions. The instructions doesn't specify why the value of the old car matters (you have to understand from the examples you can sell it in order to buy the new one). The explanation about the float rounding is contradictory. It tells you to truncate and to aproximate it to the nearest int in the same phrase. It is a disaster.
its strange, but kotlin engine cannot resolve Double.roundToInt(), it since from Kotlin 1.2
Kotlin: solved with java Math.round
Author, please, it is wrong to round money leftovers inconsistently, should be either floor or ceiling!
I was really frustratd by this kata, Math.round and Math.ceil didnt do anything for me, I would pass all the tests but fail one out of five on the attempts due to rounding error.
log is 331 expected 332 log is 112 expected 113
FRUSTRATING !
Being frustrated is not a kata issue, sorry. BTW there is no need to round everywhere... Did you read the details of the example?
Math.round gives a long, you need to use toInt(). At least I solved the problem that way
@atenea_nature, you mean to use
Math.toIntExact()
instead ofMath.round()
for calculations ?"percent of loss increases of 0.5 percent at the end of every two months" implies that the loss increases with 0.5%, i.e:
loss = loss * 1.05 instead of loss -= 0.05
Can this text be changed to say 0.5 percentage points instead? https://en.wikipedia.org/wiki/Percentage_point
something like
"percent of loss increasese with 0.5 percentage points at the end of every 2 months"
Sorry but I don't see what your "suggestion" (would not have been an issue from my point of view) brings.
This is an issue with the description. The sentence:
"Furthermore this percent of loss increases of 0.5 percent at the end of every two months."
Is poorly written and is unclear for native English speakers. It is also mathematically does not match the example. The phrase "increase of 0.5 percent" would mean the depreciation percentage should go 1.5, 1.5075, 1.5150375, etc. A correct and more understandable version of the sentence would be:
"Furthermore, the loss percentage should increase by 0.5 percentage points at the end of every two months."
(It would also be nice to mention that this pattern starts after the first month, but at least the example demonstrates that.)
fwiw, in Perl, the use of printf("%.0f",$float) does a "round half to even" which does not work like the conventional "round to infinity" that we learned in grade school math.
the kata could be improved to catch this case, possibly. Not sure if this matters in other languages.
Stack Overflow for the win.
Anyone try this with java? Test 4-6 is failing for me. It says i need 8 months but it only takes 4 months. I even hand computed it and my solution is correct.
Test Passed: Value == '[0, 0]' Expected: '[6, 766]', instead got: '[6, 540]'
Good Kata!
Thanks!
I managed to pass 20 out of 21 tests. Is there a problem with this kata?
No, no problem. Check your code.
Got them all except for the last one, it's off by 1, maybe there's an issue or maybe there's a concept that I didn't know about.
Node 18 (
mocha + chai
) should be enabled (Refer this and this for more info)Ruby 3.0 should be enabled (Refer this & this for more detail)
done
function name should be
snake_case
in crystal and ruby at leastThis comment has been hidden.
Let guys solve the kata by themselves.
A lot of issues with the rounding. When doing kata like this the test should be tolerant for off by 1 errors.
This comment has been hidden.
"Detail of the above example:" I think it shows where to round.
The word "available" seems to be clear. If not it is possible to google it and if you follow the calculation - maybe by hand or with your language - you see where it comes from. If I say how it is calculated as well giving the algorithm.
I don't see where you get that. "Detail of the above example:" shows the contrary.
positive int or float because a price for example can be 1200 or 1200.0 which is the same except for strongly typed languages. For the last it is in reverse order because a percentage is more oten a float than an int. All languages work properly with either input and in case of strongly typed language the signature of the function gives the parameters types. You solved it in C where the signature gave you all you needed about types.
It is your feeling. It is never easy to write a description. One is always between "giving too much" and "not giving enough".
I answered you and my answer is certainly not enough though it took me more than one iteration to answer you. I want to add that solving a kata can often need more than one iteration. Otherwise where would be the pleasure?
I totally agree with OP. The description sucks. Guessing your way out of a bad description does not count as a special required skill on the part of the solver, but of an obnoxious attitude of the author.
It confused me initially since I thought the loss of value in the old cars value would equate to an increase in funds needed as apose to reduction in the total equation but I get it now. ANybody else think this way?
Not getting it!!!!
hmmm I don't get it, so a reduction of 2% of the total value from month 2(2% reduction in value of month 2 after 1.5% reduction) equals 4,811.8??? (without reduction of 1k savings) Please help me what am I doing wrong here?
This comment has been hidden.
my code follows the example instead of the description and it passed. so better follow the example
Hi, How can I return? What is the form? I tried the string, block with address, with value but again and again I get (0,0)... If I return "A" I get (65, 1148846080). (Of course 65 is A but I don't know how to change the secound :( ) Any hint?
You need to mention the language you're using. I know you're using C, so I can tell you you need to return a dynamically allocated integer array... to hold two integers.
"You need to mention the language you're using." This right, sorry, I don't understand myself... But it was in my head.
"you need to return a dynamically allocated integer array" OK, it's fine now but I dont understand, why is not correct if I use block with pointer? Like, int b[2]={0}; int *p; p=t;
There is some problem with this kata.
Car prices are implied to be integer values (at least by input). It means, that they should be rounded each month, however example and test cases have written as they are not. It might be quiet misleading
This part is up to you...
?
Frankly I don't understand what you mean and what you want. Can you be more precise? I suppose that your language is Rust; note that lots of people have passed the Rust kata without problem.
This comment has been hidden.
OP solved it, closing
In file included from main.cpp:7: ./tests.cpp:9:34: error: call to non-static member function without an object argument vector ans1 = BuyCar::nbMonths(2000, 8000, 1000, 1.5); ~~~~~~~~^~~~~~~~ ./tests.cpp:16:34: error: call to non-static member function without an object argument vector ans1 = BuyCar::nbMonths(12000, 8000, 1000, 1.5); ~~~~~~~~^~~~~~~~ 2 errors generated.
How do I fix this error?
This comment has been hidden.
It's a question, not an issue; sorry.
This comment has been hidden.
Print the input.
Thanks. I did that. Helped a lot.
This comment has been hidden.
No wrong tests in a kata passed by 11,709 people...
This comment has been hidden.
I did not like that the solution requires rounding the savings (although stated in the instructions). The true amount of savings should be math.trunc or math.floor, because the bank won't be pitching in the extra cash to bump you to the nearest integer.
Is this kata working? My solution works for 22/25 cases and when I tried using solutions of others it didn't work either.
Which language?
Python? It might happen that tests are incomplete and let some insufficient solutions initially pass, but the tests get improved later so new wrong solutions do not pass anymore but old ones are still listed as valid. Solutions which do not pass new tests are usually automatically invalidated and hidden when the kata is republished or updated to a new version of the language, but it does not always happen when there are lots of solutions in a language (it is the case here with almost 3000 solutions for Python).
I tried several solutions and they passed fine. So the answer is yes the kata is working. Unfortunately it seems that your solution is wrong somewhere and fails a few tests. Print the input to see what happens
This comment has been hidden.
Im not sure, but do we need to increase the savings of $1000 every month?
This comment has been hidden.
OP solved it, closing
Solved it in Reason (thanks to whoever translated it!), but I still find it really hard to write elegant solutions with elegant code in this language compared to Haskell / Clojure 😕
In two of the tests when I click on attempt, there is an error for a single number, example 122 instead of 121, I do not follow it because all the others are good results, I just come to leave it solved because it can happen to another. scala language
This comment has been hidden.
Same happened to me in rust. In combination with poor description this kata is just broken
This comment has been hidden.
This comment has been hidden.
In the description it is said that:
Please update Nim version of this kata. I've written a fully passing solution (zero failed tests), but it's being rejected with
Error: execution of an external program failed: '/workspace/tests '
.Unfortunately your solution is wrong (hence the "Error: execution of an external program failed" ie your program) but the testing function was misplaced so it didn't count the failed tests. Sorry for the inconvenience. I re-edited the Nim translation. Don't forget to reset the page.
You were right, I've found some issues on my side and managed to solve this kata. That was hell of a ride with compound percents. :)
Thanks for your edits, now it's more comfy to track the solution process.
Good!
Description is clear enough. Try to build your algorithm more logically, mates.
I'd say the description isn't clear like many other ppl said
The assumption is, he selling his old car which depriciates at given a rate , plus the monthly savings, to buy the second hand car which is depriciating at the same rate.
I don't know why but I completely missed the other car's price is also decreasing which missed me up a lot Please highlight that part in the description
How does the rounding work in c# , I tried it with Math.Round but I get an error and don't understand why Math.Round does not work. Is the rounding off or am I doing the wrong rounding ?
I believe Math.Round still returns float so you need to cast it to integer Just make sure that the function is giving the desired result before rounding
This comment has been hidden.
my head hurst @_@
... but anw a lot of fun with this.
This comment has been hidden.
A question, not a kata issue. Please read this: https://github.com/codewars/codewars.com/wiki/Troubleshooting-your-solution
thanks @Chrono79 .sorry i don't how to chane issue into question
The task is not clear for whom English is the native language. What can we say about the Russian. And so interesting
This comment has been hidden.
Read carefully the detailed example.
Can someone help me with this one?
I'm solving this Kata using Pascal FPC 3.2. Whenever I try to return an Integer that was converted to String (e.g. thisValue.ToString or IntToStr(thisValue)), there was an error exception on that specific conversion. Could this be a bug or something?
Don't post issue when you ask for help, post a question. When I run your code I get no error for the first test but
Free Pascal Compiler version 3.2.0 [2020/06/14] for x86_64 Copyright (c) 1993-2020 by Florian Klaempfl and others Kata.pas(28,27) Error: Illegal qualifier Kata.pas(28,53) Error: Illegal qualifier Kata.pas(32,4) Fatal: There were 2 errors compiling module, stopping Fatal: Compilation aborted Error: /usr/bin/ppcx64 returned an error exitcode
The function needs a string return value but this error keeps popping off because I used a Integer/Double to String converter, which I know is correct
Look "ToString" in Free Pascal documentation.
In my opinion, description is quite ambigous, but more irritating is the need of rounding available money. Rounding units like money up has no sense for me.
In summary,
wrong:
wrong:
Depreciation is not something that suddenly occurs at a single moment. It is a process that takes place over a period of time. If depreciation rate increases in the end of a month (say Feb 28 23:59), that normally means it will only start excercising its depreciating effect from March 01, 0:00 on. So, according to description, if rate changes end of second month, then first 2 months must be discounted/depreciated at a rate of 1.5. A theoretical case can be made that the amortisation rate is not from regular wear, but from somebody with a crowbar smashing the car in very regular intervals just before end of month. But no talk of such thing in the description. jimmy.clayton is correct in their 1. remark.
g964: The example is correct (and very useful); the description's wording is certainly inaccurate, however.
To be fair, I think a lot of people learnt a few things from solving this kata: Always be very careful when reading (or writing) your problem description; use tests and logging to make sure the behaviour of your code matches with the expected reality!
The description is confusing. There are two almost equal statements:
decrease of 1.5 percent
andincreases of 0.5 percent
. However, from the examples, they mean different things. First one is taking a percent of the values, second one is just an addition to the percent.I labeled it as an issue, but looking at this discussion, I guess nobody is going to fix that.
It is your point of view. Yes, they evidently mean different things: "the prices of his old car and of the new one decrease of 1.5 percent per month. Furthermore this percent of loss increases of 0.5 percent at the end of every two months."
I don't see why I should fix that; somebody said in his post "Kata shows what real problems will have to be solved by those who choose the profession of a programmer." and I can add that the problem comes from a real person. I know that many people have difficulties to understand what happens but the example should help to see if it is understood and you understood it in half of an hour which is not bad for a confusing description:-) Sorry not to please you.
If by "real world problems" you mean clients that make confusing statements, then yes, I agree.
I have tried 3 methods to tweak out the meaning of 1.5 % and 0.5 every 2 months. A simple excise is greatly hampered by the confusion in description. I am a financial person. The issue with this kata is that the author needs to read how we finance and economist people do time alligned financial (value of money) apprails. The key assumption is always to tell upfront with the concept of midperiod, startperiod or endperiod. These assumptions yield different result as every second and minute the value of money changes. I stop guessing what is the intention of the author. After trying 3 methods - compounding, simple, and start vs end, I couldn't get 766, always slightly off
same here
In the end I figured it out that the concept is endperiod, not mid/start period. Please make sure that depreciation is on a reducing balancing basis. After I followed these two principles, my code worked.
Test Results: Test Passed Log [0, 4000] None should equal [0, 4000]
Error for correct answer How to understand this?
You're printing the result instead of returning it. Or doing recursion wrong.
Thank you. You're right
another amazing kata g964!!! Not gonna lie though, i struggle with all of them
Thanks!
Godzilla had a stroke trying to read this description and died
This comment has been hidden.
I know that this kata can be difficult to understand but it is as close as possible to what usual people can ask to a coder hence it is evident that amongst 95,120 people who submitted the kata (kata passed by almost 10,000) many who didn't pass are frustated and have defavorable comments and it is your case.
Small but important note: The description says "... and 766 is the nearest integer to 766.158... (rounding 766.158 gives 766)". It is not said to truncate or to floor but to round. You said that it is "poorly" written but I could say - no offense - that it is poorly read...
Firstly, thanks for the helpful tip; round worked better than floor
I agree with what you have said, it can be difficult to write a kata, hence why I have not written one myself, but you have to admit that there is some ambiguity in the writing style of this particular one, i.e. there is stuff left to interpretation.
Poor explanation. "this percent of loss increases of 0.5 percent at the end of every two months" isn't true based on the test cases. In order to match the cases you need to increment months at the beginning and update monthly loss as needed at the start of the loop which makes absolutely no sense.
Sorry but I think you are wrong...
You can do the change of percentage when you want... but you have to calculate with the correct one at the end of the month since the description says: "Calculations are processed at the end of each considered month". Moreover it depends on how you choose to initialize your months counter:
0
or1
... They are problems for you to code but not a description problem.As someone said (1Dan, post far below): "Isn't it logical that the percentage should be updated before applying any changes to the cost? Selling, buying and saving are normally done at end of month - if you think of your months counter as "number of months that have passed", everything is correct..."
And from someone else "Kata shows what real problems will have to be solved by those who choose the profession of a programmer."
I know that many people have difficulties to understand what happens but the example should help to see if it is understood. The success rate (70%) is not very high (!) but considering that
94757
people tried to pass the kata (9332 succeeded) it is unavoidable that many people are frustated and express their "bad" humor.This comment has been hidden.
Forgive me if the description was different when you read it, but it says: "He wants to keep his old car until he can buy the secondhand one". (So basically implying he's selling his old car to buy the new one).
Tricky wording (overall) I know. I bashed my head on this one for a lot longer than I thought I would !
It says that the loss increses every 2 months, but in the example the loss increased at the end of the firt month.
Random Test, Test 1 , Test 2 passed the test but Test 3 and 4 failed, why? can someone give an example of input
Print the input.
This comment has been hidden.
Wrong; the description says: "766 is the nearest integer to 766.158... (rounding 766.158 gives 766)."
Rounding? Really? If there are left for example 12.75$ after car buying, it do not mean that we have 13$. Description should be updated!
It is all up to the author of the Kata. If he/she wants us to round we do :)
Sure, I agree with you, but this should be in description.
The description of this kata is poor and it seriously needs to be improved. It is not by any means impossible, but it is not at all clear either. It should provide an example and the generic instructions separately, not mixed together into one set. This leads to confusion of which numbers are variables and which are fixed. It is also wrong about the depreciation rates. The description says that the percentloss by month increases at the "end" of the 2nd month. However, to get the correct answers, you must increase this value before calculating the depreciated values of the cars for the second month. This actually means the depreciation rate started at the beginning of the second month. The depreciation takes place over a whole month. If the rate changes at the end of the month, it does not begin depreciating at this rate until the next month.
0.5% increase on 1.5% results in 1.5075% with increse of 0.0075 percent point. You meant 1.5% with 0.5 percent point increase each month. Fe 10% increase on 40% results in 44% or 40% plus 4 percent point.
I give tactics, start at 1.5% from the 1st month and do not take the monthly savings as fixed as 1000, do it according to external values
The description is tricky :-D
This comment has been hidden.
this is the case for every kata authored by g964
Agreed. Poor explanation of the instructions. Doesn't specify that you are selling the old car. You must assume that.
I feel like the description was slightly confusing... the interest increase didn't work out how I thought it my head, was just trailing a change when it all worked...
My solution works perfect on Codewars, but strange things happen when I use my solution on Visual Studio Code. For example, when the input is (6873.7790013165, 10310.668501974751, 500, 3.0), I get the output (6, 268) on Visual Studio Code but (8, 597) - the correct output - on Codewars, remember, with the exact same solution. I also tested 2 other solutions on VS Code and got the same incorrect output. Please could someone give me an idea as to why?
The author should re-evaluate the solution. The solution implies that the increment of depreciation affects the previous month, which seems to contradict the instructions issued. As many have stated, the guidelines should be made clear.
Hi all, can someone help me out with this ? I passed all the test but when attempting I always get an aswer differing on one unit with the expected one, for example:
expect <749> but was <748> ... any clue of what I'm doing wrong?
Hi, you did not pass all the tests. On the one your code fails, the testing stops and you get feedback. You returned
748
for the test, but it was expecting you to return749
."where 6 is the number of months at the end of which he can buy the new car and 766 is the nearest integer to 766.158... (!!!ROUNDING!!! 766.158 gives 766)."
Hi, I figured out that the function name and the function parameters should be in snake_case in Python. How can I improve the style guide for this kata for Python?
reraised as issue
I always get [6, 685] in first test. I included 0.5% every 2 months, but I can do nothing more. It's sadly :-(
Using Java, I can pass all but two tests. Remaining money is off by +/- 1. :( I've tried using BigDecimal and Round. Wish we didn't have to output an int[], because we're dealing with money.
This comment has been hidden.
Use markdown formatting and mark your post as having spoiler content next time, please.
Thanks a lot Chrono79, that will help a lot in the future. And I actually marked it, might have messed it up again while editing. Will be more careful next time, thanks
This must be a Japanese example - in classical economics, prices for new stuff tends to go up ;-).
This comment has been hidden.
Your loop does not consider the falling startPriceOld.
In C++, it would be more appropriate to use a return type of pair rather than vector; this is probably the same for any other supported languages which have the concept of a pair or tuple.
I second this, or just freaking array would make more sense. The problem says to return a [x, y], I shouldn't have to poke through the test cases to figure it wants an vector with 2 entries.
language: swift
in Buying a Care Kata the code does not compile and show this message " main.swift:13:70: error: cannot convert value of type 'Int' to expected argument type 'Double' let act: (Int, Int) = nbMonths(startPriceOld, startPriceNew, savingPerMonth, percentLossByMonth) ^~~~~~~~~~~~~~ Double( ) " although it runs well in xcode playground with all cases without problems
excelent kata. Perfect explanation.
This comment has been hidden.
Did you read this part of the description?
Since there are lots of languages it is not particularly for Scala but you get the idea (BTW next time precise your language).
I had a random test case buyACar(2700, 2700, 1000, 1.4)).toStrictEqual([0, 0]). My code gave here [1,1000]. Next attempt successfully submitted with the same code.
I am not the JS translator but I will have a look. I think you passed the next attempt because you didn't have that case in the random tests. Thanks for your post!
This comment has been hidden.
just use the round function from the source
This comment has been hidden.
This comment has been hidden.
Be more precise on stuff like rounding and whatever else or just avoid, it's trial and error on decimal stuff that has not much to do with algorithms and more like time spent moving knobs on decimal places.
JS? I know Math.round and you?
Number.prototype.toPrecision? In any case I'm a novice not a master like you, and since it's a low level Kyu, some more guidance on rounding operations could be awesome for us noobs!
In the description I added a detail of the example. PS: As far as I know "Number.prototype.toPrecision" returns a string. The description says round to the nearest integer so there is no knobs to move on decimal places...-) Cheers.
@gvilardo: you should have read the description with precision.
The description prevents a good understanding of what we have to do; that was not pleasing at all.
I am sorry but you have to think a bit:-) Most often clients are not perfectly clear about what they want. I can't give the details of the calculatons. 6294 guys passed the kata so one can think it is doable... Plus: you have passed with OCaml which is not frequent!
Oh don't get me wrong, it's doable, but if it was from a client, we would be able to ask if the changes were to be applied at the beginning of the month or at the end of it. It needed tweaks, trial and error.
Usually you other puzzles are tricky because of what they are, not how they are described ^^ (Thanks by the way for the huge number of great katas you provided us with!)
Thanks for your post!
Hint for Go: please don't use math.Floor but math.Round~
The instructions for this kata are horribly unclear.
Definitely needs some clarification for constraints. e.g. does the loss every two months increase in absolute value (percentLossByMonth+0.005) or does it increase in relative value (percentLossByMonth *1.005)?
Most of the java tests are incorrect. I solved the same Kata in Js with the same code and it worked perfectly. Paased all the test.Theres definately something wrong the funtionality of the java tests because this has happend severally.
Look at the top of the page: 867 people passed the Java kata...
The return values should be notated as tuples (and not as lists): For example:
nbMonths(12000, 8000, 1000, 1.5) should return [0, 4000]
should benbMonths(12000, 8000, 1000, 1.5) should return {0, 4000}
And what is the
or (6,766)
supposed to be in:nbMonths(2000, 8000, 1000, 1.5) should return [6, 766] or (6, 766)
?Edit: I just realized that the descriptions are shared across languages. I did it in elixir and it was a bit confusing.
duplicate suggestion
Yo, I have a question. While testing, line int act = nbMonths(startPriceOld, startPriceNew, savingperMonth, percentLossByMonth);, has a correct value e.g. printf("%d, %d", act[0], act[1]) gives 0, 4000. but he line, char sact = array2StringInt(act, 2);, doesn't work, printf("%s", sact) gives out 0, 0. Why is that? I don't understand.
Having trouble completing this kata. On top of the order of operations issues that other people have mentioned. The array2StringInt function seems to be mangling my answer and I'm not sure why. If I place this
printf("Error. Expected %d but got %d\n", *(expr+1), *(act+1));
orprintf("Error. Expected %d but got %d\n", *expr, *act);
before that function my numbers match up with the given array. After that function my array values and string values become nonsense. I'm attempting to do the kata in C.I tried a few solutions and they worked fine. 269 guys passed the C translation. Cheers.
The instructions on this Kata need to be made far more clear.
For one - you must increase the percent of devaluing at the beginning of month 2, or you will not get the correct answer.
The instructions counter intuitively state
Furthermore this percent of loss increases by 0.5 percent at the end of every two months.
meaning I only came to this conclusion via trial and error.On top of this, the level of rounding required is entirely unclear.
When recalculating the new value each month, do we need to round the figure? Up/Down? To how many places?
So far, no matter what combination of rounding methods I use, I always have at least 3 test cases where my remaining figure is out by 1 - I'm slowly moving my decimal out, and will hopefully hit it soon.
This is an interesting Kata, and as a Junior who is learning I have found it useful in many ways - the best lesson is that requirements should be clear from the get go.
it is clearly stated in the exercise that calculations happen at the end of the month but the increase of percentLossByMonth is increased "every 2 months" which will mean that the first increase happens at the start of month 3.
Otherwise the first increase happens BEFORE 2 months have passed, and then every 2 months after that, which would be insane.
I have a problem with passing test 4 and test 5 using Java. "arrays first differed at element [1]; expected:<332> but was:<331>" in test 4 and "arrays first differed at element [1]; expected:<122> but was:<121>" in test 5. So I get the result which is only one less then the one I need. But it's OK in other tests, including sample ones. I think there might be a problem with rounding, but I can't figure out what kind of problem exactly.
I'm not familiar to Java, but I had the similar problem in C++. I had to change the types of the function arguments (int to double). It worked for me. As for rounding I used nothing but round().
It worked. thank you.
This saved me as well! Thank you!
"A man has a rather old car being worth $2000." I assume this means, "$2,000 trade-in value.", and therefore should be deducted from the new purchase cost...
This comment has been hidden.
Thank you for this - was having trouble getting the remaining amount correct, your explanation clarifies the kata description.
It is impossible to know if the bi-monthly loss increase should first be applied at the end of the first or second month. It is thus impossible to get the kata right without luck or trial and error.
Please fix the description.
Description:
With the example given in the description
nbMonths(2000, 8000, 1000, 1.5) should return [6, 766]
you get for "months", "percentLossByMonth", "available" (rounded):The thing to understand is: at each step you use the correct percentLossByMonth before doing your calculations. Is that clearer?
That gets rid of the ambiguity, thanks! However, I must say that changing the percentage at the end of the month and then calculating with it for that month is borderline criminal. But perhaps expected when bankers and car salsemen are involved.
The honest thing to do is to change the percentage at the start of the month and calculate with it at the end of the month. But maybe that's just me...
You can do the change of percentage when you want... but calculate with the correct one at the end of the month. Once more, description says:
My solution is not maybe the best but if you have time take a look at it:-)
This comment has been hidden.
Kata: ...Furthermore the percent of loss increases by a fixed 0.5 percent at the end of every two months. ... And all the test increse it at the XXXXing START of every two months.
LOTS OF grammar fail even I'm not native English user can point it out. ex: decrease of(X) decrease by(O)
Also, parameter savingperMonth(X), should be savingPerMonth
All operations are considered at the end of the months.
"Yearly sales decreased by five percent." (from https://www.merriam-webster.com/dictionary/decrease)
but "a decrease of 20,000" (from https://www.merriam-webster.com/dictionary/decrease)
I replaced
savingperMonth
bysavingPerMonth
It seems that
decrease
can be followed byof
orby
but I'm not a native speaker and everybody could be wrong: yourself have written "increse" instead of "increase". Moreover - without wanting to be unpleasant - your sentence "LOTS OF grammar fail even I'm not native English user can point it out." is not a model of English grammar. Regards.@vivi00790: better to write correctly before giving English lessons.
This is throwing up random grammar errors for words that are correctly spelled, not sure if it's this kata or something wrong with the site
Be more precise, otherwise it is impossible to answer.
I do try to be as efficient as possible, but it was flagging up errors with the spelling of the 'return' statement, and was names of objects that were correctly spelled, it's a shame because the kata is testing me
This could have been a great kata if the discription was not so awful, honestly the 69% satisfaction rate is kind considering just how many assumptions are required to complete this.
The description is horrendous and includes an incorrect statement, specifically "...this percent of loss increases by 0.5 percent at the end of every two months"
To pass, you actually have to assume that the percentage loss increase happens at the beginning of every two months (or the end of the previous month). For example in the first test case, if your code passes, it should report the value of the old car to be 1930.6 at the end of month 2, meaning that the car depreciated by 2.0% during month 2. That should not be the case, since according to the description the percentage loss should not increase from 1.5% to 2.0% until the END of month 2 (i.e., the car should've only depreciated by 1.5% in month 2).
thank u, I only figured out how to do with it when I read your comment and realizes that the percentage loss increases "0.5%" of the CAR's price, not the percentage itself. Really horrendous description.
This comment has been hidden.
Post really poor. Look at the meaning of increase...
I like Kata. Now I can not only learn Elixir but also understad Elixir + Pattern Matching of Function. Even if my code was still procedural programing style, it was great time to learn elixir and code reviewing clever codes.
I just gave up.
I don't get what was wrong with my code and I won't post it here, I tried many things but it seems I don't get everything.
This is really frustrating, I've got the feeling that the instructions are unclear but since I haven't completed it I don't want to exclude the possibility that I'm just an idiot :(
We all idiots :) Why bother? Try to write down a description of the kata on your own without looking at the original description while doing this be precise as much as possible. Next step - carefully design your algorithm.
This comment has been hidden.
Thanks!
I think the question was worded very poorly. I interpreted it as the loss increasing by 0.5%, meaning a loss of 1% would now go to 1.005%. However, you are really just adding .5% to the loss, so a loss of 1% would go to 1.5% .... Spent way too long trying to figure out the issue with my code, but this solved it.
I have problems while rounding values in java.The answer to some sample tests(not all) is one less or one more than expected answer. Is anyone facing the same ? Its defintely a time waste kata
This comment has been hidden.
No longer believe it is the comments, running the same code multiple times I get different pass rates. Probably a flaw in my programming logic, but kinda cool to realize that this could be a real problem to consider when developing in the workplace.
Do we have a math Guru who has managed to solve this through an equation? :)
in clojure how do you solve this? 2 tests fail becuase of rounding. the only rounding procedure that i found is int but it gives incorrect answer in this 2 tests because (int 2.9) is 2
also i accidentally deleted ns, how it looks like?
It is a question, not an issue (note at the top of the page that 42 guys passed the Clojure translation). For the deleted ns push the "RESET" button.
what is the answer then? i tryed all that i could find on rounding, even defining it but its like always uses stuff from java which cannot be used here, but can be used anywhere else even at repl.it
The description is really makes people misunderstanding, the right thing should be: the first month of the decrease percentage is 1.5%, 2 and 3 month is 2.0%, 4 and 5 mouth is 2.5%... only in this way we could got the right output... waste my 2 hours...::>_<::
Good kata
Do not use Math.round... use Math.floor !!!!! at this Kata)
In javascript is the opposite, Math.floor gives errors, Math.round passes the tests.
c# using "floor" occurs a failure "round"- ok
The problem starts with trying to understand the question itself with the horrendous grammar. Do these probems get reviewed before being created? Interesting how this is also an accounting based question.
The description should be rewritten slightly:
I will precise the rounding and that the beginning is an example. Will it remain clear if I remove "fixed in "fixed 0.5"?
Yes, that'd be better.
Done, thanks again.
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.
Selling, buying and saving are normally done at end of month
- if you think of your months counter as "number of months that have passed", everything is correct because only 1 month passed, NOT 2, and you should not adjust anything.round
.Parameters and return of function
part clarifies that all the mentioned values are parameters to the function.Not an issue, but question. If 4000 people understood the task while you do not, that's your problem.
@FArekkusu: thanks, I can't say better!
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.
You saved my day bro) I started month from 0 and it is not right. Many thanks !!!
Kata shows what real problems will have to be solved by those who choose the profession of a programmer.
I agree with most people here that this was poorly worded. I spent a good hour trying to get the remaining balance right. I knew there was something wrong with the percentage increments "every two months". It increases in the 2nd month AFTER the calculation to decrease the prices of the cars.
One of the most poorly-described katas I have encountered. 2 hours wasted, but a great lesson in anger management. May its creator burn in hell.
I do think the author do this on purpose to simulate a unclear requirement problem faced everyday by programmers.
And if you points it out, he will pull the ole "xxx numbers of people passed the kata" crap. Boils anyones blood really.
I cant do most of his kata but I dont hate him.
Very poorly worded question! There are so many different ways you could interprept the bi-monthly 0.5 pct. For example, is it 0.5 of the monthly valuation pre or post the 1.5 deduction? is it 0.5 of the value last time you deducted 0.5 (i.e. two months ago) or is it that the monthly 1.5 increases by 0.5 every 2 months (i.e. month 1 = 1.5%, month 2 = 2%, month 3 = 2%, month 4 = 2.5% etc).
FYI its the last one.
I would just like to clarify, the percentage decrease applies to both new and old car price, right? Secondly, if prices are going to be decreased by decimal values why would they be passed in as integers and not double or decimal?
I had a random test (data = 5864, 8410, 1193, 1.5) fail with a value just below x.5000 (in both my Fortran & Excel) being rounded UP to x + 1, so I added a halfpenny!
The description was unnecessarily unclear and lead me in the wrong direction. Thanks to @creightonja 's (and others) comments I learned the intended incrementing pattern of the bi-monthly percentage - 1.5 in month 1, 2 in month 2, 2 in month 3, and 2.5 in month 4, etc.
This had a lot of potential, but the poor explanation of the variables and how they change made it needlessly confusing.
I had to read the comments to see how the depreciation value changed month by month. I originally had it set up to change at the end of the 2nd month, thereby increasing the depreciation rate in the 3rd month's calculation. Luckily I found a comment that showed it was 1.5 in month 1, 2 in month 2, 2 in month 3, and 2.5 in month 4.
This comment has been hidden.
I have solved it,but this task is a waste of time...
Overall very poorly written question. I had to re-read everything over and over for complete comprehension. And for the final result to work with all test cases I needed to use round() instead of int(). This is a poor use of time. If something that insignificant is going to pass everything save for one test case, then the round outcome should be explicitly requested.
the every two months is absoluately confusing. the reason why i spend two hours.lol
The wording "Furthermore the percent of loss [...]" clearly implies that it only goes for the depreciation of the OLD car, not the new (that's a WIN, not a LOSS)
is WAY more accurate. (thanks to designerzim)
This comment has been hidden.
It's 1.5 2 2 2.5 2.5 3 and so on
argh, I thought the depreciation is compounded ):OP solved it, closing
This comment has been hidden.
I have 42 right and 3 wrong, I dont get what is happening here, what are the numbers for those test's? Thanks
Basic tests Test Passed: Value == '[6, 766]' Test Passed: Value == '[0, 4000]' Expected: '[8, 597]', instead got: '[4, 235]' Expected: '[8, 332]', instead got: '[11, 542]' Expected: '[25, 122]', instead got: '[15, 469]'
Did you use the variable for the saved money per month? I used a the fixed amount of 1000$ in the beginning which led to the same failures.
Hi, yes I did use a variable for the money: this.savingperMonth = savingperMonth, however I did use a fix amount to add the money, I change that, thanks.
I had the same problem. It was caused by adding +1000 to the savings counter every month (as the decription says), but if you pay attention you can see that there is a savingperMonth parameter - calculate with that instead of the fixed 1000.
I think the elixir description is wrong. I state it can be either returned a list
[month, moneyLeft]
or(month, moneyLeft)
, however to pass the "Attempt" you need to return a tuple{month, moneyLeft}
. I somehow can't suggest a change in the description.If you are using Python, use round() instead of int() to approximate the result, otherwise, in my case, one of the tests wouldn't pass.
This comment has been hidden.
Thank you!
kata hint != kata suggestion
You probably shouldn't give a static savings amount in the description if a couple tests don't use it. It took me way too long to realize my problem was using said number instead of the variable, granted that there was a variable in the first place meant I probably should've used it.
Hi,
there is a small mistake in the description:
If, for example, at the end of first month the percent of loss is 1, end of second month percent of loss is 1.5, end of third month still 1.5, end of 4th month 2 and so on ...
should be:If, for example, at the end of first month the percent of loss is 1.5, at the end of second month percent of loss is 1.5, end of third month still 1.5, end of 4th month 2 and so on ...
I wanted to update the description, but I got a message saying that modifications have been made and not published, so I preferred to avoid any troubles and didn't do it.
cheers,
B4B
I thank you very much for your post but so many guys have passed the kata that I think it is better to let the description as it is (note: the kata was approved by @jhoffner). In fact each one interprets the description his own way depending when they begin to number the months. Some begin with month = 0, others with month = 1 and they change the percent when the month number is even or odd according to their numbering choice. Maybe it would be even better if I suppressed the example only saying
Please tell me what you think of that.
Damn, I didn't think about this problem... Yes, I believe that it would be better without it then.
bye
Done, thanks!
26 corrects and the others error why? :(
Problem(s) in your code.
This comment has been hidden.
Instructions are too complicated. Gave up after 30 minutes unable to figure out what to round.
same here..
If, for example, at the end of first month the percent of loss is 1, end of second month percent of loss is 1.5, end of third month still 1.5, end of 4th month 2 and so on ...
The statement should correct as
If, for example, at the end of first month the percent of loss is 1.5, end of second month percent of loss is 2, end of third month still 2, end of 4th month 2.5 and so on ...
The describtion of this question is too diffcult to understand.
Couldn't understand why I kept failing all the tests until I read this.
This comment has been hidden.
This comment has been hidden.
.
This comment has been hidden.
.
@cypherrage and @sly_raccoon: Better would be to ask yourself why your return doesn't work. Then you would not waste your time. Hint: the problem is in your code, not in the function
array2StringInt()
..
Maybe you should read that:
https://stackoverflow.com/questions/40182644/local-variables-in-c
I hope you will be able to take advantage of it and that helps you. You could also google "c return of local variable". Good luck.
PS: it's childish to downvote my posts. I could do the same with yours and I didn't do it... For which avail?
@cypherrage and @sly_raccoon:
First thing to do: learning C! You wrote:
When you return a local variable the behaviour is undefined because it is no more on the stack!!!
array2StringInt()
works very well.@cypherrage: no need to be arrogant:-)
This comment has been hidden.
It helped to skim over the discourse prior to attempting this Kata. In particular, the improved description provided by designerzim was comprehensive and cleared potential misunderstandings.
Indeed, especially
is WAY more accurate. I'm filing an issue because "Furthermore the percent of loss" clearly implies that it only goes for the depreciation of the OLD car, not the new (that's a WIN, not a LOSS)
Duplicate suggestion above
C:
I have a working algorithm but I'm having trouble with returning the array. Commenting out the call to free() works fine with the example test. If not, I get an
*** Error in `/home/codewarrior/solution': munmap_chunk(): invalid pointer: 0x00007ffd94be9eb0 ***
int* nbMonths(int startPriceOld, int startPriceNew, int savingperMonth, double percentLossByMonth) { int * result; result = (int *) malloc(result); ... return result; }
void dotest(int startPriceOld, int startPriceNew, int savingperMonth, double percentLossByMonth, int *expr) { .... //free(act); act = NULL;
Any advice?
This comment has been hidden.
This comment has been hidden.
When you pose a question about your code don't post an issue - which makes the author lose honor - simply label your post with "Question".
Sorry, learning the rules...
Nice kata, I've somewhat figured out the solution, but the problems were with the floating point in java, which gave me a good headache :D
This comment has been hidden.
The tests are the same in all languages and 1545 guys passed the kata... It depends where you put your line about the 'Percent loss by month". Look at other solutions. I don't see any issue in that.
This comment has been hidden.
Read again: 1
2
1 shows the "percent loss by month" cannot change at month 0: it happens at the "end" of ...
I hope it is clearer now:-) Anyway thanks for your post. One is never too precise!
This comment has been hidden.
Improved description:
The first test case represents this situation: A man has an old car worth $2000. He is planning to buy a new car worth $8000. He needs a car, so while he saves up for the new car, he cannot get rid of his old car. He thinks he can save $1000 each month. He will use his savings plus the value of his old car to buy the new car.
The major complication is the value of both cars is decreasing (i.e. depreciating). They both decrease by the same percent per month, 1.5% for our first test. Additionally, the amount of depreciation increases by 0.5 percent every second month.
For each test: the price of the old car, the price of the new car, the amount saved per month, and the percentage of depreciation.
Can you help him? Our man finds it difficult to make all these calculations.
How many months will it take him to save up enough money to buy the car he wants, and how much money will he have left over?
Parameters and return of function:
parameter (positive int, guaranteed) startPriceOld (Old car price) parameter (positive int, guaranteed) startPriceNew (New car price) parameter (positive int, guaranteed) savingperMonth parameter (positive float, guaranteed) percentLossByMonth
return (int array) [ months elapsed, money left over]
nbMonths(2000, 8000, 1000, 1.5) should return [6, 766]
Where 6 is the number of months at the end of which he can buy the new car and 766 is the nearest integer to '766.16....'
Example of depreciation per month:
If the starting depreciation is 1%, then the end of the first month is clearly 1%. This means the end of second month percent of loss is 1.5%. Next, the end of third month holds at 1.5%, and the end of 4th month is 2%, and so on....
Note: Calculations are processed at the end of each month. When the value of the old car (plus savings, as necessary) is greater than the new car, the purchase will be made immediately. This means if the old car is more valuable than the new car, the new car must be purchased before any savings or depreciation occur. Values of both cars, modified by the percent of depreciation, need to be floating point values within the function. Only the final return values should be rounded off to an int.
Thank you! Passed it once I understood that the depreciation is supposed to increase by 0.5% every other month.
The description says:
Thank you. Your description really clarified the question for me.
Thanks!
I passed 1 test and after I always get error:
If I just comment out:
and all tests passed.
I think (probably) thete is some issue in tests code...
@g964 could you check please
Sorry, my mistake.
What is the second return? How much he has left from the money from his old car after buying the new one or is it the price of the new one? The latter doesn't make that much sense because in one example it was 12k (old car) and 8k (new one) and the number was 4k so obviously subtraction however the 700 and something confuse me. It would be amazing to see one calculative example instead of what kind of input you get (which is also nice but not that important). Additionally the first part of the instruction just confuses since there are real numbers but they aren't even the ones you calculate with.
poor, over-complicated explanation/directions that made the problem difficult to understand
treat this as a part of practicing. You aren't always getting super-duper perfect clear docs, are you?
This comment has been hidden.
The documentation is very lackluster. It doesn't specify in which order the calculations are done, when rounding occurs, etc. Implementing the base is trivial, but then figuring out which order the tests want you to perform the calculations in is tedious.
It not that hard. It maybe 7-8 kyu, not 6 kyu.
It is difficult not for implementing, but for understanding due to blurred definitions. The exact sequence of actions is not clear. I was able to solve the problem only when rephrase "the end of the even month" to "beginning of odd month".
Everything is not hard after you do it P:
the real Kata should be to understand the question. :)
All my tests are coming back correct with no fails but for some reason I'm unable to submit! :(. Can anyone help?
Just tried and it worked.
Just got mine working too. Had to refresh the page - must have been some issue
Hi . i am wondering when all my test are resulting correct , what is going wrong on my last test for this kata Test Results: ✔ Test Passed: Value == [6, 766] ✔ Test Passed: Value == [0, 4000] ✘ Expected: [8, 597], instead got: [8, 563]
This comment has been hidden.
I am sorry for you but the tests are correct. They are the same in all languages, 972 guys passed the kata (129 in JS).
This comment has been hidden.
All tests seems to give 2000,8000 as arguments?
Did you pass the kata?
This comment has been hidden.
The documentation got me all mixed up. You have to notice that even though the instructions say "the man saves ~1000$ month" the real input might be different (from parameter). This is pretty simple and basic stuff but for somehow I took that 1K as granted and did lots of waste work.
me too
me three ! I would've never figured it out untill I read your comment. I almost gave up !
Really bad documented... all i can say
This was both boring, and horribly documented. You need to figure out that you only round on the final value, but that means that int's that they passed don't actually work. Furthermore the test cases don't actually help since there are rounding complaints that make it both boring to debug and a pain to solve.
Very boring, waste my time.
For people using Haskell, changing the type signature to
nbMonths :: (Enum a, RealFrac a) => a -> a -> a -> a -> [Integer]
will save you a lot of type coercions.The code is idiotically simple, time wasted with this kata trying to understand the unnecessarily complicated problem formulation.
I don't think this warrents an
issue
Yeah, maybe you're right. But I maintain that the problem formulation could be improved.
I really don't get what this percent of loss is related about:
?
I'm puzzled. This kata is not difficult to solve, rather to understand.
Yes, i have made it, and it was confusing... The first month is about 1.5%, next two months 2%, next Two ones 2.5%... You have to apply that to old and new car price. And you must return the money available when buying the car: priceNewCar-priceOldCar+saving, if and only if, you have to apply percent of loss.
still not clear. how much is the price of old car after 3 months, starting from 2000?
Also cant find the answer for this crap, to initial is not correct since it will always product rounded number, but the result is a double, to the price getting updated every month then i get 355 after month 6, super confusing
This comment has been hidden.
This comment has been hidden.
It returns the allowance remained after the correspinding month. (priceNewCar-priceOldCar+saving)
In C++ the public testcases don't use 'namespace std' and therefore throw errors.
If you edit the kata you will see at the first line of public tests:
using namespace std;
but when you "Train" or "Train Again" CW doesn't show it and doesn't use it!... despite the fact that I re-published the C++ translation a lot of times. Sorry for the inconvenience! Fortunately it is easy to fix by the user all the more that there are no problem in the ""Submit tests.Sorry for that. I never created a kata so I didn't know what to look at and saw no comment on this issue.
Thanks for your posts. I was at last able to fix that.
C# Can't understand what the problem with Math.Round(). Test 3 and Random tests are failed. If I have no use Math.Round() Test 1, 4 and Random are failed. I've read all of comments:)
startPriceOld -= (int)Math.Round(startPriceOld * percentLossByMonth / 100.0); startPriceNew -= (int)Math.Round(startPriceNew * percentLossByMonth / 100.0);
Can somebody tell me where is my mistake?
As written in the description only the leftover is rounded: ...and 766 is the nearest integer to '766.158...' .
Nice, challenging kata! Thanx!