Last active
January 14, 2020 08:33
-
-
Save Himan10/acffaf3037df800de53e6f35d2f189f0 to your computer and use it in GitHub Desktop.
codathon Day2 Matrix Problem ...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # creating n*n matrix | |
| # Partially solved | |
| import numpy as np | |
| from sys import stdin, stdout | |
| def printDiagonalSum(mat, n): | |
| sum_ = 0 | |
| for i in range(0, n): | |
| sum_ += mat[i,i] | |
| return sum_ | |
| if __name__ == "__main__": | |
| n = int(input(" Enter N : ")) | |
| matrix = np.array([input().split() for _ in range(n)], dtype='int16') | |
| q = int(input()) | |
| for _ in range(q): | |
| q_type, a, b, c = stdin.readline().split() | |
| a, b, c = int(a), int(b), int(c) | |
| for i in range(a-1, b): | |
| matrix[i][i] = matrix[i][i] ^ 2 | |
| stdout.write(str(printDiagonalSum(matrix, n))) | |
| stdout.write('\n') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment