Ad
  • Custom User Avatar

    Thought I'll add a time complexity analysis since I couldn't find one posted here(or maybe I've missed it):

    If we assume T(n) is the time complexity for solving the problem of size n(n * n matrix), we have the following recursion:

    T(n) = n * (T(n-1) + n^2)

    Basically we have n problems of size n-1 and also n^2 to construct the matrix for each sub problem.

    Expanding the above we have:

    T(n) = n * T(n-1) + n^3

    which gives us

    T(n) = n^n

    What do you guys think?

  • Custom User Avatar

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

  • Custom User Avatar
  • Custom User Avatar

    I did console to track the test #, and also to see your code's output.

    You are failing on the fixed test

    assert.isTrue(determinant(m7)===88)

    const m7 = [
      [2, 4, 5, 3, 1, 2],
      [2, 4, 7, 5, 3, 2],
      [1, 1, 0, 2, 3, 1],
      [1, 3, 9, 0, 3, 2],
      [1, 1, 2, 2, 4, 1],
      [0, 0, 4, 1, 2, 3]
    ]
    

    where your code returns -88 instead of 88.

    I hope that helps!

  • Custom User Avatar

    Ups. I am sorry, but it seems I cannot format it to make it more readable...

  • Custom User Avatar

    Great kata, maybe try to mention the rules of (+ - + -) when having a chain of determinates in the details.

  • Custom User Avatar

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

  • Custom User Avatar

    Pretty good Kata! Thanks to author!

  • Custom User Avatar

    Good job, it always feels amazing to finally reach a goal that you set yourself ages ago

  • Custom User Avatar

    I forgot too, but thankfully I realised after reading the formula a couple times

  • Custom User Avatar

    I'm proud of myself for actually solving the problem instead of depending on libraries to do it for me

  • Custom User Avatar

    Yesterday, I mentioned that there was an issue with random tests, and I couldn't express the error accurately at the time. However I am now sure that it is an Overflow Error due to the large matrixes which causes different results for each primitive type. There needs to be a limitation on this!!!!

  • Custom User Avatar

    The issue was related to the returned double variable from .pow() method Thanks for your kindness

  • Custom User Avatar

    I've marked your last comment as spoiler. I think Math.pow uses doubles, and there might be some truncation errors or something.

  • Custom User Avatar

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

  • Loading more items...