Skip to content

Possible speedup when using n-grams #1

Open
@VitamintK

Description

@VitamintK

Hey lucas! If you're going to use a list of frequent bigrams/trigrams anyways, you don't need to do the first part where you generate all sane permutations of the input string, right?

That is, if you have a list common_ngrams_dict, you could just do

for trigram in common_ngrams_dict:
    if sorted(trigram) == sorted(input_string):
        filtered_solution.append(trigram)

Which would avoid the O(n!) stuff in the first part. I still enjoyed the writeup, and I see how the first part still makes sense cause you'd still want to generate all sane permutations if you use the NLP approach and the anagram isn't a frequent n-gram. 👍

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions