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
| toques_y_famas [] _ _ = (0,0) | |
| toques_y_famas (n:ns) (x:xs) ys | |
| | n == x = (t,1+f) | |
| | n `elem` ys = (t+1, f) | |
| | otherwise = (t,f) | |
| where (t,f) = (toques_y_famas ns xs ys) |
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
| for ((n,i) <- num.zipWithIndex; (m,j) <- sec.zipWithIndex) | |
| yield if (n == m) if (i == j) 'F' else 'T' |
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
| for (it in accion.withIndex()) { | |
| if (!it.value.isDigit()) | |
| return null | |
| if (it.index >= tam) | |
| return null | |
| } | |
| for ((i,n) in num.withIndex()) | |
| for ((j,m) in sec.withIndex()) | |
| if (n == m) { |
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
| for (i,c) in chars.enumerate() { | |
| if i >= tam { | |
| return nil | |
| } else if c < "0" || c > "9" { | |
| return nil | |
| } else { | |
| let digito = Int(String(c))! | |
| if num.contains(digito) { | |
| return 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
| for (i,c) in accion.chars().enumerate() { | |
| if !c.is_digit(10) { return Error } | |
| else if i >= tam { return Error } | |
| else { | |
| let digito = c.to_digit(10).unwrap(); | |
| if num.contains(&digito) { return Error } | |
| num.push(digito) | |
| } | |
| } |
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
| num := make([]int, 0, tam) | |
| for i, c := range accion { | |
| if !unicode.IsDigit(c) { | |
| return nil | |
| } else if i >= tam { | |
| return nil | |
| } else { | |
| digit := int (c - '0') | |
| for _, d := range num { | |
| if digit == d { return 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
| is_digit(C) when C >= $0, C=<$9 -> true; | |
| is_digit(_) -> false. |
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. |
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
| (defn validar [tam num] | |
| (if (and (solo-digitos num) (largo-esperado tam num)) | |
| (map #(Character/digit % 10) (seq num)) | |
| nil)) |