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
enum class Team { | |
RED, | |
BLACK, | |
EMPTY; | |
override fun toString(): String = when (this) { | |
RED -> "R" | |
BLACK -> "B" | |
EMPTY -> "O" | |
} |
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
enum class Team { | |
RED, | |
BLACK, | |
EMPTY; | |
override fun toString(): String = when (this) { | |
RED -> "R" | |
BLACK -> "B" | |
EMPTY -> "O" | |
} |
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
import java.util.Random; | |
fun pickRandomPercentage(counts: Array<Pair<Int, Int>>): Int { | |
val total = counts.sumBy { src -> src.second } | |
println("Total: ${total}") | |
var random = Random().nextInt(total) + 1 // Random inclusive between 1 and total | |
for ((value, count) in counts) { | |
println("Random: ${random} Value: ${value} Count ${count}") |