Python
-
Practice>Python>Numpy>Polynomialshackerrank.com 2019. 4. 25. 12:48
hackerrank.com Polynomials Problem Link : https://www.hackerrank.com/challenges/np-polynomials/problem Difficulty : Easy Tip polyval() should be used to solve problem Solution import numpy as np print(np.polyval(list(map(float,input().split())), float(input())))
-
Practice>Data Structures>Arrays>Arrays - DShackerrank.com 2019. 4. 25. 08:34
hackerrank.com Arrays - DS Problem Link : https://www.hackerrank.com/challenges/arrays-ds/problem Difficulty : Easy Tip Very common problem :-) reversing array There few ways to solve Implementing reversing array by using reverse index -1 [a[(i+1)*-1] for i in range(len(a))] Simply call reversed(a) More simpler version is 'return a[::-1]' Solution #!/bin/python3 import math import os import rand..
-
Practice>Python>Closures and Decorators>Decorators 2 - Name Directoryhackerrank.com 2019. 4. 23. 12:41
hackerrank.com Decorators 2 - Name Directory Problem Link : https://www.hackerrank.com/challenges/decorators-2-name-directory/problem Difficulty : Easy Tip Though, we could resolve the problem, still I'm a bit confused regarding decorator, anyway Please convert age to int from string, it seems that test cases are updated recently Sort people by using itemgetter(2) as age order Solution import op..
-
Practice>Python>Closures and Decorators>Standardize Mobile Number Using Decoratorshackerrank.com 2019. 4. 23. 07:58
hackerrank.com Standardize Mobile Number Using Decorators Problem Link : https://www.hackerrank.com/challenges/standardize-mobile-number-using-decorators/problem Difficulty : Easy Tip Use reverse index to substring aaaaa and bbbb from +91 aaaaa aaaaa Like aaaaa is s[-10:-5] and s[-5:0] Should uderstand how decorator work in python, it is a bit difficult Please understand how to use decorator, th..
-
Practice>Python>Regex and Parsing>Detect Floating Point Numberhackerrank.com 2019. 4. 22. 21:48
hackerrank.com Detect Floating Point Number Problem Link : https://www.hackerrank.com/challenges/introduction-to-regex/problem Difficulty : Easy Tip We can solve in two ways One is to solve by using regular expression, by detecting -, + and . The other is a way to utilize int(), float(), let's try this way We can create int() or float() from string If the given string is not proper, it will rais..
-
Practice>Python>XML>XML2 - Find the Maximum Depthhackerrank.com 2019. 4. 19. 12:52
hackerrank.com XML2 - Find the Maximum Depth Problem Link : https://www.hackerrank.com/challenges/xml2-find-the-maximum-depth/problem Difficulty : Easy Tip As it should be resolved by calling recursion fuction, it is a bit tricky Check it have child, or not No child, maxdepth should be updated, if maxdepth is smaller than level If child, we should call depth() with child Solution import xml.etre..
-
Practice>Python>XML>XML 1 - Find the Scorehackerrank.com 2019. 4. 17. 13:09
hackerrank.com XML 1 - Find the Score Problem Link : https://www.hackerrank.com/challenges/xml-1-find-the-score/problem Difficulty : Easy Tip Problem can be solved in two ways We iterate all of child node We can visit child node as recursive function We will follow this way As input is XML, there is only one root element. Need one loop to visit every child nodes, and get the number attributes of..
-
Practice>Python>Regex and Parsing>Validating UIDhackerrank.com 2019. 4. 16. 13:20
hackerrank.com Validating UID Problem Link : https://www.hackerrank.com/challenges/validating-uid/problem Difficulty : Easy Tip If we sort a given string, we can wrtie regular expression more easier Here is how to sort string l = [s[i] for i in range(len(s))] l.sort() l = ''.join(l) Write regular expressoin for each conditions Find 2 uppercases from sorted string Find 3 number from sorted string..