6 kyu
The latest clock
1,450 of 2,904nirgn
Loading description...
Date Time
Fundamentals
Algorithms
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.
Bruh, The C Translation is imposible, because of the string that waits for 7 chars. (In feedback only 5 chars (12:45), Making C Vatiant imposible, i mean for me...)
After deleting one question mark from given in predone tests, it works! But still crashes because i cannot change the random tests that come afterwards... ):
Your code has a small bug.
The comment in the initial setup says:
// The result should be [...] correctly null-terminated.
and your code is not doing this.Ok, now it is working on test without modifing it, but still randoms just do not go, it writes like "23:08" wrong, needed "23:08".
This does not sound right. When I try to run your solution, I get this message:
But i mean u see the point, i will try to redesign the code, but if the error occurs again, then this task is doomed for me...
This Kata should be more then 6. At least 5. It was fun and challenging before I passed all the tests.
To be honest, this task deserves more than 6 kata. Excellent work!
that was very interesting, thanks!
Very good and funny Kata! Thanks to author!!!
C Translation (author inactive).
Approved by someone
Help me! My code passes, but I still this messages. In my conde, I don´t try to import latest_clock from solution
Traceback (most recent call last): File "/workspace/default/tests.py", line 5, in from solution import latest_clock ImportError: cannot import name 'latest_clock' from 'solution' (/workspace/default/solution.py)
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/workspace/default/tests.py", line 7, in from solution import late_clock as latest_clock ImportError: cannot import name 'late_clock' from 'solution' (/workspace/default/solution.py)
Make sure your function is called
latest_clock
and notlate_clock
or something else. You may also want to read this article to know how Codewars kata work.my brain is broken now thx :)
C# version kumited
Merged
Ruby version kumited
Merged
10 minutes in Python, with 2 iterations
nice
crazy. 30 lines of code later, and my brain is numb.
Help me please. The code passes checks and the last message:
Traceback (most recent call last): File "/workspace/default/.venv/lib/python3.11/site-packages/codewars_test/test_framework.py", line 112, in wrapper func() File "/workspace/default/tests.py", line 62, in random_tests test_it(result) File "/workspace/default/tests.py", line 41, in test_it test.assert_equals(latest_clock(*ds), expected, msg) ^^^^^^^^^^^^^^^^^ File "/workspace/default/solution.py", line 82, in latest_clock time.remove(max(last_time)) ValueError: list.remove(x): x not in list
Your code crashes for input like
latest_clock(1,2,3,1)
. You need to find a bug in your solution which causes the crash and fix it.I will try to fix tests so they give better messages.
Thanks, i will try it
This 6 kyu does require quite the brian power, took me roughly 1 1/2 hours.
This one was a doozy - had me working on it all afternoon before I came up with something that worked
I wrote a program that gives the latest time, but in the tests the correct answer is NOT THE LATE TIME. Can i fix that? Some exemples: latest_clock(1, 1, 9, 0) should return "19:10": '19:19' should equal '19:10' latest_clock(1, 3, 1, 3) should return "13:31": '13:33' should equal '13:31' latest_clock(1, 7, 3, 1) should return "17:31": '17:37' should equal '17:31' latest_clock(9, 0, 2, 3) should return "23:09": '23:39' should equal '23:09' latest_clock(1, 5, 7, 1) should return "17:51": '17:57' should equal '17:51' latest_clock(6, 1, 0, 5) should return "16:50": '16:56' should equal '16:50'
Time 19:19 cannot be created from digits 1, 1, 9, and 0. You did not use 0, and you used 9 twice but theres only one 9 in the input.
Your code should use all those 4 digits, it's not doing that, it's using some more than once and not using others.
understood thanks)
Are 4 digits supposed to be the ones from test cases only or all possible digits? If so 'Every inputs have valid answer' might not agree with the input 5,6,7,8 .
These can be any possible combination of four digits which is guaranteed to have a valid answer. it can be
1 1 1 1
, it can be1 2 3 4
, it can be5 6 9 0
, but it will never be5 6 7 8
.I am sorry but, the description is just ambigious or am I just being difficult? It said "every input". Not 'every possible input that can yield valid answer'. So I suppose, 5,6,7,8 is part of every input. If the statement is "every possible" input then sure, your statement is correct.
No it's probably me who's being difficult, but I have no good idea how to express it in a clearer way. Maybe like this:
Tests pass to your function only inputs, which have a valid answer.
Or: when your function is called, it is guaranteed to be called only with digits which have a valid solution.
Or: Your function will not be called with digits which cannot be used to build a valid 24-h time.
Or: Only inputs which have valid answers are tested.
Does any of these sound better?
So you can guarentee that random tests will not provide any inputs that are not possible to construct a valid time. This sounds much better than "Every input has a valid answer.". Thanks.
Note that "input" in the description does not mean just any combination of four digits, it means a combination of four digits that is guaranteed to make up a valid time, or it would not be inputted to the function.
Gotcha. Thanks.
In the example section, we have
digits: 9, 1, 2, 5 => result: "21:59"
why can't it be
digits: 9, 1, 2, 5 => result: "19:25"
?Because 21:59 is later in the day than 19:25.
I added a clarification to the description.
This kata... she's a beauty. My approach/strategy was good and perfectly executed. Sometimes you get off on the wrong foot and your code ends up a lot longer than it needs to be. This wasn't one of those times. Went through it like a hot knife through butter. Very enjoyable kata.
My brain is getting pain.....
This was deceptively more complex than I thought it would be, based on the simple instructions. Fun kata :)
JS translation
Approved, thanks!
Traceback (most recent call last): File "/workspace/default/tests.py", line 1, in from solution import latest_clock ImportError: cannot import name 'latest_clock' from 'solution' (/workspace/default/solution.py
Has anyone else received this error when attempting this kata? My code passes all the tests and seems fine but when I attempt it, there is the issue of attempting to import 'latest_clock' that I don't see.
Is the function name latest_clock or did you change it?
Your function is called
late_clock
, but I recently changed it to belatest_clock
but your code still remembers the old version. Change your function tolatest_clock
and it should be fine.You can also back up your solution, click RESET, and then you will get the most recent state. Then paste your solution back, rename the funciton to
latest_clock
, and this should help.Yes, that allowed the attempt. Now just have to update my code. Thank you!
I have added backwards compatibility for the old python solution name on the very off chance this happens again.
CoffeeScript translation
Thanks!
late_clock(9, 1, 2, 5) should return "21:59" '19:25' should equal '21:59'
19:25 is still a valid answer, but for some reason only 21:59 is taken as true. Would be great if other valid answers could also be detected, or the criterion be disclosed in the description. Fun kata nonetheless!
Isn't it supposed to be the "latest" time? Because 21:59 is later than 19:25, the correct answer is 21:59, no?
Description says "and returns the latest time of day that can be built" , is this not clear enough?
Scala translation
Identical testing scheme to python.
Thanks!
Haskell translation
Approved
Edge case tests like [1, 2, 8, 9] would be nice to have.
I don't think [1,2,8,9] is a vaild input. What time should it output?
19:28
? If[1,2,8,9]
is not a valid input, can you specify what is expected more clearly in the description?My mistake,
[1,2,8,9]
is a valid input. I suppose I need a coffee (: I'll add it now to the example tests.And I added random tests, 1000 iterations, this should cover almost all the cases (statistically speaking).
Done Thank you!
No random tests given =(
Also it would be great to have at least one in example test cases.
Thanks I'll add random tests and couple of example test cases.
Done (: Thank you!