Last active
February 22, 2017 07:42
-
-
Save scull7/9c03bb674acdb3c2ecf163a775ba06f4 to your computer and use it in GitHub Desktop.
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
-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