Sep-22-2019, 03:22 PM
Hey. Thx for replying!
The file with name "coded" contains permutations of a second file "words", and some random alphanumeric strings that I have to filter.
Its like 'blablah<EOL>', and EOL is stripped so we are left with a clean list of strings in "coded" on the 4th line.
I have tried to operate on the alphabetic level but it takes ages just to show me all possible permutations of strings in file 'coded' to compare it:
If ascii sum of string is the same then and only then it will compare the letters.I thought it would be nice and handy for a start to get a dict like "word" : "summed ascii value" but Im stuck here, somehow I cant make a dict like that.
The file with name "coded" contains permutations of a second file "words", and some random alphanumeric strings that I have to filter.
Its like 'blablah<EOL>', and EOL is stripped so we are left with a clean list of strings in "coded" on the 4th line.
I have tried to operate on the alphabetic level but it takes ages just to show me all possible permutations of strings in file 'coded' to compare it:
# coding=utf-8 import os, itertools coded, words = open("scrambled-words.txt", "r", encoding="UTF-8"), open("dictionary.txt", encoding="UTF-8") coded, words = [x.strip('\n') for x in coded], [x.strip('\n') for x in words] def unmask(coded, words): perms = [] for x in coded: perms = ([''.join(x) for x in itertools.permutations(x)]) print(*perms, sep="\n") unmask(coded, words)So my idea is to check it on a binary level and thats what funciton binary_ops is about.
If ascii sum of string is the same then and only then it will compare the letters.I thought it would be nice and handy for a start to get a dict like "word" : "summed ascii value" but Im stuck here, somehow I cant make a dict like that.