噢,自动-正确。
你有话要说。但这是错误的。你想知道那是什么词。谢天谢地,作为一个代码高尔夫球手,你可以做一个代码来粗略猜测。
您将得到一个(错误的,全部小写)单词和一个“(全小写)字典列表)”。您必须以最小的Levenshtein距离输出到错误的单词。如果有相同的levenshtein距离的多个单词,请使用列表中的最后一个。
Input => Output
(["apple", "banana", "orange", "pineapple"], "baenanae") => "banana"
(["zeal", "zealot", "zealotry", "zealots", "zealous", "zealously", "zealousness"], "zealousl") => "zealously"
(["abductors", "abducts", "abe", "abeam", "abel"], "") => "abe"发布于 2017-09-10 04:53:53
Σ.L(}¤在网上试试! (注意:对于空字符串情况,输入上的尾换行符是必需的)。
Σ.L(}¤ - implicitly push the first input (the dictionary list)
Σ } - sort the list by:
- implicitly push second input (the misspelled word)
.L - Levenshtein distance
( - negated
¤ - tail the sorted list and place the entry on the top of the stack
- implicitly print top of stack发布于 2017-09-10 05:13:37
lambda m,s:min({levenshtein(x,s):x for x in m}.items())[1]
from pylev import*https://codegolf.stackexchange.com/questions/142304
复制相似问题