일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- 비둘기과
- 딥러닝 공부
- 비둘기목
- 오리과
- Python
- AI역량평가
- IBK기업은행 인턴
- ADsP
- python3
- 계수정렬
- 맑은소리 스피치학원
- 가마우지과
- keras
- 딥러닝공부
- 생일문제
- 솔딱새과
- django
- 한국의새
- 백로과
- 한국의 새
- AI전략게임
- 기러기목
- 참새과
- 딱다구리과
- Birthday paradox
- 참새목
- structured_array
- 흰날개해오라기
- SimpleCraft
- 직박구리과
- Today
- Total
목록프로그래밍 (91)
진박사의 일상
import time d = [0] * 40 def fibo(x): if x == 1 or x == 2: return 1 else: return fibo(x-1) + fibo(x-2) def fibo_dynamic1(x): #top-down if x == 1 or x == 2: return 1 if d[x] != 0: return d[x] d[x] = fibo_dynamic1(x-1) + fibo_dynamic1(x-2) return d[x] d = [0] * 40 def fibo_dynamic2(x): #bottom-up d[0] = 1 d[1] = 1 for i in range(3, x): d[i] = d[i-1] + d[i-2] return d[x] start = time.time() print(f..
계수 정렬이 사용 가능할 때 계수 정렬과 기본 정렬을 비교해보고 싶어서 테스트 테스트한 문제는 성적 정렬 import time import random str_pool = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" counting_score = 0 default_score = 0 for i in range(7): n = 10**i #계수 정렬 scores = [""] * 100 answer = "" random.seed(0) start = time.time() for _ in range(n): name, score = random.choice(str_pool), random.randint(1,100) scores[score-1] += name + "..
문제 : 문자열을 N개 단위로 잘라 반복된 시퀀스와 그 반복 횟수로 나타내 줄이는 압축을 할 때 최대로 압축한 문자열의 길이는? def solution(s): answer = 0 if len(s) == 1: return 1 half_l = len(s)//2 # 8 -> 4 for size in range(1,half_l+1): # 1-4 #split size word = "" count = 0 for start in range(0,len(s),size): # size=1일때 0-7, 2일때 0-6 now_seq = s[start:start+size] #현재 분할 next_seq = s[start+size:start+size*2] #다음 분할 before_seq = [] #이전 분할 if start-siz..
문제 : 오픈채팅방의 입출입 및 닉네임 변경 내역을 입력받아 채팅방에 표시되는 로그를 출력하라(단 사용자는 uid로 구별하고... 아몰라 찾아보셈(...) from collections import defaultdict def solution(record): answer = [] messages = defaultdict(list) index = 0 for r in record: if len(r.split()) == 3: command, uid, name = r.split() else: command, uid = r.split() if len(uid) > 10: continue if len(name) > 10: continue if command == "Enter": if messages[uid]: mes..
문제 : 배열을 i부터 j 까지 자르고 정렬한 다음 k번째 수를 찾아라 def solution(array, commands): answer = [] print(array) for command in commands: arr = array[ command[0] - 1 : command[1]] arr.sort() answer.append(arr[command[2]-1]) return answer 파이썬 기본 기능만 충실히 잘 써도 너무나 쉽게 풀리는 문제(slicing, sort 등)
문제 : 모든 문제를 찍는 사람의 패턴 + 문제 정답이 주어질 때 제일 점수가 잘 나온 사람은? def solution(answers): answer = [] score = [0,0,0] students = [[1,2,3,4,5],[2, 1, 2, 3, 2, 4, 2, 5],[3, 3, 1, 1, 2, 2, 4, 4, 5, 5]] i = 0 for a in answers: if a == students[0][i % 5]: score[0] += 1 if a == students[1][i % 8]: score[1] += 1 if a == students[2][i % 10]: score[2] += 1 i += 1 print(score) answer = [i+1 for i in range(3) if score[..