8000 solves dot and cross · jongfranco/hackerrank-python@f664264 · GitHub
[go: up one dir, main page]

Skip to content

Commit f664264

Browse files
solves dot and cross
1 parent 81753d0 commit f664264
< 8000 /pre>

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

numpy-python/dot-cross.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# https://www.hackerrank.com/challenges/np-dot-and-cross/problem
2+
3+
import numpy
4+
numpy.set_printoptions(legacy='1.13')
5+
6+
7+
def zero(size):
8+
return [0 for _ in range(size)]
9+
10+
11+
def get_matrix(size):
12+
matrix = []
13+
for _ in range(size):
14+
matrix.append(list(map(int, input().split())))
15+
return matrix
16+
17+
18+
N = int(input())
19+
matrix1 = numpy.array(get_matrix(N))
20+
matrix2 = numpy.array(get_matrix(N)).transpose()
21+
22+
result = []
23+
for row in range(N):
24+
result.append(zero(N))
25+
for column in range(N):
26+
result[row][column] = int(numpy.dot(matrix1[row], matrix2[column]))
27+
28+
print(numpy.array(result))

0 commit comments

Comments
 (0)
0