6 kyu
Simple time difference
463 of 1,489KenKamau
Loading description...
Algorithms
Date Time
Strings
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
Shouldn't it be stated clearly within the desc that input is guaranteed to not be empty? Having at least one time item as argument.
I'm saying that as I'm translating the kata and wanted to ensure test cases are written properly (i.e no need to handle such an edge case e.g)
Kindly LMK as I see the solution && test cases are based on that fact without clarifying it in the description.
I'd rather to always have I/O section provided for any kinda kata to standardize the process a bit.
It's not the only missing thing here. Another thing which would use some explanation is whether periods wrap around midnight or not. For alarms set to nine o'clock and ten o'clock, is the valid answer "one hour", or "23 hours", and why?
Good point & good input example, but the author implicitly explained it within the desc with the first and second examples provided. The intention of the kata is to define the day as the 24 hrs starting from first time the alarm rings at (the least value provided) all the way to itself again, with no consideration to midnight. "Midnight is just a mankind agreement on day start & end, still controversial though!"
That said, yeah with the input you suggest
["09:00", "10:00"]
should return 23 hrs or more precisely "22:59" since alaram takes a minute till stops ringing and that minute isn't taken into account, so we start counting after which all the way until the next ring. And that's a day according to the kata's implicit definition.In other words, we can get 2 intervals from that input during the entire day (9 o'clock - 9 o'clock):
The provided solution & test cases also verifies that intention.
LMK if I missed something :)
Cheers,
Go Translation
python new test framework is required. updated in this fork
Approved
There is probably error in test cases in cpp version in the last example.
Description should be language-agnostic (Removal of function names)
I think the verb "go off" is confusing for non-native English speakers. They could think it means "to shut down" rather than the opposite.
So basically "goes off" means "starts ringing". If you find this helpful, give it a like.
Can you please check if description in this fork is any clearer?
Yes it seems clearer.
.
I think the Python random tests are broken. Would you check them, please?
No they are not. Don't raise issues so lightly please, you must prove there is an issue, not just think and provide no element. See there: https://docs.codewars.com/training/troubleshooting/
for test.assert_equals(solve(["21:14", "15:34", "14:51", "06:25", "15:30"]),"09:10") how do u get 0910? Isn't the greatest time diff between alarms 0825 ( from 0625 to 1410)
21:14 and 6:25 difference is 9:10
i think qn is misleading saying that alarms on are the same day. To get 0910, we are saying that 0625 alarm is actually the next day
Great kata ~~
This comment has been hidden.
ok... this is a dejavu... i think the C random tests are broken... or the description is not describing something... because it fails on random tests i ordered the alarms and clearly there is 07:28 07:28 07:50 10:00 10:00... which is a 02:09 time difference... yet the "expected" says "00:30"
nvmd... it was sscanf being sscanf and corrupting the numbers.
I'm confused.. solve(["23:00","04:22","18:05","06:24"]) == "11:40" The time interval between 1st and 2nd index ("04:22" and "18:05") is more than "11:40".. Then how is 11:40 calculated when it was asked to find the longest time inteval between alarms??
You have "06:24" between those two.
solve(["21:14", "15:34", "14:51", "06:25", "15:30"]),"09:10"
where's the 09:10 coming from then? There's 14:51 between 06:25 and 15:34.Well, you'll say: "the difference between 21:14 and 06:25 is 09:10". Ok good.
Then:
What does this mean? Should they or shouldn't they be in chronological order?
If I have to sort the array because they should be ordered chronologically:
solve(["21:14", "15:34", "14:51", "06:25", "15:30"]),"09:10"
is wrong. Chronological order goes between 00:00 and 23:59 and it all happens within 24h. No cycle. If I don't have to sort the array:solve(["23:00","04:22","18:05","06:24"]),"11:40")
is wrong. 23:00 could be sunday, 04:22 monday, 06:24 tuesday. Cycle.If the task wants me to sort chronologically (no cycle) but still check between the alarm before 00:00 and the alarm after, then this needs to be specified because it's contradicts itself.
INDEED !!! There is a typo in both tests in C# instead of 14:51 there is 14.51.
Fixed
ok now it works :)
INDEED !!! There is a typo in both tests in C# instead of 14:51 there is 14.51.
C# has a typo in both the sample and full tests, 14.51 instead of 14:51.
Exactly you are right. There is absolutely a typo. Shit, I spent 3 hours on this kata.
You can edit the sample tests yourself (until it gets fixed). It has no impact on full tests suite.
Sorry about that, not sure how such an error made it through. You'd think the test would fail.
Fixed now.
Java has a typo in both the sample and full tests,
14.51
instead of14:51
. This will affect how it's parsed, depending on your approach.Fixed.
This comment has been hidden.
wow
Test.assertEquals(solve(["21:14", "15:34", "14:51", "06:25", "15:30"]),"09:10"); The answer is not "09:10" but "08:25"
14:51 - 06:25 + 1 = 8:25
06:25-21:14 = 09:10
As vad-s says.
Worth looking at the first example in the kata description as well.
But then in the example ["23:00", "04:22", "18:05", "06:24"] the solution would be 23:00-04:22-00:01=18:37, not 11:40.
In the test the alarm is triggered more times between 6:25 and 21:14 and what you have to find is the maximum interval between the times it sounds consecutively according to the example, right?
As RoyalST I think the solution for the test is 8:25.
You can create your own tests in the example test section by simply changing what is there. You'll not break anything. When you do this, do you still get 8.25 for the case you have suggested?
I know this comment is old but just in case someone else is having this issue try to think that the maximum interval might also be between the latest alarm and the earliest in terms of "continous" hours. So for example, in the comment of lagnor 23:00 - 4:22 would actually be 5:22 not 18:37.
Translations to C and C++.
Approved. Thanks.
This seems like a redundant and potentially confusing instruction. Just ensure the test suite does not contain any duplicate times.
Will address issues as they arise.
The Description is too ambiguous in explaining the task.
can you suggest some wording?
My initial interpretation was that the times in the input array were in sequential order; for example for the test
["23:00","04:22","18:05","06:24"]
, it seemed like the first alarm went off at23:00
on day 1, the next alarm went off at04:22
on the following day (day 2), the third alarm went off at18:05
on day 2, and so on.It should be made clear that the values in the input are the times that the alarm goes off each day and that they may not necessarily be in chronological order. I suggest adding more detail to a given example, such as for the example given above the alarm will go off 4 times per day at those times listed.
Is it clear now? Confirm.
.
2 years after, this kata is still incomprehensible, description is still unclean this author write tasks for computers not for human its very sad cause only 263 users complete this "awesome" 6kyu task :D
Can you help by giving a description that you think will work?
random test are crazy, how could we test our solutions if the arr have more then 500 elements
lol, that's bullshit:
not doing anything in my solution.
SERIOUSLY? 500 random tests?
This comment has been hidden.
You timing out is an issue??
Refresh. Its only 200 tests.
no, encountering a kata that forbid the use of the classic approach without telling it is an issue.
and stop jerking with downvotes. I can play that game too.
you seriously wanna play that game? x/
edit: Ok, you're just a fucking jerk. Noted.
Whatever
hesitating between an issue and a suggestion...
.. but, but, but .. example 1 makes perfectly clear you are not to consider just one day .. ?!?
Also, what language are you solving this in? I had zero problems with timing out in JavaScript ( but I hate its dedicated tools for dates / times, and didn't use them ).
after some investigations: what you say is absolutely compatible with what I said.
"exmaples" ?
Ah, you fixed that already.