Skip to content

Instantly share code, notes, and snippets.

@TheEndIsNear
Created May 6, 2020 16:16
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 TheEndIsNear/caa75cb9e83eb97b51ff547e0470a413 to your computer and use it in GitHub Desktop.
Save TheEndIsNear/caa75cb9e83eb97b51ff547e0470a413 to your computer and use it in GitHub Desktop.
-module(homework).
-export([xOr1/2, xOr2/2,xOr3/2, maxThree/3,howManyEqual/3]).
% three ways to represent xOr.
xOr1(X, Y) ->
not X == Y.
xOr2(X, Y) ->
X =/= Y.
xOr3(X, Y) ->
(X and not Y) or (not X and Y).
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment