結果
問題 |
No.423 ハムスター語初級(数詞)
|
ユーザー |
![]() |
提出日時 | 2022-08-04 22:19:41 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 2,000 ms |
コード長 | 737 bytes |
コンパイル時間 | 155 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-09-14 18:52:11 |
合計ジャッジ時間 | 1,157 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 9 |
ソースコード
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()