Rotated Square is a great problem to tackle if you want practice implementing and manipulating 2D arrays. Simplified problem statement: Given a larger square grid of uppercase letters and a smaller square grid of lowercase letters, count all the times the smaller grid appears in the larger grid in all of its rotated forms. For some reason, there are no stated bounds on `n`

in this problem, which makes it hard to determine whether your solution is sufficiently fast, but in this case the brute-force approach is accepted! This is why I say it is a good implementation practice problem. The algorithm itself isnâ€™t difficult to come up with, so all of the errors I received while solving this problem had to do with how I was representing the data in the array. At first, I tried using `vector<string>`

s, but this lead to difficulties in rotating the small square, so my AC code uses `char[][]`

, which I believe is much simpler to think about. Here is my solution:

# UVa 10855: Rotated Square

*
For technical reasons, comments are temporarily unavailable on my posts.
If you'd like to discuss this article with me, feel
free to email me at
or hit me up on
Twitter.
*