6 kyu
Pie Chart
440 of 596osofem
Loading description...
JSON
Fundamentals
Geometry
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.
This comment has been hidden.
This comment has been hidden.
This was fun. Would have been nice if there had been more explanation about how to calculate the angle. Possibly even the math?
otherwise I enjoyed it
wtf is angle?
? This
xD
oops... ;o
.
Hi,
Some troubles, here...:
its
Cheers
This comment has been hidden.
Actually
random_int(min, max)
is also an in-built PHP function that gives you a random number between the min and max number. http://php.net/manual/en/function.random-int.phpThanks for the link :D Sorry, I didn't realise that there were so many different random integer generators in PHP (
rand
,mt_rand
andrandom_int
), my bad :pSimple but fun Kata, keep up the good work :D I didn't even realise that PHP had JSON-specific built-in functions until now :p
Nice kata!
This comment has been hidden.
Hmm, that's weird! Just hurriedly checked through submitted solutions and saw @ZozoFouchtra actually used the format
x * 360 / sum
and passed. Will do something about that, thanks for the feedback!I also use it, and passed. But I had to submit multiple times. It happens about every other time you run the 200 random tests.
And that's not weird, actually, it's to be expected something like this happens. The only fully correct way to deal with floating point values is allow a margin for error. In this case you might get away with warning the user and reducing the number of random tests to 100, so one has a better shot at slipping through the cracks. That's the lazy solution, but it'd work. You already have a custom test function; it wouldn't be too much work to change that to allow some floating point error (about +-.015 absolute in this case).
Nice idea @JohanWiltink. Implemented with an error margin of
+/- 0.10
. Thanks for the wonderful feedback.This comment has been hidden.
The problem I have with CodeWars is lack of documentation. I never knew
assertDeepEquals
existed till you mentioned it. JavaScript/CoffeeScript Test documentation is even alittle better, some languages are just non existent. Or is it just me?This comment has been hidden.
And, looking in tests of other people, there seems to be an
assertApproxEquals
as well now. Unfortunately, I forget where I saw that, and it is not documented. But I just checked, and I seem to have the spelling correct, and it should work mostly likeassertEquals
(though I have no idea how much error it allows, or how to set that).Mind you, when using that, one should not round results to any precision.