def test_08(): """ 08. 暗号文 与えられた文字列の各文字を,以下の仕様で変換する関数cipherを実装せよ. 英小文字ならば(219 - 文字コード)の文字に置換 その他の文字はそのまま出力 この関数を用い,英語のメッセージを暗号化・復号化せよ. """ text = "I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind ." print(nlp100.solve_09(text))
def test_09(): """ 09. Typoglycemia スペースで区切られた単語列に対して,各単語の先頭と末尾の文字は残し,それ以 外の文字の順序をランダムに並び替えるプログラムを作成せよ.ただし,長さが4以下の 単語は並び替えないこととする.適当な英語の文 (例えば "I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind .") を与え,その実行結果を確認せよ. """ text = "I couldn't believe that I could actually understand what I was reading : the phenomenal power of the human mind ." for word1, word2 in zip(text.split(), nlp100.solve_09(text).split()): assert word1[0] == word2[0] assert word1[-1] == word2[-1] assert len(word1) == len(word2)