tracks/elixir/exercises/atbash-cipher/example.exs in trackler-2.2.1.47 vs tracks/elixir/exercises/atbash-cipher/example.exs in trackler-2.2.1.48
- old
+ new
@@ -7,34 +7,34 @@
## Examples
iex> Atbash.encode("completely insecure")
"xlnko vgvob rmhvx fiv"
"""
- @spec encode(String.t) :: String.t
+ @spec encode(String.t()) :: String.t()
def encode(plaintext) do
plaintext |> normalize |> transpose |> chunk |> Enum.join(" ")
end
- @spec decode(String.t) :: String.t
+ @spec decode(String.t()) :: String.t()
def decode(cipher) do
cipher |> normalize |> transpose
end
defp normalize(input) do
Regex.replace(~r{\W}, String.downcase(input), "")
end
defp transpose(text) do
text
- |> String.to_char_list
+ |> String.to_charlist()
|> Enum.map(&convert/1)
- |> List.to_string
+ |> List.to_string()
end
defp convert(character) do
Map.get(@key, character, character)
end
defp chunk(input) do
- Regex.scan(~r(.{1,5}), input) |> List.flatten
+ Regex.scan(~r(.{1,5}), input) |> List.flatten()
end
end