LoginSignup
0
0

More than 1 year has passed since last update.

超絶簡易版wordle

Posted at

超絶簡易版wordleのpythonコード
メモ的な

simplewordle.py
import hashlib

print("please question key")
key = str(input())
#keyはドラクエで言う復活の呪文みたいなもの
#適当な英単語(5文字でなくてもいい)を入力してください

print("guess the word")
guess = str(input())
#guessには回答を英単語5文字で回答してください
#英単語5文字じゃないと多分バグります

wordlist = ["apple","brood","candy","drive","enter"]
#答えになる単語のリスト

hs = hashlib.md5(key.encode()).hexdigest()
hs2 = int(hs,16) % len(wordlist)
answer = wordlist[hs2]

guessls = list(guess)
answerls = list(answer)

ret = ""

for i in range(5):
    if guessls[i] not in answerls :
        ret += "n"
    elif guessls[i] == answerls[i] :
        ret += "g"
    else:
        ret += "y"
#"n"は文字が単語に入ってない、"g"は位置もあっている、"y"は位置は合ってない
#"apple"などの同じ文字が入ってる単語とかの仕様は本家wordleと違うので注意

print(ret)

if ret == "ggggg":
    print("You did it! the answer is " + guess)
0
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
0
0