This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if i >= tam { | |
| return nil | |
| } else if c < "0" || c > "9" { | |
| return nil | |
| } else { | |
| ... | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if !c.is_digit(10) { return Error } | |
| else if i >= tam { return Error } | |
| else { ... } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def validar(tam:Int, accion:String) : Option[Array[Int]] = | |
| if (accion.exists(!_.isDigit)) | |
| None | |
| else { | |
| val num = accion.map(_.toInt - '0'.toInt).distinct | |
| if (num.length == tam && num.length == accion.length) | |
| Some(num.toArray) | |
| else | |
| None | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let validar tam accion = | |
| let cars = [for c in accion -> c] | |
| if List.exists (fun c -> not (Char.IsDigit c)) cars then List.empty<int> | |
| else | |
| let org = List.map (fun c -> (int c) - (int '0')) cars | |
| let num = List.distinct org | |
| if (List.length org <> List.length num) || (List.length num <> tam) then List.empty<int> | |
| else num |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (!it.value.isDigit()) | |
| return null | |
| if (it.index >= tam) | |
| return null | |
| else { | |
| val digit = it.value.toInt() - '0'.toInt() | |
| if (digit in num) return null | |
| num = num.plus(digit) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| validar n xs | |
| | length num /= n = [] | |
| | otherwise = num | |
| where num = if not (all isDigit xs) then [] else remover_dups xs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn validar [tam num] | |
| (if (and (solo-digitos num) (largo-esperado tam num)) | |
| (map #(Character/digit % 10) (seq num)) | |
| nil)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (defn validar [tam num] | |
| (if (and (every? #(Character/isDigit %) num)) | |
| (let [cuenta-unicos (count (distinct num))] | |
| (and | |
| (= tam cuenta-unicos) | |
| (= (count num) cuenta-unicos))))) | |
| (map #(Character/digit % 10) (seq num)) | |
| nil)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Digitos = lists:all(fun (X) -> is_digit(X) end, Entrada), | |
| if Digitos =:= true -> unicos(to_num(Entrada), Tam, Len) ; | |
| Digitos =:= false -> [] end. |