Skip to content

Instantly share code, notes, and snippets.

enum class Team {
RED,
BLACK,
EMPTY;
override fun toString(): String = when (this) {
RED -> "R"
BLACK -> "B"
EMPTY -> "O"
}
enum class Team {
RED,
BLACK,
EMPTY;
override fun toString(): String = when (this) {
RED -> "R"
BLACK -> "B"
EMPTY -> "O"
}
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}")