Skip to content

Instantly share code, notes, and snippets.

@girorme
Last active May 16, 2022 20:54
Show Gist options
  • Save girorme/9c662a2a2e4efc1653881f0115928f11 to your computer and use it in GitHub Desktop.
Save girorme/9c662a2a2e4efc1653881f0115928f11 to your computer and use it in GitHub Desktop.
tdd livebook
defmodule Solution do
def remove_duplicate_chars(string) do
string
|> String.codepoints()
|> Enum.reduce(fn char, acc ->
acc = if String.contains?(acc, char) do
acc
else
acc <> char
end
end)
end
end
ExUnit.start(auto_run: false)
defmodule SolutionTest do
use ExUnit.Case, async: false
describe "Testing remove duplicate chars" do
test "remove a from aaabc" do
assert Solution.remove_duplicate_chars("aaabc") === "abc"
end
end
end
ExUnit.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment