Registry Synced

Jan 2026 - Python - Week 9 - PPA 14

549 words
3 min read

PPA 14

Course: Jan 2026 - Python
PPA 14
Due Dec 31, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
- out of100
Score
Public Tests
0/0 Passed
Private Tests
0/0 Passed

If you have grasped the essence of recursion, then you would see the simplicity of the whole idea when you solve this problem. All those who have done Maths-2, or are doing Maths-2, should be able to appreciate this problem. If you are yet to do Maths-2, you can still try to attempt this problem. But we request learners not to be intimidated by the heavy use of notation. Feel free to skip if this problem if it is perceived to be too hard.

Any square matrix MM has a number associated with it called its determinant. The determinant of a 2×22 \times 2 matrix is defined as follows:
det([abcd])=adbc\text{det} \left( \begin{bmatrix} a & b\\ c & d\end{bmatrix} \right) = ad - bc
For any n×nn \times n square matrix MM, its determinant is defined recursively as follows:
det(M)=j=0n1(1)jM[0][j]Mj\text{det}(M) = \sum_{j = 0}^{n - 1} (-1) ^{j} \cdot M[0][j] \cdot M_{j}
Here, MjM_{j} is the determinant of the matrix obtained by removing the 0th0^{th} row and the jthj^{th} column of MM and 0j<n0 \leq j < n. Here, we have used zero-based indexing.
For example, for a 3×33 \times 3 matrix, we have:
det([abcdefghi])= (1)1+1adet([efhi])+(1)1+2bdet([dfgi])+(1)1+3cdet([degh])\begin{aligned} \text{det} \left( \begin{bmatrix} a & b & c\\ d & e & f\\ g & h & i \end{bmatrix}\right) =\ &(-1)^{1 + 1} \cdot a \cdot \text{det} \left( \begin{bmatrix} e & f\\ h & i \end{bmatrix} \right) +\\ &(-1)^{1 + 2} \cdot b \cdot \text{det} \left( \begin{bmatrix} d & f\\ g & i \end{bmatrix} \right) +\\ &(-1)^{1 + 3} \cdot c \cdot \text{det} \left( \begin{bmatrix} d & e\\ g & h \end{bmatrix} \right) \end{aligned}
Write a recursive function named det that accepts a square matrix as argument and returns its determinant. In the process of writing this function, it would be useful to look into GrPA-3 of week-7. A good approach would be to write two functions: det and minor_matrix.

You do not have to accept input from the user or print the output to the console. You just have to write the function definition.

Public Tests ( 0/0 )

Case 1

Input:
text
public
[1, 2, 3], [-1, 2, 4], [0, 1, 3](/viewer?path=1, 2, 3], [-1, 2, 4], [0, 1, 3)
Expected Output:
text
5

Case 2

Input:
text
public
[1, 2, 3], [4, 5, 6], [7, 8, 9](/viewer?path=1, 2, 3], [4, 5, 6], [7, 8, 9)
Expected Output:
text
0

🔒 Private Tests ( 0/0 )

This test case group is locked and will be revealed after the deadline.


💻 IITM Official Solution

Solution code is currently locked and will be available after the deadline.

💻 My Submitted Code

python
def det(M):
    """
    A recursive function to compute the determinant of M.

    Parameters:
        M: list of lists
    Return:
        result: integer
    """

Document Outline
Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.