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
- 시그널 핸들러
- 운영체제와 정보기술의 원리
- SDK
- recoverability
- 데이터베이스
- 커널 동기화
- 시스템프로그래밍
- 온디바이스AI
- 갤럭시 S24
- 운영체제
- 코딩테스트 [ ALL IN ONE ]
- concurrency control
- 트랜잭션
- 인터럽트
- 프로세스 주소 공간
- SQL
- 반효경
- 네트워크
- 쉬운코드
- 백엔드
- CPU 스케줄링
- vite
- 김영한
- Extendable hashing
- BreadcrumbsComputer-Networking_A-Top-Down-Approach
- 코딩애플
- 쉬운 코드
- Git
- B tree 데이터삽입
- 개발남노씨
Archives
- Today
- Total
티끌모아 태산
[백 준/구현] 4659: 비밀번호 발음하기 본문
728x90
https://www.acmicpc.net/problem/4659
4659번: 비밀번호 발음하기
좋은 패스워드를 만드는것은 어려운 일이다. 대부분의 사용자들은 buddy처럼 발음하기 좋고 기억하기 쉬운 패스워드를 원하나, 이런 패스워드들은 보안의 문제가 발생한다. 어떤 사이트들은 xvtp
www.acmicpc.net
핵심 아이디어
- 문제에서 주어진 조건만 만족시키면 풀 수 있다.
풀이 (1)
# 모음 받아오기
lst = ['a','e','i','o','u']
#입력은 여러개의 테스트 케이스로 이루어진다.
while True:
# 문자열 입력받기
s = input()
# end 이면 반환
if s == 'end':
break
# 1. 모음 하나를 반드시 포함하여야한다.
# 모음 수 카운트 변수
cnt = 0
for i in lst:
if i in s:
cnt += 1
if cnt < 1:
print(f'<{s}> is not acceptable.')
continue
# 2. 모음이 3개 혹은 자음이 3개 연속으로 오면 안된다.
x=y=0
for i in range(len(s) - 2):
# 모음 연속해서 3개 나오는 경우
if s[i] in lst and s[i+1] in lst and s[i+2] in lst:
x = 1
# 자음 연속해서 3개 나오는 경우
elif (s[i] not in lst and s[i+1] not in lst and s[i+2] not in lst):
x = 1
if x == 1:
print(f'<{s}> is not acceptable.')
continue
# 3. 같은 글자가 연속적으로 두번 오면 안되나, ee와 oo는 허용한다.
for i in range(len(s) - 1):
if s[i] == s[i+1]:
if s[i] == 'e' or s[i] == 'o':
continue
else:
y = 1
if y == 1:
print(f'<{s}> is not acceptable.')
continue
# 다 통과하면 허용
print(f'<{s}> is acceptable.')
풀이 (2)
# 모음 받아오기
lst = ['a','e','i','o','u']
#입력은 여러개의 테스트 케이스로 이루어진다.
while True:
# 문자열 입력받기
s = input()
# end 이면 반환
if s == 'end':
break
# 1. 모음 하나를 반드시 포함하여야한다.
if not any(i in s for i in lst):
print(f'<{s}> is not acceptable.')
continue
# 2. 모음이 3개 혹은 자음이 3개 연속으로 오면 안된다.
x=y=0
for i in range(len(s) - 2):
# 모음 연속해서 3개 나오는 경우
if s[i] in lst and s[i+1] in lst and s[i+2] in lst:
x = 1
# 자음 연속해서 3개 나오는 경우
elif (s[i] not in lst and s[i+1] not in lst and s[i+2] not in lst):
x = 1
if x == 1:
print(f'<{s}> is not acceptable.')
continue
# 3. 같은 글자가 연속적으로 두번 오면 안되나, ee와 oo는 허용한다.
for i in range(len(s) - 1):
if s[i] == s[i+1]:
if s[i] == 'e' or s[i] == 'o':
continue
else:
y = 1
if y == 1:
print(f'<{s}> is not acceptable.')
continue
# 다 통과하면 허용
print(f'<{s}> is acceptable.')
728x90
'백준 문제' 카테고리의 다른 글
[백 준/구현] 13460: 구슬 탈출2 (0) | 2024.01.17 |
---|---|
[백 준/구현] 10870: 세 수 - 파이썬 (0) | 2023.10.06 |
[백 준/구현] 5622: 다이얼 - 파이썬 (0) | 2023.10.06 |