defmodule Main do def main do IO.read(:line) |> String.trim() |> String.to_integer() |> interact() |> IO.puts() end def interact(n) do interact_rec(1..n |> Enum.to_list()) end def interact_rec(r) do search_unnecessary(0..((r |> length) - 1) |> Enum.to_list, r) end def search_unnecessary([], r) do "! #{r |> length}\n#{r |> Enum.join(" ")}\n" end def search_unnecessary([h | t], r) do s = r |> List.delete_at(h) cond do IO.gets("? #{(r |> length) - 1}\n#{s |> Enum.join(" ")}\n") |> String.trim() == "1" -> interact_rec(s) true -> search_unnecessary(t, r) end end end