Let's make sure people can't run levenshtein (an O(n**3) algorithm) on large inputs. I gave it to lambdaman almost 10 minutes ago and it's still not finished.

This commit is contained in:
Jeremy Fincher 2004-08-10 07:42:38 +00:00
parent 2259e9d8b6
commit ad0ffd2752

View File

@ -290,7 +290,11 @@ class Fun(callbacks.Privmsg):
between <string1> and <string2>)
"""
(s1, s2) = privmsgs.getArgs(args, required=2)
irc.reply(str(utils.distance(s1, s2)))
if len(s1) > 512 or len(s2) > 512:
irc.error('Levenshtein distance is a complicated algorithm, try '
'it with some smaller inputs.')
else:
irc.reply(str(utils.distance(s1, s2)))
def soundex(self, irc, msg, args):
"""<string> [<length>]