Skip to content

Instantly share code, notes, and snippets.

@scull7
Last active February 22, 2017 07:42
Show Gist options
  • Save scull7/9c03bb674acdb3c2ecf163a775ba06f4 to your computer and use it in GitHub Desktop.
Save scull7/9c03bb674acdb3c2ecf163a775ba06f4 to your computer and use it in GitHub Desktop.
-module(one_fifteen).
-export([xor1/2,xor2/2,xor3/2,maxThree/3,howManyEqual/3]).
-export([all/0,xor2_true_false/1]).
xor1(X,Y) ->
X =/= Y.
xor2(X,Y) ->
not (X and Y).
xor3(X,Y) ->
not X == Y.
maxThree(X,X,X) ->
X;
maxThree(X,X,Y) ->
max(X,Y);
maxThree(X,Y,Y) ->
max(X,Y);
maxThree(X,Y,Z) ->
max(max(X,Y),Z).
howManyEqual(X,X,X) ->
3;
howManyEqual(X,X,_) ->
2;
howManyEqual(_,Y,Y) ->
2;
howManyEqual(X,_,X) ->
2;
howManyEqual(_,_,_) ->
0.
%% Common Test, Test Suite
all() -> [xor2_true_false].
xor2_true_false(_Config) ->
case xor2(true,false) of
true -> ok;
X -> ct:fail({xor2_true_false_failed, X})
end.
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment