Skip to content

Instantly share code, notes, and snippets.

View glureau's full-sized avatar
🏡

Grégory Lureau glureau

🏡
View GitHub Profile
@glureau
glureau / levenshtein.kt
Created April 28, 2025 09:11 — forked from ademar111190/levenshtein.kt
Levenshtein Distance algorithm implementation using Kotlin
import kotlin.math.min
fun levenshtein(lhs : CharSequence, rhs : CharSequence) : Int {
if(lhs == rhs) { return 0 }
if(lhs.isEmpty()) { return rhs.length }
if(rhs.isEmpty()) { return lhs.length }
val lhsLength = lhs.length + 1
val rhsLength = rhs.length + 1