Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- re.split
- 백준 파이썬
- 백준 19238
- springboot
- MySQL
- Kotlin
- 백준
- spring cloud
- 파이썬
- with recursive
- Spring
- Spring Boot
- 백준 16719
- 백준 16235
- JVM
- java
- MSA
- JPA
- java 기술면접
- 백준 15685
- 백준 17779
- 백준 17626
- 프로래머스
- Coroutine
- spring oauth
- spring security
- sql 기술면접
- 프로그래머스
- 웹어플리케이션 서버
- 백준 16236
Archives
- Today
- Total
시작이 반
[프로그래머스] 메뉴 리뉴얼(python 파이썬) 본문
SMALL
programmers.co.kr/learn/courses/30/lessons/72411
코딩테스트 연습 - 메뉴 리뉴얼
레스토랑을 운영하던 스카피는 코로나19로 인한 불경기를 극복하고자 메뉴를 새로 구성하려고 고민하고 있습니다. 기존에는 단품으로만 제공하던 메뉴를 조합해서 코스요리 형태로 재구성해서
programmers.co.kr
조합, 사전 관련 문제이다.
course 수에 따른 조합을 구하여 사전에 넣는다.
from itertools import combinations
def solution(orders, course):
answer = []
for cour in course:
menus = dict()
temps = list()
for order in orders:
temps.extend(list(combinations(sorted(order), cour)))
for temp in temps:
key = ''.join(temp)
if key in menus:
menus[key] += 1
else:
menus[key] = 1
for menu in menus:
if max(menus.values()) > 1:
if menus[menu] == max(menus.values()):
answer.append(menu)
answer.sort()
return answer
solution(["XYZ", "XWY", "WXA"], [2, 3, 4])
LIST
'알고리즘 > Programmers' 카테고리의 다른 글
[프로그래머스] 키패드 누르기(python 파이썬) (0) | 2021.04.29 |
---|---|
[프로그래머스] 순위 검색(python 파이썬) (2) | 2021.03.19 |
[프로그래머스] 신규 아이디 추천(python 파이썬) (0) | 2021.03.18 |
[프로그래머스] 등굣길(python 파이썬) (0) | 2021.03.12 |
[프로그래머스] N으로 표현(python 파이썬) (0) | 2021.03.11 |