Ad
  • Custom User Avatar

    Thank you very much. finally solved the cata

  • Custom User Avatar

    Hi @multi - I'm new to C++ so perhaps not the best person to answer in detail, but I was able to solve the kata and then debug your code in the editor a bit.

    I found that the error you get is occuring when the input is an empty vector - I fixed this error above by having a check for if (v.size() == 0) { ... return an empty PeakData struct... } at the top of your code. It seems afterwards there are still some edge cases on which your code fails but at least it's no longer UB.

    Please though, in future, use the Codewars markdown if you want to have messages with lots of code - especially more "complicated" languages - as other people are more likely to help you if they can easily read the code.

    Also, please consider using the Question tag first before raising an Issue, as the latter tag is reserved for serious problems with the kata itself. Happy coding!

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    You used Date, as I understand =)
    The task said that you should take 365 days as year.
    But the Date takes leap year into account.

  • Custom User Avatar

    5 tests of mine return undefined :/

  • Custom User Avatar

    Your year value is exact, with the year being 365.2425 days long. As said above, use 365 days for the year.

  • Custom User Avatar
  • Custom User Avatar
  • Custom User Avatar

    No, that's a problem with your code, all those tests are more than 1 year, check that.

    For the purpose of this Kata, a year is 365 days and a day is 24 hours.

  • Custom User Avatar

    interesting challenge.. took me more time in formatting though ...

  • Custom User Avatar

    107 tests have passed, 6 test Failed.
    Expected: '4 years, 68 days, 3 hours and 4 minutes', instead got: '4 years, 67 days, 3 hours, 47 minutes and 12 seconds'
    Expected: '6 years, 192 days, 13 hours, 3 minutes and 54 seconds', instead got: '6 years, 191 days, 2 hours, 8 minutes and 42 seconds'
    Expected: '8 years, 12 days, 13 hours, 41 minutes and 1 second', instead got: '8 years, 10 days, 15 hours, 7 minutes and 25 seconds'
    Expected: '7 years, 246 days, 15 hours, 32 minutes and 54 seconds', instead got: '7 years, 244 days, 22 hours, 48 minutes and 30 seconds'
    Expected: '3 years, 85 days, 1 hour, 9 minutes and 26 seconds', instead got: '3 years, 84 days, 7 hours, 41 minutes and 50 seconds'
    Expected: '1 year, 19 days, 18 hours, 19 minutes and 46 seconds', instead got: '1 year, 19 days, 12 hours, 30 minutes and 34 seconds'

    Something must be wrong in this tests... or i Can't see why they are fail when other 107 have passed...
    Language is JS

  • Custom User Avatar

    I don't understand how to count more than 250 wagons in 16s?

  • Custom User Avatar

    Thx bro, now my solution complete)

  • Custom User Avatar

    the test uses a created function to do the calculation
    all u need to do is print the value entered in function

  • Custom User Avatar

    How can I print them?
    I need to add some command to my program? wich one? tell me please.

  • Loading more items...