본문 바로가기

코딩테스트/LV. 087

LV. 0 :: 종이 자르기 https://school.programmers.co.kr/learn/courses/30/lessons/120922 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(M, N) { return answer = N * M -1; } 2023. 1. 22.
LV. 0 :: 직사각형 넓이 구하기 https://school.programmers.co.kr/learn/courses/30/lessons/120860 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(dots) { var answer = 0; var minx = Math.min(dots[0][0], dots[1][0], dots[2][0], dots[3][0]); var maxx = Math.max(dots[0][0], dots[1][0], dots[2][0], dots[3][0]); var miny = Math.min(dots[0][1], dots[1][1].. 2023. 1. 22.
LV. 0 :: 문자열 정렬하기 1 https://school.programmers.co.kr/learn/courses/30/lessons/120850 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(my_string) { var text = 0; var arr = []; for (i=0; i { return my_string.split('').filter(x=>isNaN(x)!=true).map(x=> parseInt(x)).sort((a,b)=>a-b); } // 문자열을 나눠서 배열로 만들기 & 숫자인 것만 남겨두기 & 문자열 형식을 숫자로 바꾸기 & 정.. 2023. 1. 22.
LV. 0 :: 배열 회전시키기 https://school.programmers.co.kr/learn/courses/30/lessons/120844 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(numbers, direction) { if (direction == "right") { numbers.unshift(numbers[numbers.length-1]); numbers.pop(); // 맨 뒤 원소를 맨 앞에 추가해 주고, // 맨 뒤 원소를 삭제해 준다 } else { numbers.push(numbers[0]); numbers.shift(); /.. 2023. 1. 22.
LV. 0 :: 숨어있는 숫자의 덧셈 1 https://school.programmers.co.kr/learn/courses/30/lessons/120851 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(my_string) { var sum = 0; var answer=0; for (i=0; i Number(x)).map( x => Number(x)); return arr.reduce((a, b) => a + b, 0); } 230526 python def solution(my_string): numlist = list(my_string) answer = 0 fo.. 2023. 1. 22.
LV. 0 :: 제곱수 판별하기 https://school.programmers.co.kr/learn/courses/30/lessons/120909 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(n) { var answer = 0; if (Number.isInteger(Math.sqrt(n))) {answer=1;} else {answer=2;} return answer; } +)230511 const solution = (n) => { return (Number.isInteger(Math.sqrt(n)) ? answer = 1 : answer = 2);.. 2023. 1. 21.
LV. 0 :: 숫자 찾기 https://school.programmers.co.kr/learn/courses/30/lessons/120904 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(num, k) { var num = num + ''; // 숫자를 문자열로 바꿔준다 var index = num.indexOf(k); // 문자열 안에서 k를 찾아 index를 구한다 if (index < 0) {result = -1;} // 존재하지 않는다면 -1을 return else { result = index + 1;} // 존재하는 것이 맞다면 inde.. 2023. 1. 21.
LV. 0 :: 모음 제거 https://school.programmers.co.kr/learn/courses/30/lessons/120849 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(my_string) { my_string = my_string.replace(/a/g, ''); my_string = my_string.replace(/e/g, ''); my_string = my_string.replace(/i/g, ''); my_string = my_string.replace(/o/g, ''); my_string = my_string.repla.. 2023. 1. 21.
LV. 0 :: 편지 https://school.programmers.co.kr/learn/courses/30/lessons/120898 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(message) { var answer = 0; answer = message.length * 2; return answer; } +) 230510 const solution = (message) => { return 2*message.length; } 230526 python def solution(message): return len(message)*2 230.. 2023. 1. 21.
LV. 0 :: 특정 문자 제거하기 https://school.programmers.co.kr/learn/courses/30/lessons/120826 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(my_string, letter) { var answer = ''; my_string = my_string.replace(letter, ''); my_string = my_string.replace(letter, ''); my_string = my_string.replace(letter, ''); my_string = my_string.replace(letter,.. 2023. 1. 20.
LV. 0 :: 문자열 안에 문자열 https://school.programmers.co.kr/learn/courses/30/lessons/120908 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(str1, str2) { var answer = 0; var index = str1.indexOf(str2); if (index>=0) {answer=1;} else answer=2; return answer; } +)230511 const solution = (str1, str2) => { let index = str1.indexOf(str2); index !=.. 2023. 1. 20.
LV. 0 :: 외계행성의 나이 https://school.programmers.co.kr/learn/courses/30/lessons/120834 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(age) { var answer = ''; var text = age +''; // 숫자를 문자열로 변환 text = text.replace(/0/g, 'a'); text = text.replace(/1/g, 'b'); text = text.replace(/2/g, 'c'); text = text.replace(/3/g, 'd'); text = text.repla.. 2023. 1. 20.
LV. 0 :: 자릿수 더하기 https://school.programmers.co.kr/learn/courses/30/lessons/120906 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(n) { var answer = 0; var text = n+''; const arr = text.split(''); for (i=0; i { let str = n + ''; const arr = str.split('').map(x=> parseInt(x)); return arr.reduce((a, b) => a + b, 0); } 230526 python def.. 2023. 1. 20.
LV. 0 :: 주사위의 개수 https://school.programmers.co.kr/learn/courses/30/lessons/120845 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(box, n) { var answer = Math.floor(box[0]/n) * Math.floor(box[1]/n) * Math.floor(box[2]/n); return answer; } +)230510 const solution = (box, n) => { return Math.floor(box[0]/n) * Math.floor(box[1]/n) * Mat.. 2023. 1. 20.
LV. 0 :: 세균 증식 https://school.programmers.co.kr/learn/courses/30/lessons/120910 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(n, t) { var answer = 0; answer = n * (2 ** t); return answer; } +)230510 const solution = (n, t) => { return n*2**t; } 230915 C++ #include #include #include using namespace std; int solution(int n, int t).. 2023. 1. 20.
LV. 0 :: 개미 군단 https://school.programmers.co.kr/learn/courses/30/lessons/120837 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(hp) { var answer = 0; ant1 = Math.floor(hp/5); ant2 = Math.floor((hp%5)/3); ant3 = Math.floor(((hp%5)%3)); answer = ant1+ant2+ant3; return answer; } 230525 python def solution(hp): return hp//5 + hp%5//3 .. 2023. 1. 20.
LV. 0 :: 최댓값 만들기 1 https://school.programmers.co.kr/learn/courses/30/lessons/120847 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(numbers) { var answer = 0; numbers = numbers.sort((a,b)=>a-b); answer = numbers[numbers.length-1] * numbers[numbers.length-2]; return answer; } +)230510 const solution = (numbers) => { numbers = numbers.s.. 2023. 1. 20.
LV. 0 :: 문자열 뒤집기 https://school.programmers.co.kr/learn/courses/30/lessons/120822 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(my_string) { var answer = []; answer = my_string.split('').reverse().join(''); return answer; } +) 230510 const solution = (my_string) => { return my_string.split('').reverse().join(''); } 230525 파이썬 def .. 2023. 1. 20.
LV. 0 :: 배열 자르기 https://school.programmers.co.kr/learn/courses/30/lessons/120833 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(numbers, num1, num2) { var answer = numbers.slice(num1, num2+1); return answer; } +) 230510 const solution = (numbers, num1, num2) => { return numbers.slice(num1,num2+1); } 230525 python def solution(numb.. 2023. 1. 20.
LV. 0 :: 점의 위치 구하기 https://school.programmers.co.kr/learn/courses/30/lessons/120841 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(dot) { var answer = 0; if (dot[0]>0 && dot[1]>0) {answer = 1;} else if (dot[0]0) {answer = 2;} else if (dot[0] 2023. 1. 20.
LV. 0 :: 각도기 https://school.programmers.co.kr/learn/courses/30/lessons/120829 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(angle) { let answer = 0; if (angle > 0 && angle 90 && angle < 180) {answer=3;} else if (angle == 180) {answer=4;} return answer; } +)23.. 2023. 1. 20.