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 | 29 |
30 | 31 |
Tags
- ChatGPT
- 편스토랑 우승상품
- Baekjoon
- ubuntu
- 더현대서울 맛집
- 프로그래머스 파이썬
- 캐치카페
- 프로그래머스
- github
- 맥북
- 금융문자분석경진대회
- programmers
- Git
- 백준
- dacon
- AI 경진대회
- leetcode
- 편스토랑
- gs25
- 우분투
- 코로나19
- Kaggle
- SW Expert Academy
- Real or Not? NLP with Disaster Tweets
- hackerrank
- 데이콘
- 자연어처리
- PYTHON
- Docker
- 파이썬
Archives
- Today
- Total
솜씨좋은장씨
[BaekJoon] 24405번 : Eye of Sauron (Python) 본문
728x90
반응형
코딩 1일 1문제! 오늘의 문제는 백준의 Eye of Sauron 입니다.
24405번: Eye of Sauron
Input consists of a single string of length $n$, where $4 ≤ n ≤ 100$. Input strings will consist only of three types of characters: vertical bars, open parentheses, and closing parentheses. Input strings contain one or more vertical bars followed by a
www.acmicpc.net
🧑🏻💻 문제 풀이
사우론의 눈을 나타내는 문자열인 () 의 좌우에 | 가 동일한 개수로 존재하는지 확인하여
같으면 correct 를 답으로
다르면 fix 를 답으로 하는 문제입니다.
입력 받은 문자열 속 문자는 () 와 | 이외에 다른 문자는 존재하지 않는다는 것이 전제 조건입니다.
left, right = string.split("()")
이에 따라 사우론의 눈을 가리키는 () 으로 문자열을 split 해준 뒤 나오는 양쪽의 값이 같은지 다른지를 확인하였습니다.
answer = "fix"
if left == right:
answer = "correct"
ex) Eye of Sauron String == |||()|||
-> split("()") == left ||| right |||
-> left == right True -> correct
ex) Eye of Sauron String == ()|||||||
-> split("()") == left right |||||||
-> left == right False -> fix
전체 코드는 아래를 참고해주세요.
🧑🏻💻 코드 ( Solution )
def eye_of_sauron(string):
answer = "fix"
left, right = string.split("()")
if left == right:
answer = "correct"
return answer
if __name__ == "__main__":
string = input()
print(eye_of_sauron(string=string))
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] 11006번 : 남욱이의 닭장 (Python) (0) | 2022.11.11 |
---|---|
[BaekJoon] 17206번 : 준석이의 수학 숙제 (Python) (0) | 2022.11.10 |
[BaekJoon] 11235번 : Polling (Python) (0) | 2022.11.08 |
[BaekJoon] 25815번 : Cat's Age (Python) (0) | 2022.11.07 |
[BaekJoon] 11536번 : 줄 세우기 (Python) (0) | 2022.11.06 |
Comments