pangram
This commit is contained in:
26
elixir/pangram/lib/pangram.ex
Normal file
26
elixir/pangram/lib/pangram.ex
Normal file
@@ -0,0 +1,26 @@
|
||||
defmodule Pangram do
|
||||
@doc """
|
||||
Determines if a word or sentence is a pangram.
|
||||
A pangram is a sentence using every letter of the alphabet at least once.
|
||||
|
||||
Returns a boolean.
|
||||
|
||||
## Examples
|
||||
|
||||
iex> Pangram.pangram?("the quick brown fox jumps over the lazy dog")
|
||||
true
|
||||
|
||||
"""
|
||||
|
||||
@alphabet Enum.to_list(?A..?Z)
|
||||
|
||||
@spec pangram?(String.t()) :: boolean
|
||||
def pangram?(sentence) do
|
||||
letters =
|
||||
sentence
|
||||
|> String.upcase()
|
||||
|> String.to_charlist()
|
||||
|
||||
@alphabet -- letters == []
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user