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 | 29 | 30 |
Tags
- iNT
- 에러해결
- n_neighbors
- SMAPE
- PAPER
- 논문editor
- 논문
- KAKAO
- Overleaf
- 파이썬을파이썬답게
- knn
- Tire
- Mae
- MAPE
- n_sample
- Python
- 논문작성
- mes
- mMAPE
- Alignments
- RMES
- 코테
- 카카오
- Pycaret
- python 갯수세기
- 프로그래머스
- TypeError
- 평가지표
- Scienceplots
- 스택
Archives
- Today
- Total
EunGyeongKim
[완전탐색]모음사전 본문
더 많은 코드 (https://github.com/EunGyeongKim/TIL)
GitHub - EunGyeongKim/TIL: Today I Learne
Today I Learne. Contribute to EunGyeongKim/TIL development by creating an account on GitHub.
github.com
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
1. 문제 설명
사전에 알파벳 모음 'A', 'E', 'I', 'O', 'U'만을 사용하여 만들 수 있는, 길이 5 이하의 모든 단어가 수록되어 있습니다. 사전에서 첫 번째 단어는 "A"이고, 그다음은 "AA"이며, 마지막 단어는 "UUUUU"입니다.
단어 하나 word가 매개변수로 주어질 때, 이 단어가 사전에서 몇 번째 단어인지 return 하도록 solution 함수를 완성해주세요.
2. 제한사항
- word의 길이는 1 이상 5 이하입니다.
- word는 알파벳 대문자 'A', 'E', 'I', 'O', 'U'로만 이루어져 있습니다.
3. 입출력 예
word | result |
---|---|
"AAAAE" | 6 |
"AAAE" | 10 |
"I" | 1563 |
"EIO" | 1189 |
4. 코드
def solution(word):
graph = [' ','A','E','I','O','U']
tmp = ''
graph_list = []
for a in graph[1:]:
for b in graph:
for c in graph:
for d in graph:
for e in graph:
tmp = (a+b+c+d+e).replace(" ", '')
graph_list.append(tmp)
a = sorted(set(graph_list))
# print(a)
return a.index(word)+1
4-1. 타인 코드
from itertools import product
# product를 이용하여 list 만들고 출력
solution = lambda word: sorted(["".join(c) for i in range(5) for c in product("AEIOU", repeat=i+1)]).index(word) + 1
'코딩테스트 > programmers' 카테고리의 다른 글
[연습문제]컨트롤 제트 (0) | 2022.10.14 |
---|---|
[탐욕법]큰 수 만들기 (0) | 2022.10.13 |
[완전탐색]소수 찾기 (0) | 2022.10.12 |
[완전탐색]피로도 (0) | 2022.10.12 |
[level 0]최빈값 구하기 (0) | 2022.10.11 |
Comments