L0 : 옹알이(1) Python

jhyunn·2023년 1월 11일
0

Programmers

목록 보기
1/69

L0 : 옹알이(1) Python

https://school.programmers.co.kr/learn/courses/30/lessons/120956

from itertools import permutations

def solution(babbling):
    joka = ['aya', 'ye', 'woo', 'ma']
    p = []
    for i in range(1, 5):
        p += [''.join(p) for p in permutations(joka, i)]

    cnt = 0
    for b in babbling:
        if b in p:
            cnt += 1
    return cnt

4가지 단어만 발음할 수 있기 때문에, permutation을 활용해 모든 조합을 찾고 비교한다.

#itertools # permutations #replace #join

profile
https://github.com/Sungjeonghyun

0개의 댓글