You've successfully subscribed to The Poor Coder | Hackerrank Solutions
Great! Next, complete checkout for full access to The Poor Coder | Hackerrank Solutions
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Hackerrank Shape and Reshape Solution

Hackerrank Shape and Reshape Solution

Beeze Aal
Beeze Aal

Solution in python3

Approach 1.

import numpy
print( numpy.array(input().split(" "),int).reshape(3,3) )

Approach 2.

import numpy
l=input().split()
a=numpy.array(l,int)
a.shape=(3,3)
print(a)

Approach 3.

import numpy
A = numpy.array(input().strip().split(),int)
print(numpy.reshape(A,(3,3)))

Solution in python

Approach 1.

import numpy
print numpy.reshape(numpy.array(map(int,raw_input().split())),(3,3))

Approach 2.

import numpy
print(numpy.array(str(raw_input()).strip().split(), int).reshape(3,3))

Approach 3.

import numpy
ar = numpy.array(map(int,raw_input().split()))
ar.shape = (3,3)
print ar