Hackerrank Shape and Reshape Solution
Poor Man
- Published
- Updated
- Reading time
- 1 min read
- Length
- 101 words
Solution in python3#
Approach 1.
Python
import numpy
print( numpy.array(input().split(" "),int).reshape(3,3) )Approach 2.
Python
import numpy
l=input().split()
a=numpy.array(l,int)
a.shape=(3,3)
print(a)Approach 3.
Python
import numpy
A = numpy.array(input().strip().split(),int)
print(numpy.reshape(A,(3,3)))Solution in python#
Approach 1.
Python
import numpy
print numpy.reshape(numpy.array(map(int,raw_input().split())),(3,3))Approach 2.
Python
import numpy
print(numpy.array(str(raw_input()).strip().split(), int).reshape(3,3))Approach 3.
Python
import numpy
ar = numpy.array(map(int,raw_input().split()))
ar.shape = (3,3)
print ar