코테/프로그래머스

def solution(answers): one = [1, 2, 3, 4, 5] two = [ 2, 1, 2, 3, 2, 4, 2, 5] three = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5] scores = [0,0,0] lengths = [5,8,10] anslen = len(answers) answer = [] for i in range(0, len(answers)): if one[i % lengths[0]] == answers[i]: scores[0] += 1 if two[i % lengths[1]] == answers[i]: scores[1] += 1 if three[i % lengths[2]] == answers[i]: scores[2] += 1 m = max(scores) fo..
처음 코드 - 테스트 케이스 중 1개가 틀려 95점을 받았다. 뭐가 문제일까...? 이왜틀? 아이디어 : h 또는 w에서 최대값을 찾고, 최댓값이 h인지 w인지 horw 변수에 저장한 후 최솟값들 중 최댓값을 찾는다. def solution(sizes): tmax= 0 tmin =0 horw = 0 for s in sizes: if s[0] >= tmax: tmax = s[0] horw = 0 # height elif s[1] >= tmax: tmax = s[1] horw = 1 #width a = horw b = ~horw for s in sizes: if s[a] > s[b]: if tmin
밤밭황제
'코테/프로그래머스' 카테고리의 글 목록 (4 Page)