Last active
July 30, 2017 11:21
-
-
Save linkin-park/4903d7f1488b8a84d37a642c00e3bff2 to your computer and use it in GitHub Desktop.
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
-module(pat_assignment). | |
-export([xOr1/2,xOr2/2,xOr3/2,xOr5/2,maxThree/3,test/0]). | |
xOr1(true,false)->true; | |
xOr1(false,true)->true; | |
xOr1(X,Y)->false. | |
xOr2(true,false)->true; | |
xOr2(false,true)->true; | |
xOr2(_,_)->false. | |
xOr3(X,Y)-> X =/= Y. | |
xOr5(X,Y)-> not(X) == Y. | |
maxThree(X,X,X)-> | |
X; | |
maxThree(X,Y,Z)-> | |
max(max(X,Y),Z). | |
howManyEqual(X,X,X)-> 3; | |
howManyEqual(X,X,_)-> 2; | |
howManyEqual(_,X,X)-> 2; | |
howManyEqual(X,_,X)-> 2; | |
howManyEqual(_,_,_)-> 0. | |
test()-> | |
io:fwrite("~w~n",[howManyEqual(32,32,32)]), | |
io:fwrite("~w~n",[howManyEqual(32,32,45)]), | |
io:fwrite("~w~n",[howManyEqual(48,32,32)]), | |
io:fwrite("~w~n",[howManyEqual(32,48,32)]), | |
io:fwrite("~w~n",[howManyEqual(45,46,48)]). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment