Skip to content

Instantly share code, notes, and snippets.

@tambow44
Last active May 12, 2020 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tambow44/4176b709d7184f844a47239af3dc48d5 to your computer and use it in GitHub Desktop.
Save tambow44/4176b709d7184f844a47239af3dc48d5 to your computer and use it in GitHub Desktop.
-module(third).
-export([xor_1/2,xor_2/2,xor_3/2,max_three/3,how_many_equal/3]).
% '=/=' and '==' are the operations for inequality and equality in Erlang
xor_1(X,Y) ->
(X =/= Y)
.
% 'not' is the Erlang negation function
xor_2(X,Y) ->
not (X == Y)
.
% 'and' and 'or' are the Erlang conjunction and disjunction (infix) operators.
xor_3(X,Y) ->
(X =/= Y) and (X or Y)
.
max_three(X,Y,Z) ->
max(max(X, Y), Z)
.
% I had to peek for howManyEqual
% Don't know enough of Erlang to do any "smart" logic
% Specifically how to get stacks working
how_many_equal(X,X,X) -> 3;
how_many_equal(X,_,X) -> 2;
how_many_equal(X,X,_) -> 2;
how_many_equal(_,X,X) -> 2;
how_many_equal(_,_,_) -> 0.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment