Greetings, aspiring Scala programmer! Are you eager to delve into the captivating challenge of matrix traversal in Scala? In this lesson, we’ll explore unique traversal patterns of matrices using the expressive and type-safe Scala language. Our journey will navigate through a matrix in a zigzag pattern, moving up and down the columns. Prepare yourself for an exciting journey as we unravel the depths of matrix manipulation in Scala!
Here is your challenge: You are given a 2D matrix, with each cell containing a unique integer value. Your objective is to develop a function that starts traversal from the bottom-right cell of the matrix. From there, you'll ascend the current column to its top, move left to the next column, and then descend to its bottom. After reaching the bottom, proceed left to continue the upward traversal. This zigzag pattern is maintained until every cell is visited.
Consider this small matrix as illustrated below:
Following the described traversal pattern, your function should return this list: List(12, 8, 4, 3, 7, 11, 10, 6, 2, 1, 5, 9).
