HEXCODE Editorial

PROBLEM LINK:

Practice

Author: Prathamesh Sogale
Author: Prathamesh Sogale
Editorialist: Yogesh Deolalkar

DIFFICULTY:

Simple.

PREREQUISITES:

Math

PROBLEM:

Yash is on vacation and he decided to learn graphical user interface. So he started searching for courses on youtube after a while he got bored and decided to learn by reading only the documentations and various tricks that are available on google. While browsing through web he came across a confusing problem. Yash is very competitive and wants to take this as a challenge.

You are given an integer NN and you need to print the pattern below according to given value of NN.

NN=5

      *****
     *****
    *****
   *****
  *****
      *****
     *   *
    *   *
   *   *
  *****

SOLUTIONS:

Setter's Solution

#include
using namespace std;
using ll = long long;
int main() {
// your code goes here
ll t,n;
cin>>t;
while(t–){
cin>>n;
for(ll i=1; i<=n; i++){
for(ll j=1; j<=n-i; j++){
cout<<" “;
}
for(ll j=1; j<=n; j++){
cout<<”";
}
cout<<endl;
}
for(ll i = 1; i <=n; i++)
{
for(ll j=1;j<=n-i; j++)
{
cout<<" “;
}
for(ll k=1;k<=n; k++)
{
if (i==1 || i==n || k==1 ||k==n)
{
cout<<”
";
}
else
{
cout<<" ";
}
}
cout<<endl;
}
}
return 0;
}

Tester's Solution
    # cook your dish here

for i in range(int(input())):
N=int(input())
for i in range(N):
print(" “(N-i),"N)
for i in range(N):
if i==0:
print(" "
(N-i),”N)
elif i==N-1:
print(" "
(N-i),”
N)
else:
print(" "
(N-i),”"," "(abs(2-N)-2),”*")