Mix.install([
{:youtube, github: "brooklinjazz/youtube"},
{:hidden_cell, github: "brooklinjazz/hidden_cell"},
{:tested_cell, github: "brooklinjazz/tested_cell"},
{:utils, path: "#{__DIR__}/../utils"}
])
A word or sentence that reads the same way forwards and backwards is a palindrome. For example kayak and racecar are palindromes.
You're going to create a Palindrome
module which can determine if a string is a palindrome.
Palindrome.palindrome?("kayak")
true
Example Solution
defmodule Palindrome do
def palindrome?(string) do
string
|> String.split("")
|> Enum.reverse()
|> Enum.join() == string
end
end
Implement the Palindrome
module as documented below.
defmodule Palindrome do
@moduledoc """
Documentation for `Palindrome`.
"""
@doc """
Determine if two strings are anagrams.
## Examples
iex> Palindrome.palindrome?("baab")
true
iex> Palindrome.palindrome?("racecar")
true
iex> Palindrome.palindrome?("kayak")
true
iex> Palindrome.palindrome?("apples")
false
"""
def palindrome?(string) do
end
end
Run the following in your command line from the beta_curriculum folder to track and save your progress in a Git commit.
$ git add .
$ git commit -m "finish palindrome exercise"
Previous | Next |
---|---|
Comprehensions | Anagram |