-
[완전탐색] 모의고사 / 소수 찾기 / 카펫알고리즘/프로그래머스 2021. 9. 15. 20:44
https://programmers.co.kr/learn/courses/30/lessons/42840
def solution(answers): case1, case2, case3 = [1,2,3,4,5], [2,1,2,3,2,4,2,5], [3,3,1,1,2,2,4,4,5,5] s = [0, 0, 0] for i in range(len(answers)): if case1[i%5] == answers[i]: s[0] += 1 if case2[i%8] == answers[i]: s[1] += 1 if case3[i%10] == answers[i]: s[2] += 1 return [i+1 for i in range(3) if s[i]==max(s)]
https://programmers.co.kr/learn/courses/30/lessons/42839
from itertools import permutations def solution(numbers): answer = 0 cases = [] for i in range(len(numbers)): cases += ([int(''.join(i)) for i in list(permutations(list(numbers), i+1))]) for i in set(cases): if isPrime(i): answer += 1 return answer def isPrime(num): if num<=1: return False for i in range(2, num): if num%i==0: return False return True
https://programmers.co.kr/learn/courses/30/lessons/42842
def solution(brown, yellow): answer = [] size = brown+yellow for i in range(1, size): if size%i == 0: #i로 나눠 떨어지면.. y = size//i x = size//y if (x-2)*(y-2) == yellow: answer = [x, y] return answer
'알고리즘 > 프로그래머스' 카테고리의 다른 글
[위클리 챌린지] 8주차 (0) 2021.09.27 [위클리 챌린지] 7주차 (0) 2021.09.17 [스택/큐] 기능개발 / 주식가격 (0) 2021.09.12 [위클리 챌린지] 6주차 (0) 2021.09.11 [위클리 챌린지] 5주차 (0) 2021.09.11