///////////////////////////////// No.423 ハムスター語初級(数詞) //入力文字読み取り var inputall = require('fs').readFileSync('/dev/stdin', 'utf8'); while (inputall.indexOf("hamu", 0) != -1&&inputall.indexOf("ham", 0) != -1) { inputall = inputall.replace("ham", 0); inputall = inputall.replace("hamu", 1); } //数値化 inputall = Number(inputall); //2進数を10進数へ変換 inputall = parseInt(inputall, 2); //10進数を2倍 inputall = inputall * 2; //10進数を2進数へ inputall = inputall.toString(2) while (inputall.indexOf("1", 0) != -1) { inputall = inputall.replace("1", "hamu"); } while (inputall.indexOf("0", 0) != -1) { inputall = inputall.replace(0, "ham"); } console.log(inputall)