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.
Thanks!
Thank you. Your description really clarified the question for me.
The description says:
Thank you! Passed it once I understood that the depreciation is supposed to increase by 0.5% every other month.
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.
Yup. The number of bricks visible for an empty string is 0, not -1. One shouldn't have to set up counter-intuitive catches just to match arbitrary tests. Those tests, and this kata, are essentially broken.
It would be helpful for the clarity of the kata if the precise measurement / conversion of light year was given - or at least a link to the Wikipedia page showing the number of metres, to save people calculating it for themselves and failing the tests.
Interesting. I didn't know that. Removed the headings. :)
Look at the definition tab.
I'm giving myself a headache trying to find the math for part 2. The basis for the math might be physics, but it's definitely math, and as far as I'm concerned, a major issue! (not that a tag would enlighten me on the math required, but to figure it out I need a refresher on calculus, not physics)
I've been there. That's exactly why I asked.
The first answer there is "about 9 trillion kilometres" and another is (on the right) "Unit conversions: 1 ly is equal to 9.4607×1015 m".
But you want the exact IAU definition number.
If you remove the headings above the example blocks, CodeWars will only show the example for the currently selected language. But the codeblocks have to be contiguous.
The language tags on the blocks are already correct. You can preview this in the kata editor (select the language bottom left above the code window.)
Are you using JS? That is fixed now.
Try looking at the light year Wikipedia page. The conversion factor can be found there.
You have got to be kidding me.
(This is JavaScript, BTW.)
Loading more items...