Hackerrank Shape and Reshape Solution
1 min read

Hackerrank Shape and Reshape Solution

Hackerrank Shape and Reshape Solution

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

Enjoying these posts? Subscribe for more


Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

That's okay. But without advertising-income, we can't keep making this site awesome.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add thepoorcoder.com to your ad blocking whitelist or disable your adblocking software.

×