1. 두 수의 나눗셈
문제
코드
def solution(num1, num2):
answer = int(num1 / num2 * 1000)
return answer
2. 숫자 비교하기
문제
코드
def solution(num1, num2):
if(num1 == num2):
return 1
else:
return -1
3. 분수의 덧셈
문제
코드
import math
def solution(numer1, denom1, numer2, denom2):
final_numer= denom1*numer2+numer1*denom2
final_denom = denom1*denom2
gcd = math.gcd(final_numer, final_denom)
answer = [final_numer//gcd, final_denom//gcd]
return answer
4. 배열 두 배 만들기
문제
코드
def solution(numbers):
answer = []
for i in numbers :
answer.append(2*i)
return answer
728x90
'study > 알고리즘' 카테고리의 다른 글
[알고리즘] 그리디 알고리즘이란? (0) | 2024.04.08 |
---|---|
[파이썬] 파이썬 문법 정리 (1) | 2024.04.01 |
[코드업] 코드업 파이썬 기초 100제 (0) | 2024.04.01 |
[프로그래머스] 코딩테스트 연습 <가장 가까운 같은 글자> (python) (0) | 2024.02.25 |
[프로그래머스] [PCCE 기출문제] 9번 이웃한 칸 (Python) (0) | 2024.02.25 |