전체 글
-
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..
-
Practice>Python>Sets>Check Strict Supersethackerrank.com 2019. 3. 9. 05:30
hackerrank.comCheck Strict SupersetProblem link : https://www.hackerrank.com/challenges/py-check-strict-superset/problemDifficulty : Easy TipWe can use difference(), however, there is a method to check that it is super setissuperset()Solution A = set(input().split(' ')) def d(): cnt = int(input()) for _ in range(cnt): B = set(input().split(' ')) if A.issuperset(B) is False: return False return T..
-
Practice>Python>Sets>Check Subsethackerrank.com 2019. 3. 9. 05:13
hackerrank.comCheck SubsetProblem link : https://www.hackerrank.com/challenges/py-check-subset/problemDifficulty : EasyTipJust use difference(), it is all you should know to resolve it Solution cnt = int(input()) for _ in range(cnt): input() A = set(input().split(' ')) input() B = set(input().split(' ')) a1 = A.difference(B) if len(a1) > 0: print(False) else: print(True)
-
Practice>Python>Sets>The Captain's Roomhackerrank.com 2019. 3. 8. 13:36
hackerrank.comThe Captain's RoomProblem link : https://www.hackerrank.com/challenges/py-the-captains-room/problemDifficulty : Easy TipProblem description is a bit longPoint is that captain's room number is appeared only onceOther room number is repeatedCreate defatultdict with lamda: 0room number is a key of dict, and +1 when the number is appearedcheck what key is only appeared one timeSolution..
-
Practice>Python>Math>Triangle Questhackerrank.com 2019. 3. 7. 12:58
hackerrank.comTriangle QuestProblem link : https://www.hackerrank.com/challenges/python-quest-1/problemDifficulty : Medium Tip1 -> 1 / 1 -> 122 -> 22/2 -> 11333 -> 333/3 -> 1114444 -> 4444/4 -> 1111This is a first idea10 ** 1 // 9 -> 110 ** 2 // 9 -> 1110 ** 3 // 9 -> 11110 ** 4 // 9 -> 1111This is a second idea Solution for i in range(1, int(input())): print(10**i//9 * i)
-
Practice>Python>Math>Integers Come In All Sizeshackerrank.com 2019. 3. 7. 12:48
hackerrank.comIntegers Come In All SizesProblem link : https://www.hackerrank.com/challenges/python-integers-come-in-all-sizes/problemdifficulty : Easy Tipint(input())a**bThey are all we should know to solve it Solution a = int(input()) b = int(input()) c = int(input()) d = int(input()) print(a**b + c**d)
-
Practice>Python>Debugging>Words Scorehackerrank.com 2019. 3. 7. 07:31
hackerrank.comWords ScoreProblem link : https://www.hackerrank.com/challenges/words-score/problemDifficulty : Medium Tipit seems that problem is a bit complex, however, it's pointing only one thingWe understand the difference between '++' and '+='In C/C++, they are almost same functionality, however, in python, they are differentMost of legacy code is fine, just fix only few characters regarding..