코딩테스트/LV. 0
LV. 0 :: 옷가게 할인 받기
KUROMI98
2023. 1. 20. 16:26
https://school.programmers.co.kr/learn/courses/30/lessons/120818
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
function solution(price)
{
var answer = 0;
if (price < 100000) {answer = price;}
else if (price >= 100000 && price < 300000) {answer = price * 0.95;}
else if (price >= 300000 && price < 500000) {answer = price * 0.9;}
else if (price >= 500000) {answer = price * 0.8;}
return Math.floor(answer);
}
+) 230510
const solution = (price) => {
let answer = 0;
if (price<100000){ answer = price }
else if (price >=100000 && price<300000){ answer = price*0.95}
else if (price >=300000 && price<500000){ answer = price*0.90}
else if (price >=500000 ){ answer = price*0.80}
return Math.floor(answer);
}
230525 python
import math
def solution(price):
answer = 0
if price<100000:
answer = price
elif price >=100000 and price<300000:
answer = price*0.95
elif price >=300000 and price<500000:
answer = price*0.90
elif price >=500000:
answer = price*0.80
return math.floor(answer)