Skip to content

Instantly share code, notes, and snippets.

@fedeisas
Created February 20, 2017 22:00
Show Gist options
  • Save fedeisas/78a31dc047f8e2caf3f9768bcd473f58 to your computer and use it in GitHub Desktop.
Save fedeisas/78a31dc047f8e2caf3f9768bcd473f58 to your computer and use it in GitHub Desktop.
-module(howManyEqual).
-export([howManyEqual/3]).
rm_dup(List) ->
lists:foldl(
fun(Elem, Acc) ->
case lists:member(Elem, Acc) of
true ->
Acc;
false ->
Acc ++ [Elem]
end
end, [], List
).
howManyEqual(X, X, X) ->
3;
howManyEqual(A, B, C) ->
case length(rm_dup([A, B, C])) of
1 -> 3;
2 -> 2;
3 -> 0
end.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment