본문 바로가기
알고리즘/[python] 백준 BOJ

[python] 백준 4569 비밀번호 발음하기

by Alan_Kim 2023. 4. 12.
728x90
반응형

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

 

4659번: 비밀번호 발음하기

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

www.acmicpc.net

 

문제 해결

  • 주어진 조건을 하나씩 살펴보며 걸리는 것이 있으면 변수를 0에서 1로 변환시켜(bool 기호)  만들 수 없다고 출력
  • 그냥 구현문제. 빠진 조건 없는지 확인하기

 

CODE

vowel = ['a', 'e', 'i', 'o', 'u']
while True:
    string = input().rstrip()
    if string == 'end':
        break
    spells = list(string)
    v_flag = 0
    v_cnt = 0
    c_cnt = 0
    cnt = 0
    for i in range(len(spells)):
        if i>0:
            if spells[i] == spells[i-1]:
                if spells[i] != 'e' and spells[i] != 'o':
                    cnt = 1
                    break
        if spells[i] in vowel:
            v_flag = 1
            v_cnt += 1
            c_cnt =0
            if v_cnt == 3:
                cnt= 1
                break
        else:
            v_cnt = 0
            c_cnt += 1
            if c_cnt == 3:
                cnt = 1
                break
    if (cnt !=1) and (v_flag==1):
        print(f"<{string}> is acceptable.")
    else:
        print(f"<{string}> is not acceptable.")
728x90
반응형

댓글