Realm
gno.land/r/g12cs4cehujpffpjpywmkqj43m6u5ya53nj69sjz/levenshtein
Rendered output
Levenshtein edit distance
The Levenshtein distance between two strings is the minimum number of single-character edits — insertions, deletions, or substitutions — needed to turn one string into the other. This realm reimplements the classic dynamic-programming algorithm (à la Go's agext/levenshtein) fully rune-aware and on-chain.
Try it
Append two words as /<a>/<b>:
/kitten/sitting→ distance 3/flaw/lawn→ distance 2/sunday/saturday→ distance 3/gno/gnoland→ distance 4
The classic example
kitten → sitting = 3:
kitten→sitten(substitute k → s)sitten→sittin(substitute e → i)sittin→sitting(insert g at the end)
API
Distance(a, b string) int— the edit distance.Matrix(a, b string) [][]int— the full DP matrix.Similarity(a, b string) int— a 0..100 similarity percentage.
Query (read-only)
non-crossing functions · no tx, no wallet neededDistance(a string, b string) → int
Matrix(a string, b string) → [][]int
Similarity(a string, b string) → int
All exported functions (4)
show raw signatures
| Name | Params | Returns |
|---|---|---|
| Distance | [{"Name": "a", "Type": "string", "Value": ""}, {"Name": "b", "Type": "string", "Value": ""}] | [{"Name": ".res.0", "Type": "int", "Value": ""}] |
| Matrix | [{"Name": "a", "Type": "string", "Value": ""}, {"Name": "b", "Type": "string", "Value": ""}] | [{"Name": ".res.0", "Type": "[][]int", "Value": ""}] |
| Similarity | [{"Name": "a", "Type": "string", "Value": ""}, {"Name": "b", "Type": "string", "Value": ""}] | [{"Name": ".res.0", "Type": "int", "Value": ""}] |
| Render | [{"Name": "path", "Type": "string", "Value": ""}] | [{"Name": ".res.0", "Type": "string", "Value": ""}] |
Files
Storage
{
"raw": "storage: 7306, deposit: 730600"
}