Create a gist now

Instantly share code, notes, and snippets.

Otra forma de implementar validar
def validar(tam:Int, accion:String) : Option[Array[Int]] =
if (accion.exists(c => !c.isDigit) None
else {
val num = accion.map(c => c.toInt - '0'.toInt).distinct
if (num.length == tam && num.length == accion.length)
Some(num.toArray)
else
None
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment