

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 6
click for more info
Not enough gems
Cost: 6 gems
1: Tries
incomplete
2: Exists
incomplete
3: Prefix Matching
incomplete
4: Words With Prefix
incomplete
5: Find Matches
incomplete
6: Find Matches Review
incomplete
7: Longest Common Prefix
incomplete
8: Advanced Find Matches
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Now that we've built the Trie class, we want to provide an advanced word filter for LockedIn to catch variations of bad words efficiently. For example, if the bad word is 'darn', we want to also filter variations like 'd@rn', 'd4rn', or 'd@rn1t'.
Complete the advanced_find_matches method. It takes an entire document and a dictionary of character variations as input, and should return a set() of all the words in the trie that exist in the document as continuous substrings, even if the word had a variation character instead of the original.
For example, if:
{'@': 'a'}...then "d@rn" should be returned as a match.
The advanced_find_matches method should be very similar to find_matches. Before checking if a character is in the trie, check if that character has a substitution defined in the variations dictionary. If it does, use the substitution character instead of the original.