+ 1

How to print a given matrix in spiral form in Python

input: A = [[2, 4, 6, 8], [5, 9, 12, 16], [2, 11, 5, 9], [3, 2, 1, 8]] out put: 2 4 6 8 16 9 8 1 2 3 2 5 9 12 5 11

4th Sep 2017, 6:27 AM
Gopikrishna A
Gopikrishna A - avatar
4 Antworten
+ 3
The logic of iterating 2d array in spiral, but not used to display array-content, only displaying each state of spiral iterating (could be easily modified to output an array content ;) https://code.sololearn.com/cZkLiwlXZ6iQ/?ref=app
4th Sep 2017, 10:02 AM
visph
visph - avatar
4th Sep 2017, 8:53 AM
Sunera Avinash
Sunera Avinash - avatar
+ 2
Thank you all Finally I got it, Here it is my code: https://code.sololearn.com/c2hs39NrqHX5/#py
5th Sep 2017, 12:08 PM
Gopikrishna A
Gopikrishna A - avatar
0
check the logic... slight different code.. but logic is same... input a integer size of matrix like 5 https://code.sololearn.com/cNCzt3qU6XTs/?ref=app
4th Sep 2017, 6:37 AM
sayan chandra
sayan chandra - avatar