Data update
This commit is contained in:
parent
0df55f9f24
commit
aec8ed51b6
1045 changed files with 18889 additions and 2777 deletions
|
|
@ -1,26 +1,17 @@
|
|||
// version 1.1.2
|
||||
|
||||
import java.util.Random
|
||||
|
||||
const val MAX_GUESSES = 20 // say
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val r = Random()
|
||||
var num: String
|
||||
// generate a 4 digit random number from 1234 to 9876 with no zeros or repeated digits
|
||||
do {
|
||||
num = (1234 + r.nextInt(8643)).toString()
|
||||
} while ('0' in num || num.toSet().size < 4)
|
||||
fun main() {
|
||||
val num = ('1'..'9').shuffled().take(4).joinToString("")
|
||||
|
||||
println("All guesses should have exactly 4 distinct digits excluding zero.")
|
||||
println("Keep guessing until you guess the chosen number (maximum $MAX_GUESSES valid guesses).\n")
|
||||
var guesses = 0
|
||||
while (true) {
|
||||
print("Enter your guess : ")
|
||||
val guess = readLine()!!
|
||||
val guess = readln().trim()
|
||||
if (guess == num) {
|
||||
println("You've won with ${++guesses} valid guesses!")
|
||||
return
|
||||
break
|
||||
}
|
||||
val n = guess.toIntOrNull()
|
||||
if (n == null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue