Walk on Matrix with Elixir
tldr; if you visualize walk in matrix, it looked like playing snake moving inward spiral motion starting at top left and ends somewhere in the middle. Of course, Elixir.
Intro
Walk in Matrix is a coding puzzle in which you are given an input of 2-dimensional list of integers and returns a list of integers.
The input is something like this:
input =
[
[ 1, 2, 3, 4]
[10,11,12, 5]
[ 9, 8, 7, 6]
]
Then the output:
iex> walk_on_matrix(input)
[1,2,3,4,5,6,7,8,9,10,11,12]
Visuals

Walk on matrix visualized

process differentiated by colors

pattern matched list for head and tail

separating last elements of each lists in tail