7 kyu
Volume of a cup
664 of 1,214tdowek1
Loading description...
Geometry
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.
JS:
mocha + chai should be used
Description should be language-agnostic
Python: tests should not use strict equality for floats.
And result should not be rounded.
R translation. Please review and approve https://www.codewars.com/kumite/634861f5adea5200238629ba?sel=634861f5adea5200238629ba
Ruby 3.0 should be enabled, see this to learn how to do it
Enabled in this fork
Python 3 should be enabled.
Oooh, I love this site. I'd been scratching my head as to why my script didn't work for the first and last test in Ruby. Just discovered something I didn't know about the results of small integers divided by larger integers in ruby. Seems to be a couple of ways to handle it. Also applies to Python 2 apparently.
This comment has been hidden.
The function should return a number rather than a string.
This comment has been hidden.
Figured out it was about how integers are handled. Not sure if the tests were supposed to teach that in particular but definitely learned something. Nice Kata sensei :)
This comment has been hidden.
You are probably using python 3. Codewars uses python 2. The significant difference in this case being that
/
is integer division in python2 unlike python3. Convert the values into floats before using division.This comment has been hidden.
You're returning a String, while you're expected to return a Number.
Also, toFixed() gives bad behaviour sometimes; best practice to round x to the y decimal digit is to use
Math.round(x*Math.power(10,y))/Math.power(10,y)
.In this case
Math.round(x*100)/100
should cut it.Ruby and Python translation submitted; after you approve them, provided you find them good, I would suggest to specify that the cup is a truncated cone (I wondered for a while if if could have been a truncated cut or something even more exoteric, even if now the kyu ranking would probably be considered a big give-away of its difficulty level).
Dusted off my trig, solved, ranked, upvoted, and translated into CoffeeScript for your approval