Created
March 1, 2018 07:27
-
-
Save NurseyitTursunkulov/3deec959ac0d776073cd50cadc9cca0b to your computer and use it in GitHub Desktop.
Test1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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