# ALP - Editorial

Author: Prathamesh Sogale
Tester: Prathamesh Sogale
Editorialist: Ram Agrawal

EASY

loops

# PROBLEM:

Meena is working with his friend on group project. It was a quite a hard day and they run out of ideas and after a while they got bored. So in order to refresh their mood and to remove their boredom they decided to challenge each other and the one who loose the challenge will give treat all the others. Meena was assigned a challenge to create an pattern.He is very bad at creating patterns so he asked you for an idea to print a pattern.You are good friend of Meena and should help him to create the pattern. You are given an integer NN you need to print hollow pattern similar to pattern given below.

# EXPLANATION:

In this question, we have to observe the test cases and print the pattern.

# SOLUTIONS:

Setter's Solution
``````/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef{

StringTokenizer st;

{
}

String next()
{
while (st == null || !st.hasMoreElements()) {
try {
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}

int nextInt() { return Integer.parseInt(next()); }

long nextLong() { return Long.parseLong(next()); }

double nextDouble()
{
return Double.parseDouble(next());
}

String nextLine()
{
String str = "";
try {
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}

static class OutputWriter {
private final PrintWriter writer;

public OutputWriter(OutputStream outputStream) {
writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
}

public OutputWriter(Writer writer) {
this.writer = new PrintWriter(writer);
}

public void print(int[] array) {
for (int i = 0; i < array.length; i++) {
if (i != 0) {
writer.print(' ');
}
writer.print(array[i]);
}
}

public void printLine(int[] array) {
print(array);
writer.println();
}

public void close() {
writer.close();
}

public void printLine(long i) {
writer.println(i);
}

public void printLine(int i) {
writer.println(i);
}
public void printLine(char c)
{
writer.println(c);
}

public void print(Object... objects) {
for (int i = 0; i < objects.length; i++) {
if (i != 0) {
writer.print(' ');
}
writer.print(objects[i]);
}
}

public void printLine(Object... objects) {
print(objects);
writer.println();
}
}

public static class Pair implements Comparable<Pair>{
int v,i;
Pair(int v, int i){
this.v = v;
this.i = i;
}
public int compareTo(Pair p){
return this.v - p.v;
}
}

public static void main (String[] args) throws java.lang.Exception{

OutputWriter out = new OutputWriter(System.out);
int t = sc.nextInt();
while(t-->0){
int n = sc.nextInt();
int curr = 'A';
for(int i=0;i<=n;i++){
for(int j=0;j<n-i;j++) out.print(" ");
out.print((char)curr);
for(int j=0;j<2*i-1;j++) out.print(" ");
if(i!=0) out.print((char)curr);
if(curr=='Z') curr = 'a';
else curr = curr+1;
out.printLine();
}
for(int i=n-1;i>=0;i--){
for(int j=0;j<n-i;j++) out.print(" ");
out.print((char)curr);
for(int j=0;j<2*i-1;j++) out.print(" ");
if(i!=0) out.print((char)curr);
if(curr=='Z') curr = 'a';
else curr = curr+1;
out.printLine();
}
}
out.close();
}
}
``````
Tester's Solution
``````#include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin>>T;
for(int i=0;i<T;i++)
{

int n;
cin>>n;
int x=0;
int p1=71;

for(int i=n;i>=-n;i--)
{
for(int j=1;j<=abs(i);j++)
{
cout<<" ";
}

for(int p=n;p>=abs(i);p--)

{
if(p==n || p==abs(i))
{
if(char(x+65)<91)
{
cout<<char(x+65)<<" ";
}

// 	 else if(char(x+65)>=91 && char(x+65)<=96)
// 	 {
// 	     break;
// 	 }
else
{

cout<<char(p1+x)<<" ";

}
//p1++;

}

else
{

cout<<" "<<" ";

}

}
// if(char(x+65)>=91 && char(x+65)<=96)
// {
// 	x=0;
// }
// else
// {
x++;

//}

cout<<"\n";

}

}

}
``````