Algorithms in Kotlin