Skip to content

Latest commit

 

History

History
90 lines (66 loc) · 2.02 KB

palindrome.livemd

File metadata and controls

90 lines (66 loc) · 2.02 KB

Palindrome

Mix.install([
  {:youtube, github: "brooklinjazz/youtube"},
  {:hidden_cell, github: "brooklinjazz/hidden_cell"},
  {:tested_cell, github: "brooklinjazz/tested_cell"},
  {:utils, path: "#{__DIR__}/../utils"}
])

Navigation

Return Home Report An Issue

Palindrome

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

Commit Your Progress

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"

Up Next

Previous Next
Comprehensions Anagram