본문 바로가기

Programming424

[coderbyte] First Reverse [coderbyte] First Reverse Have the function FirstReverse(str) take the str parameter being passed and return the string in reversed order.Use the Parameter Testing feature in the box below to test your code with different arguments. def FirstReverse(str): # code goes here # Note: don't forget to properly indent in Python return str[::-1] # keep this function call here print FirstReverse(raw_inpu.. 2016. 4. 8.
[checkio] House password [checkio] House password ((?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20}) 위의 코드를 참고하여 작성합니다. import re def checkio(data): rst = re.match('((?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{10,})', data) return bool(rst) re.match(…) 코드에서 매치가 되지 않으면 none이 반환되므로 bool() 함수를 사용하여 반환합니다. Regular Expression ?= positive lookahead 를 사용하여 찾습니다. (?=.*\d) : 숫자가 포함된 것을 확인한다. (?=.*[a-z]) : 소문자가 포함된 것을 확인한다. (?=.*[A-Z]) : 대문.. 2016. 4. 7.
[checkio] Median [checkio] Median def checkio(data): #replace this for solution #return data[0] data = sorted(data) m = len(data) mh = int(m/2) if m % 2 == 1: return data[mh] else: return (data[mh - 1] + data[mh])/2 #These "asserts" using only for self-checking and not necessary for auto-testing if __name__ == '__main__': assert checkio([1, 2, 3, 4, 5]) == 3, "Sorted list" assert checkio([3, 1, 2, 5, 3]) == 3, ".. 2016. 4. 6.
[checkio] Non-unique Elements [checkio] Non-unique Elements 기본코드 #Your optional code here #You can import some modules or create additional functions def checkio(data): #Your code here #It's main function. Don't remove this function #It's used for auto-testing and must return a result for check. #replace this for solution return data #Some hints #You can use list.count(element) method for counting. #Create new list with non-.. 2016. 4. 5.
알고리즘 용어 알고리즘 자료 모음 어떤 수학적인 문제problem를 유한한 단계 안에 해결하기 위한 방법 혹은 절차를 알고리즘algorithm이라고 한다. a finite set of instructions for solving a problem 복잡도 시간 복잡도time complexity 어떤 결정형 문제가 주어졌을 때, 그것을 계산할 수 있는 알고리즘의 시간 복잡도에 따라 그 문제는 P 혹은 NP로 분류될 수 있다. ( P와 NP 둘 다 아닐 수도 있다.) 어떤 문제를 풀기위한 알고리즘의 최소시간 복잡도를 알 수 있을까? 알 수 있는 문제가 바로 P 이고, 알 수 없는 문제가 바로 NP이다. 결정형 문제 결정형 문제decision problem란 그 답이 'yes’와 ‘no’ 둘 중의 하나로 결정되는 문제를 뜻한.. 2016. 4. 4.
사용중인 autohotkey exe 파일입니다. 사용중인 autohotkey exe 파일입니다. 2016. 3. 15.