Created
April 25, 2022 22:21
-
-
Save gonaumov/4b90c10bd5cc9f42516da2955c5ca284 to your computer and use it in GitHub Desktop.
Russian roulette with Kotlin
This file contains hidden or 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
package com.company | |
fun main() { | |
for ((index, shot) in BooleanArray(6) { false }.apply { | |
this[(0 until this.size).random()] = true | |
this.shuffle() | |
}.withIndex()) { | |
if (shot) { | |
println("Iteration ${index + 1}. You are dead ..") | |
break | |
} | |
println("Iteration ${index + 1}. Still alive ..") | |
Thread.sleep(1000) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment