4 kyu

Helpers For a 3DGame I: Biggest Triangle in a Sphere

209 of 291raulbc777
Description
Loading description...
Data Structures
Algorithms
Mathematics
Logic
Strings
Geometry
Games
  • Please sign in or sign up to leave a comment.
  • ahmet_popaj Avatar

    Very interesting coding challenge.

  • __eloise__ Avatar

    That diagram is very nice :D

    Looks like a character is missing in the formula? I also added some conditional rendering while I was in the description.

    https://www.codewars.com/kumite/632f35eb91065f005c224595?sel=632f35eb91065f005c224595

  • Mihail_Onuchin Avatar

    I appreciate how clearly and in detail you state conditions of your katas, raulbc777. Good job! Keep it up!

  • depial Avatar
  • FArekkusu Avatar

    The tests sometimes time out in Python due to input lists being too big - there's absolutely NO point in generating 70-80 points per test.

  • FArekkusu Avatar

    Select the biggest triangle that has all its 3 vertices as interior points of the sphere (not even in the sphere contour)

    There should be fixed tests for such cases too.

  • FArekkusu Avatar

    For practical purposes you may consider that if the area of a triangle is lower than 10^(-8), the points are aligned.

    There should be fixed tests for this, as my solution ignores this rule and passes most of the time.

  • cohetillo Avatar

    My code runs out after 61 tests, i don't know how to improve it more!

  • G_kuldeep Avatar

    Python 3 should be enabled.

    PS:great kata sir, your katas made me to learn more about geometry

  • ziereis Avatar

    Appreciate adding support for Python 3. Subtle changes but still necessary. Other than that, nice one.

  • hheimpel Avatar

    Can we do a brute force solution? My code runs fine but it times out after about 48 tests.

  • Miss_Evi Avatar

    Getting 55 out of 60 tests right, but there are always a few tests that just come out flat wrong, and there doesn't seem to be anything noticeably different about those cases.

  • NathanWeinstein Avatar

    I think this is quite hard for 4 kyu, but it was fun.

  • wjadczyszyn Avatar

    When I submit my solution I get error

    (my result from attempt) Result: [165, 33.645207682521445, [[[1, 2, -4], [3, 2, 6], [-1, -4, 0]], [[1, 4, 0], [-1, -2, 4], [-3, -2, -6]]]] Test Passed (and then I get this error) [[1, 2, -4], [3, 2, 6], [-1, -4, 0]] should equal [[[1, 2, -4], [3, 2, 6], [-1, -4, 0]], [[1, 4, 0], [-1, -2, 4], [-3, -2, -6]]]

    am I missing something?

  • HugoHub Avatar

    When I try to submit my solution I get this error: Static Cases Simple Ones # biggest_triang_int' block (3 levels) in ' step' block (2 levels) in '

    Any idea what's wrong with my output? unfortunately I haven't seen such error in CodeWars before.

  • bouchert Avatar

    In your description, the example case with sphere_center = [1, 2, -2] has the wrong answer. It says the result should be [4, 22.62741699796, [[-3,2,4],[2,3,5],[-2,-1,1]]] but it's really [4, 22.627416997969522, [[1, 2, -4], [2, 3, 5], [-2, -1, 1]]] (I am not complaining about the floating point difference, but rather the wrong points.)

    Also, in that same description, you use the variable name sphere_center above, but then just call it center in the call to biggest_triang_int itself. And in the example beneath that, you define the list of points as point_list but then when calling biggest_triang_int, you call it points_list.

    And one final small issue...it unnecessarily complicates things that, if there's only one triangle, you are expected to return a list of three points (i.e., a list of lists), but if there is more than one triangle, you are expected to return a list of triangles (i.e., a list of list of lists). It adds extra mess to the code to not be allowed to simply return a list of triangle(s), whether one or many, and to instead have to special case the return structure for one triangle vs. multiple triangles. A strongly typed language probably wouldn't do it this way, and it feels like poor form even in Python, if this were a real utility function, to have to inspect the inner structure of the return values to determine whether one or multiple triangles were returned.

  • ekailia Avatar

    Thanks for this Kata!

  • daddepledge Avatar

    Another really enjoyable Kata from you. I am not sure how to grade Kata like these. I gave it a 5 (working in python) because the actual python knowledge required for the solution is quite low, but, but, but you need to have decent maths etc. Thanks.

  • stevehopkinson Avatar

    There seems to be an issue in the algorithm generating the random tests - the points provided are all out by 0.333333 or 0.666666, but the tests still expect the points to be integers:

    (Expected: '[[16, -0, 0], [-8, 16, 4], [-10, -9, -13]]', instead got: '[[16.333333333333332, -0.6666666666666679, 0.33333333333333215], [-8.666666666666668, 16.333333333333332, 4.333333333333332], [-10.666666666666668, -9.666666666666668, -13.666666666666668]]').

    Note that none of the expected values were in the pointsList provided, so the only way it was possible to pass the kata was by introducing a fudge factor (n => n < 0 ? Math.ceil(n) : Math.floor(n)) to round the coordinates to ingegers.

  • smile67 Avatar

    Hi Raul, some new honor points for your "science fiction kata" and your leaderboard race;-)! Perhaps next time some spaceships arround this sphere (nice graphics!):-)!