Skip to content

Instantly share code, notes, and snippets.

@NurseyitTursunkulov
Created March 1, 2018 07:27
Show Gist options
  • Save NurseyitTursunkulov/3deec959ac0d776073cd50cadc9cca0b to your computer and use it in GitHub Desktop.
Save NurseyitTursunkulov/3deec959ac0d776073cd50cadc9cca0b to your computer and use it in GitHub Desktop.
Test1
var count = 0
fun main(args: Array<String>) {
getKardsFromUser()
val kards = getKardsFromUser()
howManyTimesVasyaLookedKards(kards)
println(count)
}
fun howManyTimesVasyaLookedKards(kards: MutableList<Int>) {
var firstKard = kards.first()
if (firstKard == kards.min()) {
kards.remove(firstKard)
++count
} else {
kards.remove(firstKard)
kards.add(firstKard)
++count
}
if (!kards.isEmpty()) {
howManyTimesVasyaLookedKards(kards)
}
}
private fun getKardsFromUser(): MutableList<Int> {
return readLine()!!.split(' ').map(String::toInt) as MutableList<Int>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment