Pattern 22

Beginner Problems Patterns Medium
  • One real-world application of this problem is in graphic design software and games, where such patterns might be used to create programmatically generated visuals or puzzles
  • Understanding how to construct complex patterns from simple mathematical rules is a fundamental aspect of procedural generation, a technique commonly used in game design to create vast, explorable worlds on the fly

Given an integer n. You need to recreate the pattern given below for any value of N. Let's say for N = 5, the pattern should look like as below:


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


Print the pattern in the function given to you.

Constraints

  • 1 <= n <= 20

Company Tags

TCS Cognizant Accenture Infosys Capgemini Wipro IBM HCL Tech Mahindra MindTree