본문 바로가기
728x90

분류 전체보기104

[프로그래머스][Js] Lv.0 - 분수의 덧셈 문제💭 나의 풀이👨‍💻 function solution(denum1, num1, denum2, num2) { let result = [0,0] let x = denum1*num2 + denum2*num1; let y = num1*num2 let lcm = 1; for(let i = 0; i { let [ denum, num ] = [denum1 * num2 + denum2 * num1, num2 * num1] while(true) { let isContinue = false const min = denum (a*b)/g(a,b),p,q,solution=(a,b,c,d)=>{return .. 2023. 3. 15.
[프로그래머스][Js] Lv.0 - 다음에 올 숫자 문제💭 나의 풀이👨‍💻 function solution(common) { if (common[1] - common[0] === common[2] - common[1]) return common[common.length - 1] + common[2] - common[1]; if (common[1] / common[0] === common[2] / common[1]) return common[common.length - 1] * (common[2] / common[1]); } 다른 사람의 풀이👨‍🏫 1. const solution = c => c[1]-c[0] === c[2]-c[1] ? c[c.length-1] + c[1] - c[0] : c[c.length-1] * c[1] / c[0] 2. var so.. 2023. 3. 15.
[프로그래머스][Js] Lv.0 - 연속된 수의 합 문제💭 나의 풀이👨‍💻 function solution(num, total) { let answer = []; let n = Math.floor(total / num); for (let i = Math.round(-num / 2); i < Math.round(num / 2); i++) { num % 2 === 0 ? answer.push(n + 1 + i) : answer.push(n + i); } return answer; } 다른 사람의 풀이👨‍🏫 1. function solution(num, total) { var min = Math.ceil(total/num - Math.floor(num/2)); var max = Math.floor(total/num + Math.floor(num/2)); ret.. 2023. 3. 14.
[프로그래머스][Js] Lv.0 - 안전지대 문제💭 나의 풀이👨‍💻 function solution(board) { let result = 0 for(let i = 0 ; i < board.length ; i ++) { for(let j = 0 ; j < board[i].length ; j ++) { if(board[i][j] === 1) { if(i !== 0 && board[i-1][j] !== 1) { board[i-1][j] = 2 } if(i !== board.length-1 && board[i+1][j] !== 1) { board[i+1][j] = 2 } if(j !== 0 && board[i][j-1] !== 1) { board[i][j-1] = 2 } if(j !== board[i].length-1 && board[i][j+1] !=.. 2023. 3. 14.
[Linux] 파일 권한 확인 및 변경하기 (permission) 퍼미션(permission)이란? 특정 파일이나 경로를 사용할 권한을 설정하는 기준이자 그 기준으로 만든 설정 그 자체를 일컫는 말이다. 유닉스/리눅스에서 주로 사용되는 파티션에서는 3자리의 8진수로 이루어진 권한 설정이 사용되며, 첫째 자리는 해당 파일의 소유자 본인, 둘째 자리는 파일 소유자가 소속된 그룹과 같은 그룹에 소속된 사용자, 셋째 자리는 그 외의 일반 사용자로써 각각 읽기(파일 구성을 읽을 수 있다), 쓰기(파일 구성을 수정할 수 있다), 동작(파일을 실행시킬 수 있다)의 권한을 4, 2, 1의 숫자 조합을 통해 나타낸다. 4, 2, 1의 조합인 이유는 2진수로 표현 시 첫 자리(4)가 읽기, 둘째 자리(2)가 쓰기, 셋째 자리(1)가 동작이라서이다. 출처 : 나무위키 퍼미션을 확인하는 방.. 2023. 3. 13.
[프로그래머스][Js] Lv.0 - 겹치는 선분의 길이 문제💭 나의 풀이👨‍💻 function solution(lines) { const linesArr = [...lines[0], ...lines[1], ...lines[2]] const min = Math.min(...linesArr) const max = Math.max(...linesArr) const result = Array(max - min + 1).fill(0) for (let line of lines) { line.sort((a, b) => a - b) if (min < 0) { line[0] += Math.abs(min) line[1] += Math.abs(min) } for (let i = line[0]; i < line[1]; i ++ ) { result[i] ++; } } return .. 2023. 3. 13.
728x90