Showing posts with label Pattern. Show all posts
Showing posts with label Pattern. Show all posts

March 21, 2021

Sappient : Star Pattern problem



Question: WAP to print the number in the below format.
star pattern for size :7
    1
   232
  34543
 4567654
  34543
   232
    1


Answer :

March 14, 2018

Print Start Pattern Using Recursion

Output :
X 
X X 
X X X 
X X X X 
---------------------
X X X X 
X X X 
X X 
X 
JAVA Code:
public class HelloWorld {

 static int count = 0;

 public static void print(int i, int j) {

  if (i <= 0 || j < 0 ) return;

  System.out.print("X ");

  print(i, j - 1);

  if (j == 0) {

   count++;

   System.out.println();

   print(i - 1, count);





  }

 }

   public static void print2(int i, int j) {

  if (i <= 0 || j < 0 ) return;

System.out.print("X ");

print2(i, j - 1);





  if (j == 0) {



   System.out.println();

   print2(i - 1, i-2);





  }

}





 public static void main(String[] args) {

  //System.out.println("Hello World2");

  print(4, 0);

  System.out.println("---------------------");



  print2(4, 3);

 }

}

April 1, 2015

Vinsol : Defected Meter

Question :A Defected meter is given with missing number 4 from it's rim.WAP that convert the wrong  reading into right one.
Example:
input 100
output 81

March 17, 2015

AMCAT:Pattern Based Question2

Pattern  for n=6
11111112
32222222
33333334
54444444
55555556
76666666

AMCAT:Pattern Based Question1

Question:For input N print 2N  no. of lines same as following  pattern
Assume input is 4 assume start number is 4
4
55
666
7777
7777
666
55
4 
 Note: i got only idea of Question, not  the extact Question so modify According to your need.

March 15, 2015

Thoughtworks :StairProblem

This is Screening interview Question asked in Thoughtworks.


Question: Print spiral stair case pattern.

Input: Y is the number of stairs available, X  is the length spiral visible stairs.
Output: Pattern in spiral form.



Stair Problem ...Enter X,Y(Y is number of stair and Y length of stair)
15 4
1
_2
__3
___4
__5
_6
7
8
_9
__10
___11
__12
_13
14
15