Notice
Recent Posts
Recent Comments
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 데이콘
- programmers
- 맥북
- 편스토랑 우승상품
- Real or Not? NLP with Disaster Tweets
- gs25
- SW Expert Academy
- dacon
- 프로그래머스 파이썬
- 백준
- Docker
- hackerrank
- Kaggle
- Git
- leetcode
- 파이썬
- 우분투
- Baekjoon
- 코로나19
- github
- 프로그래머스
- ChatGPT
- AI 경진대회
- 더현대서울 맛집
- 편스토랑
- 자연어처리
- 금융문자분석경진대회
- ubuntu
- 캐치카페
- PYTHON
Archives
- Today
- Total
솜씨좋은장씨
[BaekJoon] 26587번 : Reverse (Python) 본문
728x90
반응형
코딩 1일 1문제! 오늘의 문제는 백준의 Reverse 입니다.
26587번: Reverse
At a contest you have been asked to write a program that reads in a line of text and reverses the order of all words that begin with vowels. Words that begin with consonants will keep their position in the line of text. You are not sure why you would ever
www.acmicpc.net
👨🏻💻 코드 ( Solution )
def reverse(string):
vowels = ['a', 'e', 'i', 'o', 'u']
reverse_result = []
reverse_dict = {}
words = string.split()
check_vowels = [word[0] for word in enumerate(words) if word[1][0].lower() in vowels]
reverse_check = check_vowels[::-1]
for idx, check_idx in enumerate(check_vowels):
reverse_dict[check_idx] = words[reverse_check[idx]]
for word_idx, word in enumerate(words):
if word_idx in reverse_dict.keys():
reverse_result.append(reverse_dict[word_idx])
else:
reverse_result.append(word)
return " ".join(reverse_result)
if __name__ == "__main__":
while True:
try:
string = input()
print(reverse(string=string))
except EOFError:
break
GitHub - SOMJANG/CODINGTEST_PRACTICE: 1일 1문제 since 2020.02.07
1일 1문제 since 2020.02.07. Contribute to SOMJANG/CODINGTEST_PRACTICE development by creating an account on GitHub.
github.com
'Programming > 코딩 1일 1문제' 카테고리의 다른 글
[BaekJoon] 23808번 : 골뱅이 찍기 - ㅂ (Python) (0) | 2023.01.13 |
---|---|
[BaekJoon] 23806번 : 골뱅이 찍기 - ㅁ (Python) (2) | 2023.01.12 |
[BaekJoon] 27001번 : Bovine Birthday (Python) (0) | 2023.01.09 |
[BaekJoon] 10570번 : Favorite Number (Python) (0) | 2023.01.08 |
[BaekJoon] 26500번 : Absolutely (Python) (0) | 2023.01.07 |
Comments