Bulls and cows: Difference between revisions
→{{header|Kotlin}}
Not a robot (talk | contribs) (Add ABC) |
|||
(3 intermediate revisions by the same user not shown) | |||
Line 4,176:
=={{header|Kotlin}}==
<syntaxhighlight lang="
const val MAX_GUESSES = 20 // say
fun main(
val num = ('1'..'9').shuffled().take(4).joinToString("")
println("All guesses should have exactly 4 distinct digits excluding zero.")
Line 4,195 ⟶ 4,188:
while (true) {
print("Enter your guess : ")
val guess =
if (guess == num) {
println("You've won with ${++guesses} valid guesses!")
}
val n = guess.toIntOrNull()
Line 4,247 ⟶ 4,240:
You've won with 9 valid guesses!
</pre>
=={{header|Lasso}}==
This game uses an HTML form to submit the answer. The random number and history are stored in a session using Lasso's built in session management.
|