Skip to content

Instantly share code, notes, and snippets.

@h-j-13
Created March 22, 2025 12:09
Show Gist options
  • Select an option

  • Save h-j-13/03141d841a13a51b89198648115b0ac1 to your computer and use it in GitHub Desktop.

Select an option

Save h-j-13/03141d841a13a51b89198648115b0ac1 to your computer and use it in GitHub Desktop.
keep talking nobody explodes 密码猜测模块工具
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# keep talking nobody explodes 密码猜测模块工具
import re
# 初始单词列表
words = [
"about",
"after",
"again",
"below",
"could",
"every",
"first",
"found",
"great",
"house",
"large",
"learn",
"never",
"other",
"place",
"plant",
"point",
"right",
"small",
"sound",
"spell",
"still",
"study",
"their",
"there",
"these",
"thing",
"think",
"three",
"water",
"where",
"which",
"world",
"would",
"write",
]
def get_possible_words(words, pattern):
# 使用正则表达式匹配可能的单词
regex = re.compile(pattern, re.IGNORECASE)
return [word for word in words if regex.match(word)]
def main():
possible_words = words.copy()
for i in range(5):
print(f"请输入第 {i + 1} 个字符的可能字母(例如 'abcde' 或 'ABCDE'):")
allowed_chars = input().strip().lower()
# 构建正则表达式模式
pattern = "^" + "." * i + f"[{allowed_chars}]" + "." * (4 - i) + "$"
# 获取可能的单词
possible_words = get_possible_words(possible_words, pattern)
if not possible_words:
print("没有匹配的单词。")
return
if len(possible_words) == 1:
print(f">>> 匹配到的单词是: {possible_words[0]}")
return
print(f"当前可能的单词有: {possible_words}")
print(f"最终可能的单词有: {possible_words}")
if __name__ == "__main__":
print("============= keep talking nobody explodes [密码模块] =============")
while 1:
print(">>> 猜测开始, 请按照提示输入从左到右依次输出每个位置可能出现的所有字符")
main()
print(">>> 猜测结束 \n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment