Matrix Dimension Restructuring - Coding problem | OneNoughtOne