Flipping bits game: Difference between revisions

→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details
(→‎{{header|Kotlin}}: Removed 'incorrect example' warning as now fixed.)
(→‎{{header|Kotlin}}: Updated example see https://github.com/dkandalov/rosettacode-kotlin for details)
Line 1,795:
}
 
/** starting from the target we make 9 random row or column flips */
fun initBoard() {
for (i in 0..2) {
Line 1,827:
}
return true
}
 
fun main(args: Array<String>) {
Line 1,846:
print("Enter row number or column letter to be flipped: ")
val input = readLine()!!
val ch = if (input.length > 0isNotEmpty()) input[0].toLowerCase() else '0'
if (ch !in "123abc") {
println("Must be 1, 2, 3, a, b or c")
Line 1,853:
if (ch in '1'..'3') {
n = ch.toInt() - 49
}
else {
isRow = false
Line 1,864:
if (isRow) flipRow(n) else flipCol(n)
val plural = if (flips == 1) "" else "S"
printBoard("\nBOARD AFTER $flips FLIP$plural")
}
while (!gameOver())
 
val plural = if (flips == 1) "" else "s"
println("You've succeeded in $flips flip$plural")
}</lang>