What is the chance of it coming across 'HELLO' :la...
# announcements
t
What is the chance of it coming across 'HELLO' 😆:
Copy code
while (true) {
        val string = randomCharGenerator(5)
        println(string)

        if (string == "HELLO") {
            println("HELLO FOUND")
            break
        }
    }
}

fun randomCharGenerator(length: Int): String {
    val chars = listOf('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z')

    var string = ""

    var length2 = length
    while (length2 != 0) {
        string += chars[kotlin.random.Random.nextInt(0, chars.size)]
        length2--
    }

    return string
}