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
| 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
| 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
| 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 (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 ((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
| 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
| contar_toques_y_famas(Num,Sec) -> tyf(Num,Sec,Sec). | |
| tyf([],_,_) -> {0,0}; | |
| tyf([HNS|TNS],[HXS|TXS],YS) -> | |
| {T,F} = tyf(TNS,TXS,YS), | |
| if HNS =:= HXS -> {T,F+1}; | |
| HNS =/= HXS -> {T+toque(HNS,YS),F} | |
| end. | |
| toque(X,XS) -> IN = lists:member(X,XS), if IN =:= true -> 1; IN =:= false -> 0 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
| let comparar num sec = | |
| let rec tyf ns xs ys = | |
| match (ns, xs, ys) with | |
| | ([], _, _) -> (0,0) | |
| | (n::ns, x::xs, ys) -> | |
| let (t,f) = tyf ns xs ys | |
| if n = x then (t,f+1) else (if List.exists (fun x -> x = n) ys then (t+1,f) else (t,f)) | |
| tyf num sec sec |
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 gano? [num sec tam] | |
| (let [f (famas num sec) t (- (toques num sec) f)] | |
| (println "tu ingresaste" num) | |
| (println "resultado:" t "Toques, " f "Famas\n") | |
| (= tam f))) |