Skip to content

Instantly share code, notes, and snippets.

@DineshSolanki
Last active November 24, 2020 13:22
Show Gist options
  • Save DineshSolanki/a668ece008e9eec424d681345acec3b7 to your computer and use it in GitHub Desktop.
Save DineshSolanki/a668ece008e9eec424d681345acec3b7 to your computer and use it in GitHub Desktop.
Kotlin Extension function to find index of minimum value of given row of 2D array
fun Array<DoubleArray>.minIndexOfColumnsOfRow(rowNumber: Int): Int {
var minNum = this[0][rowNumber]
var minIndex = 0
repeat(this.size)
{ x ->
if (minNum > this[x][rowNumber]) {
minIndex = x
minNum = this[x][rowNumber]
}
}
return minIndex
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment