Ad
  • Custom User Avatar

    This Kata seemed boring at first sight to be honest but it was entretaining and refreshing at the end :D

  • Custom User Avatar

    this is so clever! I'm learning a lot from Codewars! :D

  • Custom User Avatar

    I loved this kata, made me realize that I've got some skills with bits and ascii but I wasted a lot of time just because I didn't calculate the output lenght correctly, any tips so this won't happen again? For C language, I gave it more than I sould have and then placed the '\0' character way after the end of the string, thus printing garbage chars.

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    Hey hobovsky, I finally understood what was wrong with my solution and finally got to use integers only. I just want to add for future reference, for any warrior with the same problem:

    if you see this and you are using double or float types, it's wrong, TRY USING INTEGERS, is the only way. You can see above that I've tried in so many ways with floats and doubles but IT DOES NOT WORK.

    So, yeah try again using ints.

    Thanks a lot for your time hobovsky!

  • Custom User Avatar

    try again using integers only, belieave me, it's the only way. I tried using float and double and the only "other" way is using double but adding a hardcoded amount of 0.000002 or something like that, which is not correct.

  • Custom User Avatar

    I think I get it now, it's like seeing them like:
    1:15:59 and 2:03:17

    So the difference is:
    00:47:18

    Great! thanks a lot, like I said I misunderstood the description.

  • Custom User Avatar

    Hello, I'm stuck with the tests too, I think I'm understanding the problem in the wrong way but here's my question anyway:

    From your example on the problem's description, How do you get a range of 00 for a set of {01,01,01,01,02} hours, isn't it supposed to be 01 (highest:02 - lowest:01)?
    "01|15|59, 1|47|6, 01|17|20, 1|32|34, 2|3|17"

    "Range: 00|47|18 Average: 01|35|15 Median: 01|32|34"

    From how I understand the problem, to get a range of 00 you'd need to have a full set of runners taking 2 hours min each.

    I have kind of the same question for everything else (all tests), I'm getting all the tests wrong but I think my solution is right, at least for the description I understood.

    It's been a really fun and refreshing kata aside from that issue.

  • Custom User Avatar

    I see now what you mean, I guess I just got lucky and randomly worked twice and I supposed that was it, but when you mention that it had failed, I tried to investigate further and this is what I found:

    • it turns out that printf was rounding up the value of my variable because I didn't gave it enough decimal digits, so it displayed, for example, 3660.0000 instead of the actual value of the variable which was, 3659.999999999998. So, in addition when I did the rest of the operations whith ints, C rounds down the number to 3659 taking away one second and making the output wrong.

    • finally, as someone has stated, adding a really small amount like 0.0000002 to the total of seconds it's a trick to work with float/double variables.

    • or you can just work with ints, although for my solution it gave a FP error and I couldn't figure out why.

    Hopefully this helps current and future warriors :P

  • Custom User Avatar

    Using C language

    As many others have stated, I had the issue where the only the last random test would return error, my solution was the following:

    1. I noticed that I always needed one second to get that specific test passed.

    2. used printf to log the total amount of seconds calculated.
      secs_passed: 2024.999878
      Error. Expected 0, 33, 45 but got 0, 33, 44

    3. So I used double for the all the calculations regarding seconds (except the ones where I calculated hours, mins, secs). Some were double declarations and some casting.

    4. It's now solved, all random tests returned good :D

    • This seems to be an acquaricy problem just like hobovsky has stated in multiple answers bellow, so I think it could work with integers too, what I can guarantee you is that it does work properly using double types on your calculations (except for the returned array).
  • Custom User Avatar

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

  • Custom User Avatar

    I see, it's kind of expected because it's really useful. I'm always exited to learn something about C :D

  • Custom User Avatar

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