20250601 baekjoon javascript

This commit is contained in:
songyc macbook 2025-06-01 20:10:44 +09:00
parent af758ceb0f
commit ebe2262463
5 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,9 @@
const s = require("fs").readFileSync(0, "utf8").toString().trim();
let flag = 1;
for(let i=0; i<s.length/2; i++){
if(s[i]!=s[s.length-i-1]){
flag = 0;
break;
}
}
console.log(flag);

View File

@ -0,0 +1,17 @@
const n = require("fs").readFileSync(0,"utf8").toString().toUpperCase();
let arr = new Array(26).fill(0);
for(let c of n){
arr[c.charCodeAt()-'A'.charCodeAt()]++;
}
let max_idx = 0, cnt = 0;
for(let i=0; i<26; i++){
if(arr[i]==Math.max(...arr)){
max_idx=i;
cnt++;
}
}
console.log(cnt>1 ? '?' : String.fromCharCode('A'.charCodeAt()+max_idx));

View File

@ -0,0 +1,7 @@
const n = Number(require("fs").readFileSync(0, "utf8").toString());
for(let i=1; i<=n; i++){
console.log(' '.repeat(n-i) + '*'.repeat(2*i-1));
}
for(let i=n-1; i>0; i--){
console.log(' '.repeat(n-i) + '*'.repeat(2*i-1));
}

View File

@ -0,0 +1,3 @@
console.log(
" ,r'\"7\nr`-_ ,' ,/\n \\. \". L_r'\n `~\\/\n |\n |"
);

View File

@ -0,0 +1,3 @@
const n = require("fs").readFileSync(0,'utf8').toString().split(" ").map(Number);
const arr = [1,1,2,2,2,8];
console.log(...arr.map((v,i)=>v-n[i]));