목록if-else (1)
IT 세계의 후아
[python]조건문
if-else문 관련 문제 풀이 # 프로그래머스 조건 문자열 def solution(ineq, eq, n, m): if ineq == '>': if eq == '=': return int(n >= m) else: return int(n > m) else: if eq == '=': return int(n 오히려 runtime 오래 걸려서 시간 초과됨... # 프로그래머스 콜라츠 수열 # 초반 풀이 - 시간 초과ㅠㅡㅠ def solution(n): answer = [] while n > 1: answer.append(n/2 if n%2 == 0 else 3*n + 1) print(answer) answer.append(1) return answer # 수정 후 answer = [] while n > 1: a..
Coding/Python
2024. 4. 17. 16:57