In this Inner and Outer problem, You are given two arrays: A and B. Your task is to compute their inner and outer product.

HackerRank Inner and Outer solution in python


Problem solution in Python 2 programming.

import numpy
m=numpy.array(map(int,raw_input().split()))
n=numpy.array(map(int,raw_input().split()))
print numpy.inner(m,n)
print numpy.outer(m,n)


Problem solution in Python 3 programming.

import numpy as np
A = np.array(input().split(), int)
B = np.array(input().split(), int)
print(np.inner(A,B), np.outer(A,B), sep='\n')


Problem solution in pypy programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import numpy as np

A = np.array([int(i) for i in raw_input().split()])
B = np.array([int(i) for i in raw_input().split()])

print np.inner(A, B)
print np.outer(A, B)


Problem solution in pypy3 programming.

# Enter your code here. Read input from STDIN. Print output to STDOUT
import numpy as np
a = [int(i) for i in input().split()]
b = [int(i) for i in input().split()]
print(np.inner(a,b))
print(np.outer(a,b))