Shape and Reshape

Sort by

recency

|

384 Discussions

|

  • + 0 comments

    My compact solution…

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

    My solution shows another way to use reshape. The problem statement ony discussed reshaping by setting a value in the shape property of an array object or by calling the np.reshape() function from the NumPy module. However, it is available as a method of array objects, too. Using that method, I was able to create the array and reshape it all in one line, using a fluent style of coding.

  • + 0 comments
    import numpy
    array= numpy.array(list(map(int, input().split())))
    print(numpy.reshape(array, (3,3)))
    
  • + 0 comments

    import numpy as np

    user_list = list(map(int,input().split()))

    print(np.reshape(user_list,(3,3)))

  • + 0 comments

    Here is HackerRank Shape and Reshape in Python solution - https://programmingoneonone.com/hackerran-shape-and-reshape-problem-solution-in-python.html

  • + 0 comments
    A= numpy.reshape([list(map(int,input().split()))],(3,3))