• 104

## Learning Opportunities

This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.

## Goal

You must crank an WxH matrix counterclockwise by X positions. To crank a matrix, you must shift each matrix element along the matrix rectangle. For example, for a 7x5 matrix with X = 1 the movements are performed this way:

v < < < < < <
v v < < < < ^
v v 0 0 0 ^ ^
v > > > > ^ ^
> > > > > > ^

where the characters < ^ > v represent the displacement of a value in that position; 0 means no displacement.
Input
Line 1: 2 integers W and H representing the width and height (respectively) of a matrix.
Line 2: An integer X representing the number of positions to crank the matrix.
Next H lines: W matrix values v per line.
Output
H lines: The cranked matrix.
Constraints
1 ≤ W,H ≤ 50
1 ≤ X ≤ 100000000
-100 ≤ v ≤ 100
Example
Input
```3 3
1
1 2 3
4 5 6
7 8 9```
Output
```2 3 6
1 5 9
4 7 8```

A higher resolution is required to access the IDE   Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
Online Participants