object Main extends App {
def isRAsync (str: String): Boolean = {
if (str.length < 2) false
else {
val numbers = Map(
'0' -> '0',
'1' -> '1',
'6' -> '9',
'8' -> '8',
'9' -> '6'
)
var isAsync = true
for (i <- 0 until str.length/2) {
val ch = str.charAt(i)
numbers.isDefinedAt(ch) match {
case true => if (ch != str.charAt(str.length-i-1) && numbers(ch) != str.charAt(str.length-i-1)) isAsync=false
case false => if (ch != str.charAt(str.length-i-1)) isAsync=false
}
}
isAsync
}
}
println(isRAsync("121121"))
}