// 방 번호
const filePath = process.platform === "linux" ? "/dev/stdin" : "input.txt";
const input = require("fs")
.readFileSync(filePath)
.toString()
.trim()
.split(/\n/);
const sol = (input) => {
const arr = input[0].split("").map(Number);
const numObj = {
1: 0,
2: 0,
3: 0,
4: 0,
5: 0,
6: 0,
7: 0,
8: 0,
9: 0,
0: 0,
};
arr.map((item) =>
item === 6 || item === 9 ? (numObj[6] += 1) : (numObj[item] += 1)
);
numObj[6] = Math.ceil(numObj[6] / 2);
console.log(Math.max(...Object.values(numObj)));
};
sol(input);
6과 9는 뒤집어 사용할 수 있다는 점만 주의하면 쉽게 풀 수 있다.
'알고리즘 > 백준' 카테고리의 다른 글
[boj 9935] 폭발 문자열-js (0) | 2022.04.06 |
---|---|
[boj 2455] 지능형 기차 (0) | 2022.03.28 |
[boj 14889] 스타트와 링크 (0) | 2022.03.25 |
[boj 14888] 연산자 끼워넣기 -js (0) | 2022.03.24 |
[boj 2675] 문자열 반복 - js (0) | 2022.03.19 |