Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
16
Task/ABC-problem/Elixir/abc-problem.elixir
Normal file
16
Task/ABC-problem/Elixir/abc-problem.elixir
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
defmodule ABC do
|
||||
def can_make_word(word, avail) do
|
||||
can_make_word(String.upcase(word) |> to_charlist, avail, [])
|
||||
end
|
||||
|
||||
defp can_make_word([], _, _), do: true
|
||||
defp can_make_word(_, [], _), do: false
|
||||
defp can_make_word([l|tail], [b|rest], tried) do
|
||||
(l in b and can_make_word(tail, rest++tried, []))
|
||||
or can_make_word([l|tail], rest, [b|tried])
|
||||
end
|
||||
end
|
||||
|
||||
blocks = ~w(BO XK DQ CP NA GT RE TG QD FS JW HU VI AN OB ER FS LY PC ZM)c
|
||||
~w(A Bark Book Treat Common Squad Confuse) |>
|
||||
Enum.map(fn(w) -> IO.puts "#{w}: #{ABC.can_make_word(w, blocks)}" end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue