Eye and Identity

Sort by

recency

|

314 Discussions

|

  • + 0 comments
    import numpy
    numpy.set_printoptions(legacy='1.13')
    a,b=list(map(int,input().split()))
    print(numpy.eye(a,b))
    
  • + 0 comments
    import numpy as np 
    np.set_printoptions(legacy = "1.13")
    N, M = map(int, input().split())
    
    arr = np.eye(N,M, k = 0)
    print(arr)
    
  • + 0 comments

    For Python3 Platform

    import numpy
    
    numpy.set_printoptions(legacy='1.13')
    
    N, M = map(int, input().split())
    
    print(numpy.eye(N, M))
    
  • + 0 comments
    import numpy as np
    np.set_printoptions(legacy='1.13')
    print(np.eye(*map(int,input().split())))
    
  • + 0 comments

    Python (of course): My compact solution…

    import numpy as np
    np.set_printoptions(legacy='1.13')
    print(np.eye(*map(int, input().split())))
    

    Annoying that HackerRank uses "MathJax_SVG" to display code in their problem descriptions. I had to use Google Lens to copy the numpy.set_printoptions() code. (Because I didn't want to retype it myself.)