Ad
  • Custom User Avatar
  • Custom User Avatar

    In my opinion, the derivative of const should be [0], not []! But maybe it's a matter of presenting the results.

  • Custom User Avatar

    The link to "poly add" at the end of description is wrong and should point to this correct address (both links point to poly multiply kata)

  • Default User Avatar

    Great fun serie of katas.

    However, as for kata #1 of this serie, it should be clearly stated what should be the return value of :

    poly_subtract ( [1], [1] )
    

    [] or [0]

    And :

    poly_subtract ( [1, 1], [-1, 1] )
    

    [2] or [2, 0]

    In both cases, the first answer seems to make more sense to me, as :

    • there should be a unique way of representing a polynom
    • (len-1) would then be the equivalent of the degree (each monomial would have a degree equal to his index)
  • Default User Avatar

    It's not specified how trailing zeros in the result should be handled. Is trimming zeros considered incorrect?

  • Custom User Avatar

    To be mathematically rigourous, you should update how you handle the zero polynomial or the polynomial with 0 as the constant term. This polynomial should be represented by [0] not [] because the polynomial needs to have a constant term in order to exist.

  • Custom User Avatar

    I think there is an issue with one of the random tests when len(p1) > len(2) > 0. In this case the test is always expecting a wrong result.

    For example, these are the p1, p2 and the wrong expected result:

    Test.assert_equals( poly_subtract([84, 37, 41, 12, 83, 11, 14, 67, 10, 37, 77, 45],[52, 61]), [-20, -85, 41, 12, 83, 11, 14, 67, 10, 37, 77, 45])

    while the correct expected result should be:

    [32, -24, 41, 12, 83, 11, 14, 67, 10, 37, 77, 45]

  • Default User Avatar

    I think it might be more educational to combine these 4 separate katas into one class, something like this:
    http://www.codewars.com/kata/54cf4fc26b85dc27bf000a6b

    Also, you can add polynomial integration kata (indefinite and definite).