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
- level3
- 코딩테스트
- 운영체제
- N과M
- 가상메모리 관리
- programmers
- MYSQL
- 프로그래머스
- dict
- 가상메모리
- python
- BFS
- 구현
- DP
- 백준
- level1
- 힙
- level0
- 딕셔너리
- 브루트포스
- 다익스트라
- 파이썬
- 스택
- 수학
- dfs
- level2
- 다이나믹 프로그래밍
- 재귀
- 그리디
- BOJ
Archives
- Today
- Total
동캄의 코딩도장
프로그래머스 level0 [옹알이] 파이썬 본문
https://school.programmers.co.kr/learn/courses/30/lessons/120956
def solution(babbling):
answer = 0
for babb in babbling:
babb = list(map(str, babb))
i = 0
length = len(babb)
while i < length:
if babb[i] == 'a' and (i+2 < length) and babb[i+1] == 'y' and babb[i+2] == 'a':
i += 3
elif babb[i] == 'y' and (i+1 < length) and babb[i+1] == 'e':
i += 2
elif babb[i] == 'w' and (i+2 < length) and babb[i+1] == 'o' and babb[i+2] == 'o':
i += 3
elif babb[i] == 'm' and (i+1 < length) and babb[i+1] == 'a':
i += 2
else:
break
if i == length:
answer+=1
break
return answer
처음에는 babbling에서 최대로 발음할 수 있는 단어의 개수를 질문하는 것인 줄 알고, 그렇게 알고리즘을 구성했는데, 문제를 다시 읽어보니 babbling의 각 요소들 중에 발음할 수 있는 것이 몇개인가 하는 문제였다.
(차근차근 잘 읽어보자)
이 다음부터 level0에 해당하는 문제는 JS를 통해 풀고 github에 업로드 할 예정이다.(JS 연습을 하기위해서)
'코테 > 프로그래머스 level0' 카테고리의 다른 글
프로그래머스 level0 [문자열 밀기] 파이썬 (0) | 2023.03.07 |
---|---|
프로그래머스 level0 [저주의 숫자 3] 파이썬 (0) | 2023.03.06 |
프로그래머스 level0 [특이한 정렬] 파이썬 (0) | 2023.03.05 |
프로그래머스 level0 [다항식 더하기] 파이썬 (0) | 2023.03.05 |
프로그래머스 level0 [최빈값 구하기] 파이썬 (0) | 2023.03.05 |