You know that rush when you finally figure something out after banging your head against a wall for hours? That was me trying to solve a deceptively simple-looking pattern problem in C. Here’s the challenge: Problem: Given a number n, print a (2n-1) x (2n-1) square pattern where the numbers decrease in layers towards the center. For example, if n = 4, the output should look like this: 4 4 4 4 4 4 4 4 3 3 3 3 3 4 4 3 2 2 2 3 4 4 3 2 1 2 3 4 4 3 2 2 2 3 4 4 3 3 3 3 3 4 4 4 4 4 4 4 4

Apr 12, 2025 - 13:12
 0

You know that rush when you finally figure something out after banging your head against a wall for hours? That was me trying to solve a deceptively simple-looking pattern problem in C.

Here’s the challenge:
Problem:
Given a number n, print a (2n-1) x (2n-1) square pattern where the numbers decrease in layers towards the center.

For example, if n = 4, the output should look like this:

4 4 4 4 4 4 4
4 3 3 3 3 3 4
4 3 2 2 2 3 4
4 3 2 1 2 3 4
4 3 2 2 2 3 4
4 3 3 3 3 3 4
4 4 4 4 4 4 4