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.
This Kata seemed boring at first sight to be honest but it was entretaining and refreshing at the end :D
this is so clever! I'm learning a lot from Codewars! :D
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.
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
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!
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.
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.
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.
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
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:
I noticed that I always needed one second to get that specific test passed.
used printf to log the total amount of seconds calculated.
secs_passed: 2024.999878
Error. Expected 0, 33, 45 but got 0, 33, 44
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.
It's now solved, all random tests returned good :D
This comment is hidden because it contains spoiler information about the solution
I see, it's kind of expected because it's really useful. I'm always exited to learn something about C :D
This comment is hidden because it contains spoiler information about the solution