I think this is a better solution. Thanks for sharing.
Update: I have used @hauleth solution to write a generic function for getting a string of length n with just integers:
@spec random_n_char_number_string(integer()) :: String.t()
def random_n_char_number_string(n) do
"~#{n}..0B"
|> :io_lib.format([(10 |> :math.pow(n) |> round() |> :rand.uniform()) - 1])
|> List.to_string()
end
I hope this helps someone else.






















