Skip to content

Instantly share code, notes, and snippets.

@Himan10
Last active January 14, 2020 08:33
Show Gist options
  • Select an option

  • Save Himan10/acffaf3037df800de53e6f35d2f189f0 to your computer and use it in GitHub Desktop.

Select an option

Save Himan10/acffaf3037df800de53e6f35d2f189f0 to your computer and use it in GitHub Desktop.
codathon Day2 Matrix Problem ...
# 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