The idea is to create two arrays that are one shift apart. We want to be able to compare values at same indices. Since this is from a number, we will naturally carry along its list representation.

```
def maps(num)
n = num.to_s.split('').map { |i| i.to_i }
m = n.length
l = n[0, m-1]
r = n[1, m]
return l, r, n
end
k = maps(123456789)
print k[0].each { |i| i }
puts
print k[1].each { |i| i }
puts
print k[2].each { |i| i }
puts
```

Output

```
12345678
23456789
123456789
```