Skip to main content
cracked
Source Link
CursorCoercer
  • 4.8k
  • 10
  • 20

Edit Distance, Python 3.8 (pre-release), 124 bytes, \$O(mn)\$ complexity, cracked by SuperStormer

(I won't bother trying to score since I had to edit my answer and the scoring system was flawed)

lambda a,b:(d:=range(len(b)+1),[d:=[x:=d[(j:=0)]+1]+[x:=min(x+1,d[(j:=j+1)]+1,d[j-1]+(i!=k))for k in b]for i in a])and d[-1]

Try it online!

Ya like walrus operators?

Complexity is \$O(mn)\$ where m,n are the lengths of the two input strings.
Time: 2023-07-20 16:18:22Z

Edit Distance, Python 3.8 (pre-release), 124 bytes, \$O(mn)\$ complexity

lambda a,b:(d:=range(len(b)+1),[d:=[x:=d[(j:=0)]+1]+[x:=min(x+1,d[(j:=j+1)]+1,d[j-1]+(i!=k))for k in b]for i in a])and d[-1]

Try it online!

Ya like walrus operators?

Complexity is \$O(mn)\$ where m,n are the lengths of the two input strings.
Time: 2023-07-20 16:18:22Z

Edit Distance, Python 3.8 (pre-release), 124 bytes, \$O(mn)\$ complexity, cracked by SuperStormer

(I won't bother trying to score since I had to edit my answer and the scoring system was flawed)

lambda a,b:(d:=range(len(b)+1),[d:=[x:=d[(j:=0)]+1]+[x:=min(x+1,d[(j:=j+1)]+1,d[j-1]+(i!=k))for k in b]for i in a])and d[-1]

Try it online!

Ya like walrus operators?

Complexity is \$O(mn)\$ where m,n are the lengths of the two input strings.
Time: 2023-07-20 16:18:22Z

corrected test case and saved a byte
Source Link
CursorCoercer
  • 4.8k
  • 10
  • 20

Edit Distance, Python 3.8 (pre-release), 125124 bytes, \$O(mn)\$ complexity

lambda a,b:(d:=range(len(b)+1),[d:=[x:=d[(j:=0)]+1]+[x:=min(x+1,d[(j:=j+1)]+1,d[j-1]+(i!=k))for k in b]for i in a])and min(d)d[-1]

Try it online!Try it online!

Ya like walrus operators?

Complexity is \$O(mn)\$ where m,n are the lengths of the two input strings.
Time: 2023-07-20 16:18:22Z

Edit Distance, Python 3.8 (pre-release), 125 bytes, \$O(mn)\$ complexity

lambda a,b:(d:=range(len(b)+1),[d:=[x:=d[(j:=0)]+1]+[x:=min(x+1,d[(j:=j+1)]+1,d[j-1]+(i!=k))for k in b]for i in a])and min(d)

Try it online!

Ya like walrus operators?

Complexity is \$O(mn)\$ where m,n are the lengths of the two input strings.
Time: 2023-07-20 16:18:22Z

Edit Distance, Python 3.8 (pre-release), 124 bytes, \$O(mn)\$ complexity

lambda a,b:(d:=range(len(b)+1),[d:=[x:=d[(j:=0)]+1]+[x:=min(x+1,d[(j:=j+1)]+1,d[j-1]+(i!=k))for k in b]for i in a])and d[-1]

Try it online!

Ya like walrus operators?

Complexity is \$O(mn)\$ where m,n are the lengths of the two input strings.
Time: 2023-07-20 16:18:22Z

Source Link
CursorCoercer
  • 4.8k
  • 10
  • 20

Edit Distance, Python 3.8 (pre-release), 125 bytes, \$O(mn)\$ complexity

lambda a,b:(d:=range(len(b)+1),[d:=[x:=d[(j:=0)]+1]+[x:=min(x+1,d[(j:=j+1)]+1,d[j-1]+(i!=k))for k in b]for i in a])and min(d)

Try it online!

Ya like walrus operators?

Complexity is \$O(mn)\$ where m,n are the lengths of the two input strings.
Time: 2023-07-20 16:18:22Z