Skip to content

Commit 028dc10

Browse files
committed
1 parent 2eb0d8a commit 028dc10

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

data-structures/matrix/matrix.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,32 @@ func spiralTraverse(m [][]string) {
1515
fmt.Printf("%s\n", m[row][column])
1616
visited++
1717
switch dir%4 {
18-
case 0: //TOP
18+
case 0: //Top path
1919
if column < rowSize - row - 1 {
20-
column++
20+
column++ //Go right
2121
} else {
22-
row++
22+
row++ //Turn down
2323
dir++
2424
}
25-
case 1: //RIGHT
25+
case 1: //Right path
2626
if row < column {
27-
row++
27+
row++ //Go down
2828
} else {
29-
column--
29+
column-- //Turn left
3030
dir++
3131
}
32-
case 2: //BOTTOM
32+
case 2: //Bottom path
3333
if column > rowSize - row - 1 {
34-
column--
34+
column-- //Go left
3535
} else {
36-
row--
36+
row-- //Turn up
3737
dir++
3838
}
39-
case 3: //LEFT
39+
case 3: //Left path
4040
if row > column + 1 {
41-
row--
41+
row-- //Go up
4242
} else {
43-
column++
43+
column++ //Turn right
4444
dir++
4545
}
4646
}

0 commit comments

Comments
 (0)