Last active
August 29, 2015 14:23
-
-
Save emadb/8284698bb7e4bfbd730b to your computer and use it in GitHub Desktop.
Comp.ex
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
defmodule Comp do | |
def check([h|t], b) do | |
check(t, List.delete(b, h*h)) | |
end | |
def check(_,[]), do: true | |
def check([], b), do: false | |
end |
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
defmodule CompTest do | |
use ExUnit.Case | |
test "Lists match" do | |
a = [121, 144, 19, 161, 19, 144, 19, 11] | |
b = [121, 14641, 20736, 361, 25921, 361, 20736, 361] | |
result = Comp.check(a, b) | |
assert result == true | |
end | |
test "Lists don't match" do | |
a = [121, 144, 19, 161, 19, 144, 19, 11] | |
b = [132, 14641, 20736, 361, 25921, 361, 20736, 361] | |
result = Comp.check(a, b) | |
assert result == false | |
end | |
test "List don't match" do | |
a = [121, 144, 19, 161, 19, 144, 19, 11] | |
b = [121, 14641, 20736, 36100, 25921, 361, 20736, 361] | |
result = Comp.check(a, b) | |
assert result == false | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment