https://www.acmicpc.net/problem/2941

 

2941번: 크로아티아 알파벳

예전에는 운영체제에서 크로아티아 알파벳을 입력할 수가 없었다. 따라서, 다음과 같이 크로아티아 알파벳을 변경해서 입력했다. 크로아티아 알파벳 변경 č c= ć c- dž dz= đ d- lj lj nj nj š s= ž z=

www.acmicpc.net

const fs = require('fs');
let croatia = fs.readFileSync('/dev/stdin').toString().trim();
const croatiaList = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z='];

const result = [];
let cnt = 0;
let flag = true;

while(flag){
    let include = false;
    for(let i = 0 ; i < croatiaList.length ; i++) {
        if(croatia.includes(croatiaList[i])) {
           include = true;
           croatia = croatia.replace(croatiaList[i], ' ');
           result.push(croatiaList[i]);
           break;
       } 
    }
    if(!include) flag = false;
}

croatia = croatia.replaceAll(' ', '').split("");


console.log(result.length+croatia.length);
728x90

+ Recent posts