Anagram Solver
Mix.install([
{:kino, github: "livebook-dev/kino", override: true},
{:kino_lab, "~> 0.1.0-dev", github: "jonatanklosko/kino_lab"},
{:vega_lite, "~> 0.1.4"},
{:kino_vega_lite, "~> 0.1.1"},
{:benchee, "~> 0.1"},
{:ecto, "~> 3.7"},
{:math, "~> 0.7.0"},
{:faker, "~> 0.17.0"},
{:utils, path: "#{__DIR__}/../utils"},
{:tested_cell, git: "https://github.com/BrooklinJazz/tested_cell"}
])
Navigation
Anagram Solver
Two words that contain all the same letters are anagrams. For example bored and robed are anagrams.
You are going to create an AnagramSolver
with a solve/1
function that accepts a word and
returns every possible permutation of the anagram. Each permutation does not need to be a real word.
For example,
AnagramSolver.solve("cat")
[
"cat",
"cta",
"act",
"atc",
"tac",
"tca"
]
You can expect that the number of answers for a word of given length n
will be n!
.
So a word with 3 letters has 6 solutions, a word with 4 letters has 24 answers, a word with
5 letters has 120 answers.
Enter your solution in the Elixir cell below,
defmodule AnagramSolver do
def solve(word) do
end
end
Validate Your Solution
To validate your solution, ensure the following matches the expected output above. The order of anagrams does not matter.
AnagramSolver.solve("cat")
Commit Your Progress
Run the following in your command line from the project folder to track and save your progress in a Git commit.
$ git add .
$ git commit -m "finish anagram solver exercise"