[프로그래머스] Lv.0 조건 문자열
2023. 12. 3. 16:02ㆍ코딩 테스트/프로그래머스
✏️ 문제
https://school.programmers.co.kr/learn/courses/30/lessons/181934

Python
def solution(ineq, eq, n, m):
return int(eval(f"{n}{ineq}{eq.replace('!','')}{m}"))
Java
public int solution(String ineq, String eq, int n, int m) {
boolean answer = true;
if (eq.equals("=")) {
answer = ineq.equals(">") ? n >= m : n <= m;
} else {
answer = ineq.equals(">") ? n > m : n < m;
}
return (answer) ? 1 : 0;
}
'코딩 테스트 > 프로그래머스' 카테고리의 다른 글
Lv.0 코드 처리하기 (1) | 2023.12.06 |
---|---|
Lv.1 [PCCP 기출문제] 1번 (1) | 2023.12.05 |
[프로그래머스] Lv.0 flag에 따라 다른 값 반환하기 (2) | 2023.12.03 |
[프로그래머스] Lv.0 문자열 반복해서 출력하기 (2) | 2023.12.02 |
[프로그래머스] Lv.0 문자열 출력하기 (0) | 2023.12.02 |