Week 4: Programming Assignment 1
1
; otherwise, it should print 0
.Input Format:
The first input is an integer r , the number of rows in the matrix.
The second input is an integer c, the number of columns in the matrix.
The next r lines each contain c integers, representing the elements of each row of the matrix.
Output Format:
The output is 1
if a saddle point exists, otherwise 0
.
Example:
Input:
3
3
2 0 3
2 1 4
4 2 6
Output:
1
Reason:
Element 2 in third row and second column is minimum in its row and maximum in its column.
So, it is a saddle point.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 3
3
2 2 3
2 1 4
4 0 6 | 0 | 0 | Passed |
Test Case 2 | 3
3
2 0 3
2 1 4
4 2 6 | 1 | 1 | Passed |
Test Case 3 | 4
4
7 3 5 8
4 2 9 1
2 2 10 11
14 1 7 3 | 1 | 1 | Passed |
Week 4: Programming Assignment 2
Create a Python program that multiplies the transpose of a given matrix by a scalar. The program should prompt the user to input the dimensions of the matrix, the elements of the matrix, and the scalar value. The program should then compute the transpose of the matrix, multiply it by the scalar, and print the resulting matrix.
Input:
The first input is an integer 𝑟 , the number of rows in the matrix.
The second input is an integer 𝑐 , the number of columns in the matrix.
The next 𝑟 lines each contain 𝑐 integers, representing the elements of the matrix.
The final input is an integer 𝑠, representing the scalar value.
Output Format:
The output consists of 𝑐 lines, each containing 𝑟 integers, representing the elements of the resulting matrix after multiplying the transpose of the original matrix by the scalar.
Example:
Input:
2
3
1 2 3
4 5 6
2
Output:
2 8
4 10
6 12
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 2
3
1 2 3
4 5 6
2 | 2 8\n
4 10\n
6 12 | 2 8\n
4 10\n
6 12 | Passed |
Test Case 2 | 3
2
1 2
3 4
5 6
3 | 3 9 15\n
6 12 18 | 3 9 15\n
6 12 18 | Passed |
Test Case 3 | 2
2
-1 0
2 -3
4 | -4 8\n
0 -12 | -4 8\n
0 -12 | Passed |
Week 4: Programming Assignment 3
1
if it is, otherwise print 0
.Input Format:
The first input is an integer r , the number of rows and columns in the matrix.
The next r lines each contain r integers, representing the elements of each row of the matrix.
Output Format:
The output is 1
if a matrix is skew-symmetric, otherwise 0
.
Example:
Input:
3
0 2 -1
-2 0 -4
1 4 0
Output:
1
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 3
0 2 -1
-2 0 -4
1 4 0 | 1 | 1 | Passed |
Test Case 2 | 3
0 2 -1
-2 0 4
1 4 0 | 0 | 0 | Passed |
Test Case 3 | 4
0 2 -3 4
-2 0 5 -6
3 -5 0 7
-4 6 -7 0 | 1 | 1 | Passed |
No comments