목록IT/Baekjoon Oline Judge (74)
언젠가는 펼쳐 볼 아카이브
사용언어 : javascript - node.js #제출코드 const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; const input = fs .readFileSync(filePath) .toString() .trim() .split('\n') .map((item) => +item); solution(input); function solution(input) { let sum = input.reduce((total, angle) => (total += angle)); if (input[0] === 60 && input[1] === 60 && input[2] === 60) ..

사용언어 : javascript - node.js #문제 #접근방법 최소 크기의 직사각형 넓이를 구해야한다. 처음엔 입력값의 좌표들이 담긴 사각형의 좌표를 하나하나 구해야 하나 했었는데, 생각해보니 그냥 그 좌표들을 가지고 사각형을 그려서 가로/세로 넓이를 구하면 될 것 같다. 그렇다면 점의 개수가 1개 일때는 넓이를 구할 수 없으므로 결과 값을 0으로 해주고, 점의 개수가 1개 이상일 때의 가로/세로 길이를 구해보자..! * 가로 길이 : x 좌표에서 제일 큰 값 - x 좌표에서 제일 작은 값 * 세로 길이 : y 좌표에서 제일 큰 값 - y 좌표에서 제일 작은 값 위와 같으므로 입력한 x좌표들과 y 좌표들을 내림차순으로 sort 한 후 길이를 계산해주자. 내림차순으로 정렬한 후 뺄셈을 했지만 혹시 모..
사용언어 : javascript - node.js #제출코드 const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; const n = fs.readFileSync(filePath).toString().trim(); solution(n); function solution(n) { // 둘레의 길이는 입력한 n*4 console.log(n*4); }
사용언어 : javascript - node.js #제출 코드 const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt'; const array = fs .readFileSync(filePath) .toString() .trim() .split('\n') .map((item) => item .trim() .split(' ') .map((item) => +item) ); solution(array); function solution(array) { let x = array.map((item) => item[0]).sort((a, b) => a - b); let y = array.ma..