Created
January 12, 2016 02:15
-
-
Save lnds/297bfd90aef441a0641c to your computer and use it in GitHub Desktop.
toques y famas en erlang
This file contains 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. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment