結果

問題 No.423 ハムスター語初級(数詞)
ユーザー wesoweeenwesoweeen
提出日時 2022-08-04 22:19:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 737 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 10,644 KB
実行使用メモリ 7,884 KB
最終ジャッジ日時 2023-10-12 20:30:54
合計ジャッジ時間 1,017 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,840 KB
testcase_01 AC 16 ms
7,828 KB
testcase_02 AC 15 ms
7,792 KB
testcase_03 AC 14 ms
7,884 KB
testcase_04 AC 15 ms
7,772 KB
testcase_05 AC 15 ms
7,740 KB
testcase_06 AC 14 ms
7,824 KB
testcase_07 AC 15 ms
7,780 KB
testcase_08 AC 14 ms
7,792 KB
testcase_09 AC 15 ms
7,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def translate_to_int(ham_lang: str) -> str:
    hamu_replaced = ham_lang.replace("hamu", "1")
    ham_replaced = hamu_replaced.replace("ham", "0")
    return ham_replaced


def to_binary(ham_translated: str) -> str:
    bin_ham = int(ham_translated, 2)
    doubled_bin_ham = bin_ham * 2
    return bin(doubled_bin_ham)


def translate_to_ham(binary_num: str) -> str:
    eliminate_0b = binary_num.replace("0b", "")
    ham_lang = eliminate_0b.replace("1", "hamu").replace("0", "ham")
    return ham_lang


def main():
    ham_lang = input()
    ham_translated = translate_to_int(ham_lang)
    binary_num = to_binary(ham_translated)
    ham_lang = translate_to_ham(binary_num)
    print(ham_lang)


if __name__ == "__main__":
    main()
0