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
'Algorithm&CodingTest > Baekjoon' 카테고리의 다른 글
[Baekjoon] [1157] 단어 공부 (0) | 2023.02.09 |
---|---|
[Baekjoon] [4344] 평균은 넘겠지 (0) | 2023.02.09 |
[Baekjoon] [10926] ??! (0) | 2023.02.09 |
[Baekjoon] [18108] 1998년생인 내가 태국에서는 2541년생?! (0) | 2023.02.09 |
[Baekjoon] [25304] 영수증 (0) | 2023.02.09 |