My goal here is pretty simple, I want to turn a number like
12435987234 into an array of integers in reverse order. So that would look like:
I want to do this without changing the number to a string and back. Really, I don't want to convert it at all but I'm open to hearing ideas around this.
I've found one way to do in ruby via
#divmod but suspect there is a more perfomant way.
# turns 1234 into # [4,3,2,1] def reversed_digits(val) quot = val results =  while quot > 0 do quot, remainder = quot.divmod(10) results << remainder end results end puts reversed_digits(1234) => [4,3,2,1]