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.

Kewdz can haz found heeer

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

Walk on matrix visualized

color-tiered steps in solving the matrix

process differentiated by colors

head and tail on separating list

pattern matched list for head and tail

separating last elements of each lists in tail

separating last elements of each lists in tail