Skip to content

Instantly share code, notes, and snippets.

@emadb
Last active August 29, 2015 14:23
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 emadb/8284698bb7e4bfbd730b to your computer and use it in GitHub Desktop.
Save emadb/8284698bb7e4bfbd730b to your computer and use it in GitHub Desktop.
Comp.ex
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
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