1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

エセ関西弁アナグラム

Posted at

###作りました
クソ診断をしていると,毎日クソみたいなポストをする必要があるので自動化しようかなと思いひな型を作りました.

import random

def inv_dict(d):
    return {v:k for k,v in d.items()}

ese = {"":1, "":2, "":3, "西":4, "":5}
mahi = {"":1, "":2, "":3, "":4, "":5}
inv_ese = inv_dict(ese)
inv_mahi = inv_dict(mahi)

instr = ""    #将来的にはAPIで自動取得
for i in range(5):
    i = random.randrange(4)+1
    instr += inv_ese[i+1]
print(instr)

outstr= ""
for txt in list(instr):
    outstr += inv_mahi[ese[txt]]
print(outstr)

if instr == "エセ関西弁":
    print("Congratulations!!")

###なんでこんなものを組んだのか,それが分からない

関弁西西セ
ひき好好っ

一応成功.
逆引き用の辞書しか使ってないやんけ!という印象.
将来的には自動取得するつもりですが,現時点では自分で診断結果を作ってるからただの自作自演.

不正して
「エセ関西弁」って投稿したら
彼は気がついてくれるのだろうか?

こういう人もいるので,ネイティブな結果をリダイレクトして走るコマンドも考えておく必要がありますね.

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?