Python 3.5, 74 7272 71 bytes
f=lambda L,*S:print(*S,*L)@ff([sum(x)%10for x in zip(L,L[1:print(*S,*L)]or 1)],'',*S)
Input is a list of integers (e.g. f([1,2,3,5,8])
), output is to STDOUT. The %10
and the fact that map
returns a map
object in Python 3 is a bit annoying, meaning we can't do map(lambda*x:sum(x)%10,L,L[1:])
or similar.
The function errors out, but by then the output would have completed. Thanks to @xsot for -1 byte by finding a good place to stick the @print
is just an irrelevant binary op here.