Ad
  • Custom User Avatar
  • Default User Avatar
  • Custom User Avatar
    • Description should be language-agnostic

    • Parameter name in initial solution setup should be snake_case

    • Python new test framework should be used

  • Custom User Avatar

    Good kata. I would rate it a 4kuy. But there are some problems. Your solution doesn't make the final decision any easier. For example, I got one of the random tests:

    p1 = '-20x**3-460x**2+15x-11'
    p2 = 'x+23'
    # expected    => ['-20x**2+0x+15', -356]
    # my solution => ['-20x**2+15', -356]
    

    In this case, it seems to me there is no point in 0x, and any online solver sites do as much simplifying as I do. Perhaps we should redo this point?

  • Custom User Avatar

    Use approx equality instead of rounding

  • Custom User Avatar

    This kata is just a copy of "Strange principal" (https://www.codewars.com/kata/55fc061cc4f485a39900001f)

    I literally just copy and pasted my other answer into this one.
    Also, the other one was 7 kyu and this one 6, which I don't fully understand, but isn't really the main issue.

  • Custom User Avatar

    So sorry but realy don't understand the solution. Maybe this problem have a name that I can make research to more understand the solution please ? Or maybe someone have some sources to share ? :)

  • Custom User Avatar

    Your task is to write a function angle_planes(lstPts) that calculates the angle between two planes, each of them being defined by a tuple of three points.

    We actually receive a list of 6 tuples of 3 coordinates (I guess). This is a bad design. We should receive two tuples of 3 tuples each.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Default User Avatar

    Hi,

    The angle between two planes shouldn't be restricted to [0, 90], because it arbitrary assumes the orientations of normal vectors, therefore some methods giving mathematicaly right anwsers fail.
    Such assumption would cause problems in scientific calculations.

  • Custom User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar

    Nice one, but there are some troubles with it yet (all appearing in the random tests):

    first problem (unfortunately, I don't have the inputs for that one):

    ['-333x**2+500x', 23] should equal ['-333x**2+500x+0', 23]
                                                      ^^
    

    => zero values shouldn't appear in the final string


    Secondly, your random generator can create null coefficients.

    If that's not a problem on the principle (even if a bit weird), your solution handles them with the same problem than before:

        p1,p2 = '0x**5+174x**4+50x**3+345x**2-17x+7', 'x+69'
                 ^^^^^
        
        ['174x**3-11956x**2+825309x-56946338', 3929297329]
        should equal
        ['0x**4+174x**3-11956x**2+825309x-56946338', 3929297329]`
          ^^^^^
    

    Finally, you need more fixed tests, especially more edge cases like:

        divide('256x**6+0x**5-368x**4-315x**3+71x**2+11x-8', 'x+0')    # note: p2 is a bit edgy by itself too, here, but...
        == ['256x**5-368x**3-315x**2+71x+11', -8]                      # "generates" a 0 coef in the result
        
        divide('-x**4-355x**3+89x**2-25x-12', 'x+355')
        == ['-x**3+89x-31620', 11225088]
        # generates a zero coef in the result too, but with a!=0 and all coefs in the input are non zero
        # (better edge case than the previous one)
        
        divide('333x**17-86x**16-40x**15+153x**14-163x**13+87x**12+149x**11-157x**10-55x**9+98x**8+259x**7+61x**6+498x**5+387x**4-487x**3+313x**2-1x+3', 'x+0')
        == ['333x**16-86x**15-40x**14+153x**13-163x**12+87x**11+149x**10-157x**9-55x**8+98x**7+259x**6+61x**5+498x**4+387x**3-487x**2+313x-1', 3]
        # this one made fall my implementation because of the constant term of -1 x)
        
        divide('187x**8+368x**7+195x**6+388x**5+384x**4+237x**3-444x**2+x-2', 'x+0')
        == ['187x**7+368x**6+195x**5+388x**4+384x**3+237x**2-444x+1', -2]    # because of the 1 at the end (filter out wrong regexp simplifications)
        
        divide('-121x**7+472x**6-160x**5-50x**4-472x**3+331x**2+5', 'x-1')
        == ['-121x**6+351x**5+191x**4+141x**3-331x**2', 5]        # two last terms to be 0
    
    

    One suggestion, now: why not to have something more general with various degrees for P2?

  • Custom User Avatar

    It is a fun kata but it is still need some fix.
    Please have a look at https://i.imgur.com/hhdKi4v.jpg

    similar to what damjan had addressed before.

  • Custom User Avatar

    I think your random tests are wrong:

    Test Results:
      Basic tests
    ✔ Test Passed
    ✔ Test Passed
    ✔ Test Passed
    ✔ Test Passed
    ✔ Test Passed
    ✔ Test Passed
      More random tests
    STDERR:
    Traceback:
       in 
       in convert0
    TypeError: 'function' object is not subscriptable
    

    "convert0" - not my function;-)?!

  • Default User Avatar

    534 has 8 factors, right? [1,2,3,6,89,178,267,534]
    So hcn(534) should be 24? It also has 8 factors: [1,2,3,4,6,8,12,24]

    But I get the following error for the input 534:

    ✘ 24 should equal 30
    

    Also, the starting 'initial solution' needs to be titled hcn.