def reverse(x)
arr = x.to_s.split("")
rev = []
index = 1
arr.each do |a|
if a == "-" && rev.length == 0
rev << a
next
end
break if a == 0 && (rev.length - 1 == arr.length)
rev[arr.length - index] = a
index += 1
end
rev.join.to_i
end
puts(reverse(-123))