X
X
xmoonlight2020-01-13 11:08:20
JavaScript
xmoonlight, 2020-01-13 11:08:20

How to search for misspelled anagrams?

Let's say there are anagram words:
AABB = ABAB, ABBA, BBAA
Now some of them are misspelled:
AABB ~= ABAB, ABBB, BDAC Misprint
percentages (relative to AABB): 0%, 25%, 50%.
According to the error threshold exceeding 25%, we filter out only the last word: BDAC.
That is, it will be so.
Acceptable error threshold is 25% (1 error per 4 characters):
AABB ~= ABAB, ABBB
(this is the final result)
Question:
How to detect anagrams as quickly as possible if the words contain one or more typos with the desired error threshold?
The length of words - can be any, the percentage of typos - can be set arbitrarily.
UPD: Examples of typos (comparison of anagrams and number of typos):
AABB and AAB => 1 (missing character)
AABB and AABBA => 1 (extra "own" character)
AABB and AABBC => 2 (extra "foreign" character)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
twobomb, 2020-01-13
@xmoonlight

https://jsfiddle.net/twobomb/eLnpcu9x/

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question