언젠가는 펼쳐 볼 아카이브
[BOJ] 3003번 - 킹, 퀸, 룩, 비숍, 나이트, 폰 본문
사용언어: javascript - node.js
#제출코드
const fs = require('fs');
const filePath = process.platform === 'linux' ? '/dev/stdin' : './input.txt';
const input = fs
.readFileSync(filePath)
.toString()
.trim()
.split(' ')
.map((item) => +item);
solution(input);
function solution(input) {
const chess = [1, 1, 2, 2, 2, 8];
let answer = '';
for (let i = 0; i < chess.length; i++) {
if (chess[i] !== input[i]) {
answer += chess[i] - input[i] + ' ';
} else {
answer += 0 + ' ';
}
}
console.log(answer);
}
'IT > Baekjoon Oline Judge' 카테고리의 다른 글
[BOJ] 2444번 - 별찍기 - 7 (0) | 2023.08.22 |
---|---|
[BOJ] 10988번 - 팰린드롬인지 확인하기 (0) | 2023.08.22 |
[BOJ] 25083번 - 새싹 (0) | 2023.08.18 |
[BOJ] 5622번 - 다이얼 (0) | 2023.08.17 |
[BOJ] 2908번 - 상수 (0) | 2023.08.17 |