전체 글
-
Practice>Python>Regex and Parsing>Re.findall() & Re.finditer()hackerrank.com 2019. 4. 3. 12:46
hackerrank.com Re.findall() & Re.finditer() Problem Link : https://www.hackerrank.com/challenges/re-findall-re-finditer/problem Difficulty : Easy, this is not easy, it should be Medium at lest Tip Problem is not easy, and quite tricky We are going to approach a bit different, unlike discussion in the problem. Cs is consonants Vs is vowels Pattern is like [Cs][Vs][Vs]+[Cs] Find this pattern first..
-
Practice>Python>Regex and Parsing>Group(), Groups() & Groupdict()hackerrank.com 2019. 3. 29. 13:09
hackerrank.com Group(), Groups() & Groupdict() Problem Link : https://www.hackerrank.com/challenges/re-group-groups/problem Difficulty : Easy Tip a-zA-Z0-9 this to capture both alphabet and number Solution import re m = re.search(r'([a-zA-Z0-9])\1+', input().strip()) print(m.groups()[0] if m else -1)
-
Practice>Python>Regex and Parsing>Re.split()hackerrank.com 2019. 3. 29. 12:53
hackerrank.com Re.split() Problem Link : https://www.hackerrank.com/challenges/re-split/problem Difficulty : Easy Tip Regular expression is a key for handling string [,.]+ characters inside '[]' they can be repeated from 0 to mutiple times Solution regex_pattern = r"[,.]+"# Do not delete 'r'. import re print("\n".join(re.split(regex_pattern, input())))
-
Practice>Python>Numpy>Concatenatehackerrank.com 2019. 3. 28. 12:30
hackerrank.com Concatenate Problem Link : https://www.hackerrank.com/challenges/np-concatenate/problem Difficulty : Easy Tip Create input for creating numpy array like below a1 = [input().split() for _ in range(N)] so far a1 is string, need to convert it to int arr1 = numpy.array(a1, int) Concatenate arr1 and arr2 :) Solution import numpy as np N, M, P = list(map(int, input().split())) a1 = [inp..
-
Practice>Python>Built-Ins>Any or Allhackerrank.com 2019. 3. 27. 13:04
hackerrank.comAny or AllProblem Link : https://www.hackerrank.com/challenges/any-or-all/problemDifficulty : Easy Tiphow to check the number is palindromicPlease use ::-1, it make reverse arraypalindromic number means that original and reverse are samev == v[::-1] 0 for v in N1) Solution input() N2 = input().split(' ') N1 = list(map(int, N2)) r1 = all(v > 0 for v in N1) r2 = any(v == v[::-1] for ..
-
Practice>Python>Numpy>Transpose and Flattenhackerrank.com 2019. 3. 26. 12:56
hackerrank.comTranspose and FlattenProblem Link : https://www.hackerrank.com/challenges/np-transpose-and-flatten/problemDifficulty : Easy TipDon't miss list() when you use map(int, input().split())list(map(int, input.split()))use transpose() and flatten() as description Solution import numpy N, M = list(map(int, input().split(' '))) values = [] for _ in range(N): values.append(list(map(int, inpu..
-
Practice>Python>Numpy>Shape and Reshapehackerrank.com 2019. 3. 26. 12:45
hackerrank.comShape and ReshapeProblem link : https://www.hackerrank.com/challenges/np-shape-reshape/problemDifficulty : Easy TipMost of thing to resolve problem, is described in descriptionJust add 'int' when you create numpy arrary, like numbpy.array(arr, int)It is to covert string to int Solution import numpy arr = input().split(' ') arr = numpy.array(arr, int) print(numpy.reshape(arr,(3,3)))
-
Practice>Python>Numpy>Arrayshackerrank.com 2019. 3. 26. 12:38
hackerrank.comArraysProblem link : https://www.hackerrank.com/challenges/np-arrays/problemDifficulty : Easy Tipdouble colon :: is keyyou guys know regarding single colon : It's time to understand the usage of ::key is [::-1] to reverse numpy array Solution import numpy def arrays(arr): return numpy.array(arr, float)[::-1] arr = input().strip().split(' ') result = arrays(arr) print(result)