Compare two anagrams

functions that return a boolean seem to end with an ?
This commit is contained in:
Nathan Mattes 2021-09-22 10:55:26 +02:00
parent ff8cd2798a
commit 193d58827f
1 changed files with 6 additions and 1 deletions

View File

@ -4,7 +4,12 @@ defmodule StringsAndBinaries do
end
def custom_ascii_printable?(char_list) do
# every character in char list must between 20hex 32 and 126
# every character in char list must between 32 and 126
Enum.all?(char_list, &( 32 <= &1 and &1 <= 126))
end
def anagram?(word1, word2) do
# An anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once.
Enum.sort(String.to_charlist(word1)) == Enum.sort(String.to_charlist(word2))
end
end