Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/Anagrams/Elixir/anagrams-1.elixir
Normal file
16
Task/Anagrams/Elixir/anagrams-1.elixir
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
defmodule Anagrams do
|
||||
def find(file) do
|
||||
File.read!(file)
|
||||
|> String.split
|
||||
|> Enum.group_by(fn word -> String.codepoints(word) |> Enum.sort end)
|
||||
|> Enum.group_by(fn {_,v} -> length(v) end)
|
||||
|> Enum.max
|
||||
|> print
|
||||
end
|
||||
|
||||
defp print({_,y}) do
|
||||
Enum.each(y, fn {_,e} -> Enum.sort(e) |> Enum.join(" ") |> IO.puts end)
|
||||
end
|
||||
end
|
||||
|
||||
Anagrams.find("unixdict.txt")
|
||||
8
Task/Anagrams/Elixir/anagrams-2.elixir
Normal file
8
Task/Anagrams/Elixir/anagrams-2.elixir
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
File.stream!("unixdict.txt")
|
||||
|> Stream.map(&String.strip &1)
|
||||
|> Enum.group_by(&String.codepoints(&1) |> Enum.sort)
|
||||
|> Map.values
|
||||
|> Enum.group_by(&length &1)
|
||||
|> Enum.max
|
||||
|> elem(1)
|
||||
|> Enum.each(fn n -> Enum.sort(n) |> Enum.join(" ") |> IO.puts end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue