7 kyu
Convert Decimal Degrees to Degrees, Minutes, Seconds
263 of 515danieldauk
Loading description...
Fundamentals
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.
Still not fixed for JS:
I've fixed this in Python; I'll port the changes over to JS now.
Resolved.
Missing test for rounding up to nearest degree. For example
0.99999999 -> [1]
.Good catch, thank you. Fixed in Python.
This comment has been hidden.
approved
[261, 13] should equal [261, 12, 60]
How is this possible? At least one random test is wrong every attempt. It expects you not to convert 60'' to 1' in some tests while others work properly
I've published a fork which fixes the bugs in the reference solution, just waiting on approval.
286.3333333333333
degrees[286, 20, 0]
[286, 20, 60]
Fork published with bugfix, see above
[360, 12] should equal [360, 11, 60]
Seems okay for pythonDuplicate issue.
This issue is still present. Hope it gets fixed.
still the same issue
Essentially a duplicate of Months, Weeks, Days, Hours and Minutes.
There are tons of katas of breaking down and building up units.
True. For some reason my brain couldn't wrap around this one. Added it to collections. It was fun
Python translation is broken.
Furthermore, there is this test:
fixed by self-edit and fork approval
Approved as 7kyu
Updated JS to Node 12
Python translation
It's not mentioned in the descriptions that seconds should be rounded.
Fixed.
In the description, you say trailing zeroes should be omitted. But some of the random tests expect trailing zeroes.
Also, I'm wondering what should happen with
0.0001
? Should it be[0, 0, 36]
? That would be a good test to see if people handle the rounding correctly; they might exit early at the first0
and not add the remaining values.Thank you for your insight, it was very helpful.
I've added the test cases:
Also, I've corrected the trailing zeroes problem.
Awesome.
You should try
0.0001388888888888889
which should also round to[0, 0, 1]
, if I've calculated it right. (Becomes 0.5 seconds, rounded up?)Yes, you're right :) We can try
0.0001388888888888889
and0.0001388888888888888
case.Fixed tests are inadequate. My solution has a glaring bug, but it's not caught by the tests.
Random tests are missing altogether.
Johan, thank you for your input. I really appreciate that. I could use some help with tests and your contribution would be appreciated.
Have a look at The conjured Codewars codex and the JS/CoffeeScript Test Reference (including the comments). Both may be incomplete and/or outdated in places.
Also, read tests for kata you've solved.
The basic pattern for random tests is generate test input, create a reference solution (you have that already), and compare output from reference and user solution. There are some caveats, but you'll learn them, possibly the hard way.
Creating fixed tests is an iterative process more often than not - that's what the beta phase is for.
Thanks :)
Test.assertDeepEquals
seems more appropriate thanTest.assertEquals(JSON.stringify())
(for whichTest.assertSimilar()
exists).Thanks!
Description unconditionally asks for
[ degrees, minutes, seconds ]
but tests expect trailing zeroes to be omitted. Maybe put that in the description?Added to the description :)