Problems with Integer.digits when the number is 99

defmodule Kata do
  def sum_digits(number) do
    number
    |> abs()
    |> Integer.digits()
  end
end


iex(42)> Kata.sum_digits(99)                                                                                                                                                                                                      
~c"\t\t"
iex(43)> Kata.sum_digits(94)                                                                                                                                                                                                      
[9, 4]
iex(44)> Kata.sum_digits(100)                                                                                                                                                                                                     
[1, 0, 0]

Lists of integers that are in the printable ASCII range are inspected as charlists.

1 Like

yes thank you for that
just feel weird that happens with certain numbers

~c"\t\t" and [99, 99] are the same thing. It’s sadly a very common gotcha.