Python
-
Practice>Python>Numpy>Mean, Var, and Stdhackerrank.com 2019. 3. 13. 12:54
hackerrank.comMean, Var, and StdProblem link : https://www.hackerrank.com/challenges/np-mean-var-and-std/problemDifficulty : Easy Tipnp.set_printoptions(legacy='1.13')Still this is requiredPlease understand how to use np.mean(), np.var() and np.std() Solution import numpy as np np.set_printoptions(legacy='1.13') N, M = list(map(int, input().split(' '))) arr = np.array([input().split(' ') for _ i..
-
Practice>Python>Numpy>Min and Maxhackerrank.com 2019. 3. 13. 12:42
hackerrank.comMin and MaxProblem link : https://www.hackerrank.com/challenges/np-min-and-max/problemDifficulty : Easy TipJust understanding how to use numpy.min() numpy.max(), is enough to solve this problem Solution import numpy as np N, M = list(map(int, input().split(' '))) arr = np.array([input().split(' ') for _ in range(N)], int) arr2 = np.min(arr, axis = 1) print(np.max(arr2))
-
Practice>Python>Numpy>Sum and Prodhackerrank.com 2019. 3. 12. 18:57
hackerrank.comSum and ProdProblem link : https://www.hackerrank.com/challenges/np-sum-and-prod/problemDifficulty : Easy TipPlease understand how to use numpy.sum() and numpy.prod()They are all you should know Solution import numpy as np N, M = list(map(int, input().split(' '))) arrA = np.array([input().split(' ') for _ in range(N)], int) arrB = np.sum(arrA, axis=0) #print(arrB) print(np.prod(arr..
-
Practice>Python>Numpy>Floor, Ceil and Rinthackerrank.com 2019. 3. 12. 12:53
hackerrank.comFloor, Ceil and RintProblem link : https://www.hackerrank.com/challenges/floor-ceil-and-rint/problemDifficulty : Easy Tipnumpy.set_printoptions(sign=' ')Please use this, before print any numpy arrayProblem is easy ;) no more tips are needed Solution import numpy Vs = input().split(' ') arr = numpy.array(Vs, float) numpy.set_printoptions(sign=' ') print(numpy.floor(arr)) print(numpy..
-
Practice>Python>Numpy>Array Mathematicshackerrank.com 2019. 3. 12. 12:44
hackerrank.comArray MathematicsProblem link : https://www.hackerrank.com/challenges/np-array-mathematics/problemDifficulty : Easy Tip/ this is division, result return as floating point// this is integer division, result as int Solution import numpy N, M = list(map(int, input().split(' '))) A = numpy.array([input().split(' ') for _ in range(N)], int) B = numpy.array([input().split(' ') for _ in r..
-
Practice>Python>Classes>Classes>Dealing with Complex Numbershackerrank.com 2019. 3. 11. 13:16
hackerrank.comDealing with Complex NumbersProblem link : https://www.hackerrank.com/challenges/class-1-dealing-with-complex-numbers/problemDifficultiy : Medium TipThis problem is to check that you know how to use complex() from cmathwe map each arithmetic operation is each method to complex(), it's all you should do Solution class Complex(complex): def __add__(self, o): return Complex(complex.__..
-
Practice>Python>Numpy>Eye and Identityhackerrank.com 2019. 3. 9. 05:57
hackerrank.comEye and IdentityProblem link : https://www.hackerrank.com/challenges/np-eye-and-identity/problemDifficulty : EasyTipThis is easy :)Even, If you resolve it correctly, but you need thisnumpy.set_printoptions(legacy='1.13')Solution import numpy dims = tuple(map(int, input().split(' '))) mm = numpy.eye(*dims, k = 0) numpy.set_printoptions(legacy='1.13') print(mm)
-
Practice>Python>Numpy>Zeros and Oneshackerrank.com 2019. 3. 9. 05:46
hackerrank.comZeros and OnesProblem link : https://www.hackerrank.com/challenges/np-zeros-and-ones/problemDifficulty : EasyTipDimension is not 3, it is NThe maximum length of dimension is 3dims = tuple(map(int, input().split()))This is a key :)Solution import numpy dims = tuple(map(int, input().split())) a = numpy.zeros(dims, dtype = numpy.int) print(a) b = numpy.ones(dims, dtype = numpy.int) pr..