Ad
  • Custom User Avatar

    You should explain what n is in the description. Also, the examples should be language-agnostic, if feasible.

  • Custom User Avatar

    Yes, thanks. Minimal explanations are often more effective but im kinda nerd🤓

  • Custom User Avatar

    Hi Homogen,

    You have a very nice idea here, but I think the description can be simplified to make it clearer.

    Something like this:

    The usual definition of matrix multiplication does not allow for division of matrices to be defined. In this kata we redefine matrix multiplication so that division of matrices can be unambiguously defined.
    Given two square matrices of size n called A and B, define their product C by

    c_{ij} = (a_{i0}*b_{0j}, a_{i1}*b_{1j}, ..., a_{ik}*b_{kj})
    

    Example:

          A        B           		C
        |1 2| × |1 4| 	= 	|(1,10) (4,4)|
        |3 1|   |5 2|   		|(3,5) (12,2)|
    

    The order of the product matters:

          B        A           		 C
        |1 4| × |1 2| 	= 	|(1,12) (2,4)|
        |5 2|   |3 1|   		|(5,2) (10,2)|
    

    Then, given the product matrix C and one of the factors, we can recover the other factor, as long as we know whether the factor that we are given is the left one A or the right one B.

    Task:

    Implement a function matrix_div with 3 parameters:

    result represents the product matrix C

    factor represents one of the two factors (either A or B).

    position is either 0 or 1: 0 means that factor is the right factor while 1 means it's the left one.

    Return the other factor.

    Examples:

    matrix_div([[[1,10],[4,4]],[[3,5],[12,2]]], [[1,4],[5,2]], 0) 
    should return [[1,2], [3,1]].
    
    matrix_div([[[1,10],[4,4]],[[3,5],[12,2]]], [[1,4],[5,2]], 1) 
    should return [[1,4], [2,1]].
    

    Note: 1<=n<=30. All matrix elements lie between 1 and 100 inclusive. Division of elements is integer division.

  • Custom User Avatar

    haha thanks, it was very concise and clear

  • Custom User Avatar

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

  • Custom User Avatar

    I apologize for my insufficient knowledge of the Codewars documentation, but I don’t understand how to take advantage of this mistake, and much less how to fix it

  • Custom User Avatar

    Python: Random tests are vulnerable to input modification

  • Custom User Avatar

    Thanks i am changed a few things

    Write if you still have something to add

  • Custom User Avatar

    I think that properly used KaTeX and math markup could make description a bit clearer. The monospaced block looks weird.

  • Custom User Avatar

    ;-)

  • Custom User Avatar

    I am so sorry mr Voile but i am still still waiting and i hope im not distracting you from something very important

  • Custom User Avatar

    Sorry but i am still waiting

  • Custom User Avatar

    Done, it turns out that I wrote the very first paragraph in vain

  • Custom User Avatar

    each element of the resulting matrix obtained by multiplication will be represented as numbers that must be the sum

    The sum of what? How should we interpret the numbers in

    |(1,10) (4,4)|
    |(3,5) (12,2)|
    

    ? It takes a lot of squinting to decipher how these values come up (they're the individual terms of the matrix multiplication).

    Overall it is now barely decipherable, but still very unclear.

  • Custom User Avatar
  • Loading more items...