📚 이론정리/알고리즘
연산자를 활용한 문제
서카츄
2024. 1. 28. 00:32
1. 막내야 도넛 좀 사와라
function solution(n, donuts){
return n/donuts;
}
solution(120, 12);
solution(40, 8);
2. 운수 좋은 날
function solution(n, members) {
const money = n + 6000;
const coffee = 4100 * members;
const result = money - coffee;
return result;
}
solution(50000, 12);
solution(35000, 9);
3. 이런 건 맨날 나만 시키지
function solution(name, birth) {
const result = name + birth;
return result;
}
solution("marco", 970219);
solution("tomas", 991108);
4. 비밀번호 만들기
function solution(birth, date) {
const result = birth + date;
return `비밀번호는 ${result}입니다.`;
}
solution(900501, 2021);
solution(930219, 2020);
5. 제비뽑기 용지
function solution(a, b) {
const row = a - 1;
const col = (b - 1) * a;
return row + col;
}
solution(100, 100); // 9999
solution(1, 1); // 0
solution(20, 50); // 999
6. 분기별 일정
function solution(month) {
const result = Math.ceil(month / 3);
return result;
}
solution(4); // 2
solution(12); // 4