Ad
  • Default User Avatar

    Nice Kata! However, Java tests (random tests) dont really test the solution properly, as there are 99,9% chance that the time chunk will end with seconds. This way, u can just use "...and second(s)", as there are almost never a test ending with days/hours (which needs to be solved through "...days and 3 hours").
    I suggest adding some manually writen tests exactly for those cases, otherwise not fully-solved Katas are getting through.

  • Custom User Avatar

    Nice one indeed, i actualy did the smae as you.

  • Custom User Avatar

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

  • Default User Avatar

    expected x to equal y

    means that the tests expected y but your code returned x. you are missing a comma after 182 days. please do not raise issues so lightly in the future, ask questions instead.

  • Custom User Avatar

    Error in browser
    Expected : 182 days 1 hour, 44 minutes and 40 seconds
    to equal : 182 days, 1 hour, 44 minutes and 40 seconds
    But in my vscode i get 182 days 1 hour, 44 minutes and 40 seconds
    How can this be?

  • Custom User Avatar
  • Custom User Avatar

    his ahh is not 4q :skull:

    5q maybe?

  • Custom User Avatar

    The tests are fine, your function's name is formatDuration instead of format_duration. Rename it so the tests find it.

  • Custom User Avatar

    Looks like there is a problem in python tests

    it starts with:

    import codewars_test as test
    from solution import format_duration

    but when I run I get:

    Traceback (most recent call last):
    File "/workspace/default/tests.py", line 2, in
    from solution import format_duration
    ImportError: cannot import name 'format_duration' from 'solution' (/workspace/default/solution.py)

  • Custom User Avatar

    I wish this used oxford comma :<

  • Custom User Avatar

    This one in shell was great. Techniques were applied like never before.

  • Custom User Avatar

    Otherwise, the duration is expressed as a combination of years, days, hours, minutes and seconds.

    There are no months there. Not a kata issue.

  • Default User Avatar

    I'm a new programmer, I might be wrong, but some test cases do not follow some of of the given instructions

    I used a greedy approach so solve the problem because you said "A unit of time must be used "as much as possible. It means that the function should not return 61 seconds, but 1 minute and 1 second instead. Formally, the duration specified by of a component must not be greater than any valid more significant unit of time"

    And here you're testing the opposite: "Incorrect answer for seconds=15731080: expected '6 months, 2 days, 1 hour, 44 minutes …' to equal '182 days, 1 hour, 44 minutes and 40 s…'
    Isn't month a more significant unit of time than days if it isn't and I'm wrong what criteria do you use to determine "the more significant unit of time"

  • Custom User Avatar

    OP solved it, closing.

  • Default User Avatar

    What I do wrong?
    Passed: 107 Failed: 6
    '4 years, 104 days, 3 hours and 4 minutes' should equal '4 years, 68 days, 3 hours and 4 minutes'
    '6 years, 246 days, 13 hours, 3 minutes and 54 seconds' should equal '6 years, 192 days, 13 hours, 3 minutes and 54 seconds'
    '8 years, 84 days, 13 hours, 41 minutes and 1 second' should equal '8 years, 12 days, 13 hours, 41 minutes and 1 second'
    '7 years, 309 days, 15 hours, 32 minutes and 54 seconds' should equal '7 years, 246 days, 15 hours, 32 minutes and 54 seconds'
    '3 years, 112 days, 1 hour, 9 minutes and 26 seconds' should equal '3 years, 85 days, 1 hour, 9 minutes and 26 seconds'
    '1 year, 28 days, 18 hours, 19 minutes and 46 seconds' should equal '1 year, 19 days, 18 hours, 19 minutes and 46 seconds'

  • Loading more items...