DEV Community

loading...

Discussion on: Brute-forcing the NPR Sunday Puzzle

Collapse
dimven profile image
Dimitar Venkov

string matching could be another way to compare the names:

from difflib import SequenceMatcher as SM

a, b = 'Eugene Onegin', 'Eugene Oregon'

acceptableRatio = (len(a) - 2) / len(a)

acceptableRatio
Out[4]: 0.8461538461538461

SM(None, a, b).ratio()
Out[5]: 0.8461538461538461