ABC042C - こだわり者いろはちゃん
問題
https://atcoder.jp/contests/abc042/tasks/arc058_a
回答1
defmodule Main do
def main do
:stdio
|> IO.read(:all)
|> solve()
|> IO.puts()
end
defp split_lines(lines) do
lines
|> String.trim()
|> String.split("\n")
end
defp split_words(words) do
String.split(words, " ")
end
def solve(input) do
[[n, _] | [d]] =
input
|> split_lines()
|> Enum.map(fn line ->
line
|> split_words()
|> Enum.map(&String.to_integer/1)
end)
n..99999
|> Enum.find(fn payment ->
all_digits =
payment
|> Integer.digits()
|> Enum.uniq()
|> Enum.concat(d)
all_digits
|> Enum.uniq()
|> Enum.count()
|> Kernel.==(Enum.count(all_digits))
end)
end
end
"""
1000 8
1 3 4 5 6 7 8 9
"""
|> Main.solve()
|> then(&(&1 == 2000))
"""
9999 1
0
"""
|> Main.solve()
|> then(&(&1 == 9999))