Open neuroretransmit opened 7 months ago
An idea for that:
IMPOSSIBLE_BIGRAMS = ["JQ", "QG", "QK", "QY", "QZ", "WQ", "WZ"]
def generate_permutations(plaintext):
# ...
permutations = [permutation for permutation in permutations if not any(bigram in permutation for bigram in IMPOSSIBLE_BIGRAMS)]
return permutations
for later:
from itertools import permutations
IMPOSSIBLE_BIGRAMS = ["JQ", "QG", "QK", "QY", "QZ", "WQ", "WZ"]
def generate_permutations(plaintext):
# generate all possible permutations of the input text
perms = [''.join(p) for p in permutations(plaintext)]
# filter
filtered_perms = [perm for perm in perms if not any(bigram in perm for bigram in IMPOSSIBLE_BIGRAMS)]
return filtered_perms
# just an example
plaintext = "ING"
permutations = generate_permutations(plaintext)
print(permutations)
The following are impossible bigrams: ["JQ", "QG", "QK", "QY", "QZ", "WQ", "WZ"]
When permutations mode is implemented (fixing things like using NG where ING should be by permitting the plaintext to a list with possibilities for multi-character/bigram runes), if a candidate contains these, remove it from the list