Skip to content

Instantly share code, notes, and snippets.

Last active Jul 16, 2020
What would you like to do?
Solves the 'password' puzzle in Keep Talking And Nobody Explodes
#!/usr/bin/env python3
Solves the 'password' puzzle in Keep Talking And Nobody Explodes.
$ ktane-passwords ahiwx tpcri
The answer is WRITE 😅
$ ktane-passwords oglwqm oxanbe wvnrke
Multiple possible answers! 😬 ['large', 'world']
$ ktane-passwords oglwqm oxanbe wvnkex
Something is wrong, no matches 😰
$ ktane-passwords '*' oxanbe wvnrke xudkbl
The answer is WORLD 😅
__author__ = "Chris Danis"
__email__ = ""
__license__ = "MIT"
import argparse
import itertools
import string
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',
p = argparse.ArgumentParser(
p.add_argument('letters', nargs='+',
help='The letters from each column, for example: ahiwx tpcri \n'
'You may also use * to allow any letter in that column, \n'
'useful if you missed the first column.')
args = p.parse_args()
for (idx, column) in enumerate(args.letters):
if column == '*':
args.letters[idx] = string.ascii_lowercase
all_letter_combos = [''.join(x) for x in itertools.product(*args.letters)]
candidates = [w for w in words for L in all_letter_combos if w.startswith(L)]
if not candidates:
print("Something is wrong, no matches 😰")
elif len(candidates) == 1:
print(f"The answer is {candidates[0].upper()} 😅")
print(f"Multiple possible answers! 😬 {candidates}")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment