Python
[coding test] 2019 카카오 개발자 겨울 인턴십 문제
1,2,3번은 평이한 난이도라 코드만 keep. 10~20줄 내외다.(각 문제당 약 2~30분 동안 풀었음) 1.크레인 인형뽑기 게임 from collections import deque def solution(board, moves): leng = len(board) q = deque([]) count = 0 for i in moves: for j in range(leng): if board[j][i - 1] != 0: q.append(board[j][i - 1]) if len(q) >1 and q[len(q)-1]==q[len(q)-2]: count += 2 q.pop() q.pop() board[j][i - 1] = 0 break return count 2. 튜플 def solution(s): ss..
![[Python] 리스트(list)에서 '조합' 찾기(product,permutations,combinations)](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FVQFyz%2FbtqDY2lTKrM%2FoPc4npOF2GmLnSBK6a1mu0%2Fimg.jpg)
[Python] 리스트(list)에서 '조합' 찾기(product,permutations,combinations)
알고리즘 문제에서 흔히 등장하는 조합을 찾는 문제. 여러 번 봤지만 볼 때마다 헷갈려서 정리해보려 한다. iteration은 설치가 필요 없는 파이썬의 기본 라이브러리 from itertools import product from itertools import permutations from itertools import combinations 다만 문제를 풀기 위해서는 순열(permutation)과 조합(combination)에 대한 이해가 있어야 하는데, 아래 블로그에 잘 정리되어 있다. https://suhak.tistory.com/2 순열(permutation)에서 조합(Combination)으로 순서가 있는 것에서 없는 것으로 경우의 수를 세는 방법 가운데 바탕이 되는 것은 순열과 조합이다. 그..