String contains non-overlapping letter pairs
You could use a map to store the pairs with their first occurrence while iterating over the pairs. Break if the current pair was already found at a position less than the current position minus 1.

def has_non_overlapping_pair(string) do
  0..String.length(string) - 2
  |&gt; Enum.reduce_while(%{}, fn n, m -&gt;
    pair = String.slice(string, n, 2)
    pos  = Map.get(m, pair, n)
    cond do
      pos == n     -&gt; {:cont, Map.put(m, pair, n)}
      pos == n - 1 -&gt; {:cont, m}
      true         -&gt; {:halt, true}
    end
  end) == true
end