Created
March 19, 2019 05:42
-
-
Save marocchino/81b9d75708fdab6a312ba7e483e1df0a to your computer and use it in GitHub Desktop.
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
ExUnit.start() | |
ExUnit.configure(exclude: :pending, trace: true) | |
defmodule CostTest do | |
use ExUnit.Case | |
def cost([]), do: 0 | |
def cost([_last]), do: 0 | |
def cost([current | [next | tail]]) do | |
Enum.min([current + cost([next | tail]), next + cost(tail)]) | |
end | |
test "1" do | |
assert cost([10, 15, 20]) == 15 | |
end | |
test "2" do | |
assert cost([1, 100, 1, 1, 1, 100, 1, 1, 100, 1]) == 6 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment