6 kyu

Pie Chart

440 of 596osofem
Description
Loading description...
JSON
Fundamentals
Geometry
  • Please sign in or sign up to leave a comment.
  • MiranKazaryan Avatar

    This comment has been hidden.

  • destinio Avatar

    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

  • Blind4Basics Avatar
  • Blind4Basics Avatar

    Hi,

    Some troubles, here...:

    with it corresponding angle to two decimal places with it corresponding angle to two decimal places when necessary..

    • its
    • you don't define what you mean by "corresponding angle". I had to go here, to read the comments and hopefully found a hint about what you wanted. You need to actually describe what you want us to do.
    • the requirement about the number of decimal places is never tested, since you only test equality of objects, not strings. => Either remove that from the description, are you have to had the proper tests.

    Cheers

  • donaldsebleung Avatar

    This comment has been hidden.

  • donaldsebleung Avatar

    Simple 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

  • user5036852 Avatar

    Nice kata!

  • myjinxin2015 Avatar

    This comment has been hidden.

    • osofem Avatar

      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!

    • JohanWiltink Avatar

      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).

    • osofem Avatar

      Nice idea @JohanWiltink. Implemented with an error margin of +/- 0.10. Thanks for the wonderful feedback.

      Suggestion marked resolved by osofem 8 years ago
  • ZozoFouchtra Avatar

    This comment has been hidden.

    • osofem Avatar

      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?

    • ZozoFouchtra Avatar

      This comment has been hidden.

      Suggestion marked resolved by ZozoFouchtra 8 years ago
    • JohanWiltink Avatar

      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 like assertEquals (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.