diff --git a/challenges/rotate-2-dimensional-array-90-degrees/README.md b/challenges/rotate-2-dimensional-array-90-degrees/README.md new file mode 100644 index 0000000..5809a46 --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/README.md @@ -0,0 +1,58 @@ +# rotate-2-dimensional-array-90-degrees + +Created by [@Divlo](https://github.com/Divlo) on 3 December 2021. + +## Instructions + +Given a square/rectangle matrix representing an image and a direction of rotation (`clockwise` or `anticlockwise`), rotate the image by 90 degrees. + +### Input + +- **Line 1:** The direction (`clockwise` or `anticlockwise`) of rotation +- **Next Lines:** The matrix of the image + +### Output + +- **Lines:** The rotated matrix + +## Examples + +### Example 1 + +#### Input + +```txt +clockwise +1 2 3 +4 5 6 +7 8 9 +``` + +#### Output + +```txt +7 4 1 +8 5 2 +9 6 3 +``` + +### Example 2 + +#### Input + +```txt +anticlockwise +1 2 3 +4 5 6 +7 8 9 +``` + +#### Output + +```txt +1 4 7 +2 5 8 +3 6 9 +``` + +See the `test` folder for examples of input/output. diff --git a/challenges/rotate-2-dimensional-array-90-degrees/solutions/.gitkeep b/challenges/rotate-2-dimensional-array-90-degrees/solutions/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/challenges/rotate-2-dimensional-array-90-degrees/test/1/input.txt b/challenges/rotate-2-dimensional-array-90-degrees/test/1/input.txt new file mode 100644 index 0000000..a5f17a6 --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/test/1/input.txt @@ -0,0 +1,4 @@ +clockwise +1 2 3 +4 5 6 +7 8 9 \ No newline at end of file diff --git a/challenges/rotate-2-dimensional-array-90-degrees/test/1/output.txt b/challenges/rotate-2-dimensional-array-90-degrees/test/1/output.txt new file mode 100644 index 0000000..acd6697 --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/test/1/output.txt @@ -0,0 +1,3 @@ +7 4 1 +8 5 2 +9 6 3 \ No newline at end of file diff --git a/challenges/rotate-2-dimensional-array-90-degrees/test/2/input.txt b/challenges/rotate-2-dimensional-array-90-degrees/test/2/input.txt new file mode 100644 index 0000000..10b8eab --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/test/2/input.txt @@ -0,0 +1,4 @@ +anticlockwise +1 2 3 +4 5 6 +7 8 9 \ No newline at end of file diff --git a/challenges/rotate-2-dimensional-array-90-degrees/test/2/output.txt b/challenges/rotate-2-dimensional-array-90-degrees/test/2/output.txt new file mode 100644 index 0000000..4c1337c --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/test/2/output.txt @@ -0,0 +1,3 @@ +1 4 7 +2 5 8 +3 6 9 \ No newline at end of file diff --git a/challenges/rotate-2-dimensional-array-90-degrees/test/3/input.txt b/challenges/rotate-2-dimensional-array-90-degrees/test/3/input.txt new file mode 100644 index 0000000..fb02601 --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/test/3/input.txt @@ -0,0 +1,5 @@ +clockwise +5 1 9 11 +2 4 8 10 +13 3 6 7 +15 14 12 16 \ No newline at end of file diff --git a/challenges/rotate-2-dimensional-array-90-degrees/test/3/output.txt b/challenges/rotate-2-dimensional-array-90-degrees/test/3/output.txt new file mode 100644 index 0000000..ba878f6 --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/test/3/output.txt @@ -0,0 +1,4 @@ +15 13 2 5 +14 3 4 1 +12 6 8 9 +16 7 10 11 \ No newline at end of file diff --git a/challenges/rotate-2-dimensional-array-90-degrees/test/4/input.txt b/challenges/rotate-2-dimensional-array-90-degrees/test/4/input.txt new file mode 100644 index 0000000..f8e20b0 --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/test/4/input.txt @@ -0,0 +1,4 @@ +clockwise +11 12 13 14 +21 22 23 24 +31 32 33 34 \ No newline at end of file diff --git a/challenges/rotate-2-dimensional-array-90-degrees/test/4/output.txt b/challenges/rotate-2-dimensional-array-90-degrees/test/4/output.txt new file mode 100644 index 0000000..cacb735 --- /dev/null +++ b/challenges/rotate-2-dimensional-array-90-degrees/test/4/output.txt @@ -0,0 +1,4 @@ +31 21 11 +32 22 12 +33 23 13 +34 24 14 \ No newline at end of file