# [Perl 5], 111 + 1 (-p) = 112 bytes

<!-- language-all: lang-perl -->

    @a=0..3*$_;$t=$a[$d=abs$a[$_]-$a[$_-1]],$a[$d]=$a[$s=$a[$_]+$a[$_-1]],$a[$s]=$t,push@r,$a[1]for 2..$_;$_=$r[-1]

[Try it online!][TIO-j62hq7ab]

[Perl 5]: https://www.perl.org/
[TIO-j62hq7ab]: https://tio.run/##K0gtyjH9/98h0dZAT89YSyXeWqXEViUxWiXFNjGpGMSIj9UFU7qGsbE6YJlYsIJiW4isNqpsMVC2RKegtDjDoQgkYBibll@kYKSnBzI63lalKBqo9P9/IwODf/kFJZn5ecX/dQsA "Perl 5 – Try It Online"