Bulls and cows: Difference between revisions
Content added Content deleted
Line 4,182: | Line 4,182: | ||
fun main() { |
fun main() { |
||
// generate a 4 digit random number from 1234 to 9876 with no zeros or repeated digits |
// generate a 4 digit random number from 1234 to 9876 with no zeros or repeated digits |
||
val num: String = |
val num: String = |
||
generateSequence { (1234..9876).random().toString() } |
|||
.first { '0' !in it && it.toSet().size == 4 } |
|||
} |
|||
println("All guesses should have exactly 4 distinct digits excluding zero.") |
println("All guesses should have exactly 4 distinct digits excluding zero.") |