Input
A binary string \$s\$ of length \$n\$ and a positive integer \$k \leq n\$.
Output
The number of binary strings with Levenshtein distance exactly \$k\$ from the string \$s\$.
Example outputs
Each example gives the largest possible output for the given \$(n, k)\$ pair.
k=1, s=1010, output=14
k=2, s=1010, outupt=55
k=3, s=1101, output=112
k=4, s=1001, output=229
k=1, s=1010101010, output=32
k=2, s=1010110101, output=362
k=3, s=1010110101, output=2016
k=4, s=1011001101, output=6538
k=5, s=1011001101, output=16223
k=6, s=1001100110, output=37620
k=7, s=1001100110, output=85028
k=8, s=1001100110, output=187667
k=9, s=1001100110, output=406183
k=10, s=1001100110, output=864793
k=1, s=101010101010, output=38
k=2, s=101010010101, output=533
k=3, s=101010010101, output=3804
k=4, s=101001100101, output=15708
k=5, s=101100110010, output=45717
Score
The score will be the highest \$n, k\$ pair your code outputs the correct answer for on my Ubuntu desktop in one minute. The order should be (1,1), (2,1), (2,2), (3,1),(3,2), (3,3), (4,1), (4,2), (4,3), (4,4), (5,1) etc. The time is the total running time and not just for the last pair.
Your code should work for all strings but I will time it using random binary strings.
As always, this is a competition per language so Python coders don't need to worry about C competitors.
Leaderboard
- (28, 23) in Rust by Anders Kaseorg
- (12, 11) in Rust by corvus_192.
- (12, 10) in Pypy by Jonathan Allen.
- (11, 10) in Pypy by Value Ink.
- (11, 9) in Python by Value Ink.
- (11, 9) in Python by Jonathan Allen.
- (7,6) in Charcoal by Neil.
Edit
I noticed this related question which has a link that suggests there is a fast algorithm