HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
📝
프론트엔드 스쿨 교안(1기)
/
📝
(코테준비) 자료구조 및 알고리즘
/
✌
JS 100제 - 2권
/
🔥
문제75
/
✔️
답안
✔️

답안

function sol(n){ let answer = 0; let count = 1; const d = {3 : 1, 6 : 2, 9 : 3}; while (n.length !== 0){ answer += d[parseInt(n.pop(), 10)] * count; count *= 3; } return answer; } const user_input = new String(prompt('입력해주세요')).split(''); console.log(sol(user_input));