파이썬
-
Practice>Python>Built-Ins>Athlete Sorthackerrank.com 2019. 5. 1. 16:17
hackerrank.com Athlete Sort Problem Link : https://www.hackerrank.com/challenges/python-sort-sort/problem Difficulty : Medium Tip Using itemgetter() as key for sorted() function, is important to solve Solution #!/bin/python3 import math import os import random import re import sys from operator import itemgetter mn = input().split() m = int(mn[0]) n = int(mn[1]) arr = [] for _ in range(m): arr.a..
-
Practice>Python>Regex and Parsing>Matrix Scripthackerrank.com 2019. 4. 29. 21:48
hackerrank.com Matrix Script Problem Link : https://www.hackerrank.com/challenges/matrix-script/problem Difficulty : Hard Tip MUST remove __main__, it lead to fail even correct answer, because there is 'if' Should use regular expression Lookahead and lookbehind Write regular expression, to capture [alphabet][symboles][alphabet] Solution #!/bin/python3 import math import os import random import r..
-
Practice>Python>Built-Ins>ginortShackerrank.com 2019. 4. 29. 13:00
hackerrank.com ginortS Problem Link : https://www.hackerrank.com/challenges/ginorts/problem Difficulty : Medium Tip We should sort as per four groups myfilter() function is written to get four gourps. Sort each groups and concate them Solution s = input() def myfilter(s): lc = [] wc = [] on = [] en = [] for i in range(len(s)): c = s[i] if 'a'
-
Practice>Python>Regex and Parsing>Validating Credit Card Numbershackerrank.com 2019. 4. 26. 12:47
hackerrank.com Validating Credit Card Numbers Problem Link : https://www.hackerrank.com/challenges/validating-credit-card-number/problem Difficulty : Medium Tip It's a bit difficult to solve only using regular expression Especially, 'NOT have or more consecutive repeated digits' More over, in test case 6, '-------' is given as a part of input, it should be filtered, also Check condition 1~4 by u..
-
Practice>Python>Numpy>Linear Algebrahackerrank.com 2019. 4. 25. 12:55
hackerrank.com Linear Algebra Problem Link : https://www.hackerrank.com/challenges/np-linear-algebra/problem Difficulty : Easy Tip Use numpy.linalg.det() np.set_printoptions(legacy='1.13') Checking answer is using old style, please set 1.13 Solution import numpy as np N = int(input()) m = np.array([input().split() for _ in range(N)], float) np.set_printoptions(legacy='1.13') print(np.linalg.det(..
-
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())))