Repository: vaskoz/dailycodingproblem-go (go)

Issue:
Day 168
Good morning! Here's your coding interview problem for today.

This problem was asked by Facebook.

Given an N by N matrix, rotate it by 90 degrees clockwise.

For example, given the following matrix:
```
[[1, 2, 3],
 [4, 5, 6],
 [7, 8, 9]]
```
you should return:
```
[[7, 4, 1],
 [8, 5, 2],
 [9, 6, 3]]
```
Follow-up: What if you couldn't use any extra space?

Pull request description:
Day168
Resolves #348.

Patch:
diff --git a/README.md b/README.md
index 027014b..b862e6e 100644
--- a/README.md
+++ b/README.md
@@ -179,3 +179,4 @@ problems from
 * [Day 165](https://github.com/vaskoz/dailycodingproblem-go/issues/343)
 * [Day 166](https://github.com/vaskoz/dailycodingproblem-go/issues/346)
 * [Day 167](https://github.com/vaskoz/dailycodingproblem-go/issues/347)
+* [Day 168](https://github.com/vaskoz/dailycodingproblem-go/issues/348)
diff --git a/day168/problem.go b/day168/problem.go
new file mode 100644
index 0000000..a3111d0
--- /dev/null
+++ b/day168/problem.go
@@ -0,0 +1,19 @@
+package day168
+
+// Matrix is a 2D array of integers of NxN dimension.
+type Matrix [][]int
+
+// RotateMatrixRightClockwise90 does what it says.
+// It creates a new Matrix for the result.
+func RotateMatrixRightClockwise90(m Matrix) Matrix {
+	result := make(Matrix, len(m))
+	for i := range result {
+		result[i] = make([]int, len(m))
+	}
+	for i := range m {
+		for j := range m[i] {
+			result[j][len(m)-1-i] = m[i][j]
+		}
+	}
+	return result
+}


Test patch:
diff --git a/day168/problem_test.go b/day168/problem_test.go
new file mode 100644
index 0000000..4e6c9a3
--- /dev/null
+++ b/day168/problem_test.go
@@ -0,0 +1,29 @@
+package day168
+
+import (
+	"reflect"
+	"testing"
+)
+
+var testcases = []struct {
+	matrix, rotated Matrix
+}{
+	{Matrix{
+		{1, 2, 3},
+		{4, 5, 6},
+		{7, 8, 9},
+	}, Matrix{
+		{7, 4, 1},
+		{8, 5, 2},
+		{9, 6, 3},
+	}},
+}
+
+func TestRotateMatrixRightClockwise90(t *testing.T) {
+	t.Parallel()
+	for _, tc := range testcases {
+		if result := RotateMatrixRightClockwise90(tc.matrix); !reflect.DeepEqual(result, tc.rotated) {
+			t.Errorf("Expected %v got %v", tc.rotated, result)
+		}
+	}
+}