We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Python
  3. Numpy
  4. Concatenate
  5. Discussions

Concatenate

Problem
Submissions
Leaderboard
Discussions
Editorial

Sort 277 Discussions, By:

votes

Please Login in order to post a comment

  • it21208
    5 years ago+ 21 comments
    import numpy as np
    a, b, c = map(int,input().split())
    arrA = np.array([input().split() for _ in range(a)],int)
    arrB = np.array([input().split() for _ in range(b)],int)
    print(np.concatenate((arrA, arrB), axis = 0))
    
    86|
    Permalink
    View more Comments..
  • orestiss
    6 years ago+ 4 comments

    you don't actually need to concatenate anything to pass this challenge

    26|
    Permalink
    View more Comments..
  • craig_holland
    6 years ago+ 6 comments
    import numpy as np
    N, M, _ = [int(x) for x in raw_input().strip().split()]
    a, b = map(lambda x: np.array([raw_input().strip().split() for i in xrange(int(x))], int), [N, M])
    print np.concatenate((a, b), axis = 0)
    
    7|
    Permalink
    View more Comments..
  • kalesanket99
    4 years ago+ 2 comments
    import numpy as np
    n,m,p=map(int,input().split())
    lis=[]
    for i in range(n+m):
        inp=input().split()
        lis.append(inp)
    print(np.array(lis,int))
    
    6|
    Permalink
  • altafshaikh
    3 years ago+ 0 comments
    import numpy
    
    inp = input()
    inp=[int(x) for x in inp.split(" ")]
    N=inp[0]    #1st matrix row
    M=inp[1]    #2nd matrix row
    P=inp[2]    #col
    
    mat1=[]
    mat2=[]
    for i in range(N):
        row = list(map(int,input().split(" ")))
        
        mat1.append(row)
    
    for i in range(M):
        row = list(map(int,input().split(" ")))
        
        mat2.append(row)
    
    arry1 = numpy.array(mat1)
    arry2 = numpy.array(mat2)
    arry1=numpy.reshape(arry1,(N,P))
    arry2=numpy.reshape(arry2,(M,P))
    print(numpy.concatenate((arry1,arry2),axis=0))
    
    3|
    Permalink
Load more conversations

Need Help?


View editorial
View top submissions
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature