The cofactor matrix is the transpose of the [Adjugate Matrix](https://en.wikipedia.org/wiki/Adjugate_matrix). The elements of this matrix are the [cofactors](https://en.wikipedia.org/wiki/Minor_%28linear_algebra%29) of the original matrix. The cofactor [![enter image description here][1]][1] (i.e. the element of the cofactor matrix at row i and column j) is the determinant of the submatrix formed by deleting the ith row and jth column from the original matrix, multiplied by (-1)^(i+j). For example, for the matrix [![enter image description here][2]][2] The element of the cofactor matrix at row 1 and column 2 is: [![enter image description here][3]][3] You can find info on what the determinant of a matrix is and how to calculate them [here](https://en.wikipedia.org/wiki/Determinant). ###Challenge Your goal is to output the cofactor matrix of an input matrix. **Note**: Built-ins that evaluate cofactor matrices, or adjugate matrices, or determinants or anything similar are **allowed**. ###Input The matrix may be inputed as a command line argument, as a function parameter, in `STDIN` or in any way that is most appropriate for the language you use. The matrix will be formatted as a list of lists, each sublist corresponding to one row, which contains factors ordered from left to right. Rows are ordered from top to bottom in the list. For example, the matrix a b c d will be represented by `[[a,b],[c,d]]`. You may replace the square brackets and commas with something else if it fits your language and is sensible (e.g. `((a;b);(c;d))`) Matrices will **only contain integers (which can be negative)**. Matrices will **always be square** (i.e. same number of rows and columns). You may assume that the input will always be correct (i.e. no formatting problem, nothing other than integers, no empty matrix). ###Output The resulting cofactor matrix may be outputed to `STDOUT`, returned from a function, written to a file, or anything similar that naturally suits the language you use. The cofactor matrix must be formatted in the exact same way the input matrices are given, e.g. `[[d,-c],[-b,a]]`. ###Test cases - Input: `[[1]]` Output: `[[1]]` - Input: `[[1,2],[3,4]]` Output: `[[4,-3],[-2,1]]` - Input: `[[-3,2,-5],[-1,0,-2],[3,-4,1]]` Output: `[[-8,18,-4],[-5,12,-1],[4,-6,2]]` - Input: `[[3,-2,7,5,0],[1,-1,42,12,-10],[7,7,7,7,7],[1,2,3,4,5],[-3,14,-1,5,-9]]` Output: [[9044,-13580,-9709,23982,-9737],[-1981,1330,3689,-3444,406],[14727,7113,2715,-9792,414],[-28448,-2674,-707,16989,14840],[-2149,2569,-2380,5649,-3689]] ###Scoring This is [tag:code-golf] so the shortest answer in bytes wins. [1]: https://i.sstatic.net/3QQ4e.png [2]: https://i.sstatic.net/BDLIM.png [3]: https://i.sstatic.net/t40WC.png