본문 바로가기

카테고리 없음

파이썬) 비밀번호 발음하기 - BOJ

https://www.acmicpc.net/problem/4659

 

4659번: 비밀번호 발음하기

좋은 패스워드를 만드는것은 어려운 일이다. 대부분의 사용자들은 buddy처럼 발음하기 좋고 기억하기 쉬운 패스워드를 원하나, 이런 패스워드들은 보안의 문제가 발생한다. 어떤 사이트들은 xvtp

www.acmicpc.net

 

while True:
    st = input()

    if st == 'end':
        break

    q = []
    aeiou = 'aeiou'
    others = 'bcdfghjkmnlpqrstvwxyz'
    is_aeiou = False
    is_accept = False
    for i in st:
        if i in aeiou:
            is_aeiou = True

        if len(q) == 0:
            q.append(i)
        else:
            f = q[-1]

            if f == i:
                if f == 'e':
                    z = []
                elif f == 'o':
                    z = []
                else:
                    is_accept = True
                    break

            if len(q) >= 2:
                s = q[-2]

                if s in others and f in others and i in others:
                    is_accept = True
                    break
                elif s in aeiou and f in aeiou and i in aeiou:
                    is_accept = True
                    break

                else:
                    q.append(i)

    if not is_aeiou:
        print(f'<{st}> is not acceptable.')
    elif is_accept:
        print(f'<{st}> is not acceptable.')
    else:
        print(f'<{st}> is acceptable.')