rajesh puppala
 

Android application source code Use me
The Web
Ratna

This is my college campus.



now here i kept infosys aspiration 2020 infosys programming context. i was attended for infosys programming context aspiration 2020. so i am here present all seven question here.any one can read.

program1:

 

Queens and Knights

You are given a 8x8 chess board with out any pieces other than equal number of queens and knights. You have to place an equal number of knights and queens on the chessboard such that NO piece attacks any other piece. Each position in the board uses following to represent the status: 0 - no pieces, 1 - queens, 2 - knights.

Given a board with or without any pairs of queen and knight, you have to write a function addMaxPieces which adds as many pairs of queens and knights as possible and returns the updated board in the same format.

You can use the fact that in the best configuration, a maximum of 5 queens and 5 knights can be placed on 8 x 8 board such that NO piece attacks any other piece. An example of such a configuration is given below


Note that you will get 50% credit, if you add even one extra pair of queen and knight on the board correctly.

Instructions to use Open PBT Client:

  1. Specify the work directory path in the 'Work Directory Path' field. The path should correspond to your solution work directory.
  2. Download the Support files by clicking the Get Support Files

.

  1. You will find the problem directories containing:
    • problem.h file
    • problem.c file

in your work directory.

  1. Write your solution in .c file

Step 1:

In your Solution File:

  1. Add method public static int[][] addMaxPieces(int[][] board)

Step 2:

  1. Pass the following parameter to the method addMaxPieces()
    board is a two dimension integer array, represents the chess board as mentioned in the problem description.

Step 3:

Write the appropriate code as mentioned in the problem description by following the below given Constraints.

  1. The input should be the two dimension integer array provided to the method with some entries in the matrix.
  2. The entries specify the position of the Queens and Knights in the chess board (matrix). 1 for Queen and 2 for Knight
  3. You need to figure out the position of the Queens and Knights in the chess board, which can be additionally added to the board so thus no peices will attack anyone
  4. Your method should return the chess board that is the two dimension array with some additional entries.
  5. If your method will able to add atleast one pair of Queens and Knights, you will get the 50% credit.
  6. Read Constraints carefully.

The Prototype of the Function is :

  • int** addMaxPieces(int** board) takes a chess board as input and tries to add as many knight and queen pairs as possible and return the board in same format.

Constraints

  • The positions on the board can have only 0,1,2 values, else return the board as it is.
  • Input board should have equal number of queens and knights (if any), else return the board as it is.
  • In Input Board, no piece can attack any other piece, else return the board as it is.
  • Input board should be of size 8 x 8, else return the board as it is.

Example 1

Input


board[0][2] = board[1][5] = board[2][1] = 1;
board[6][4] = board[6][7] = board[7][3] = 2;

Output


The function returns

X,Y = 0,2 Piece = Q     input
X,Y = 1,5 Piece = Q     input
X,Y = 2,1 Piece = Q     input
X,Y = 3,6 Piece = Q
X,Y = 5,0 Piece = Q
X,Y = 7,7 Piece = K
X,Y = 6,4 Piece = K     input
X,Y = 6,7 Piece = K     input
X,Y = 7,3 Piece = K     input
X,Y = 7,4 Piece = K

The picture for this example

.

Example 2

Input


board[0][2] = board[1][5] = 1;
board[6][4] = board[6][7] = 2;

Output


The function returns

X,Y = 0,2 Piece = Q     input
X,Y = 1,5 Piece = Q     input
X,Y = 2,1 Piece = Q
X,Y = 3,6 Piece = Q
X,Y = 5,0 Piece = Q
X,Y = 7,7 Piece = K
X,Y = 6,4 Piece = K     input
X,Y = 6,7 Piece = K     input
X,Y = 7,3 Piece = K
X,Y = 7,4 Piece = K

Example 3

Input


board[0][2] = 1;
board[6][4] = 2;

Output


The function returns

X,Y = 0,2 Piece = Q     input
/> X,Y = 1,5 Piece = Q
X,Y = 2,1 Piece = Q
X,Y = 3,6 Piece = Q
X,Y = 5,0 Piece = Q
X,Y = 7,7 Piece = K
X,Y = 6,4 Piece = K     input
X,Y = 6,7 Piece = K
X,Y = 7,3 Piece = K
X,Y = 7,4 Piece = K

 

For C solutions

Header File

:

queenknights.h

Function Name

:

int** addMaxPieces(int** board)

Directory Name

:

queenknights

File Name

:

queenknights.c

 

For C++ solutions

Header File

:

queenknights.h

Class Name

:

QueenKnights

Function Name

:

int** addMaxPieces(int** board)

Directory Name

:

queenknights

FileName

:

queenknights.cpp

 

General Instructions

    *

The file / class names, functions, method signatures, header files to be used are mentioned in the problem statement. Do not use your own names or change the method signatures and fields. You can add any number of additional methods.

    *

Do not forget to mention the file extension, either .c or .cpp as the case maybe.

    *

For C solutions, change the value of "C_OR_CPP" macro in header file to 1 and for C++ solutions change the value to 2.

    *

Incase of iostream.h specify as iostream only.

 

 






Rajesh
7306947200
pedana
krishna dt

JOKES CORNER:
Some Good "Poor Jokes"...
Here are some really bad pj's...Read on if u like some...


Lion Roaring...
what happens when the lion roars???
...
TOM & JERRY Begins......



Hights of Optimism:r
Soldier: "Sir we are surrounded by enemies on all sides!!!"
Sardar Major" Excellent!!! we can attack in any direction"



Flirt like this
What is the height of Flirting?
Its When your love letter starts with "TO WHOMSOEVER IT MAY CONCERN"
..
BRILLIANT WAYS GIRLS TURN GUYS DOWN!!
HE: I'm a photographer I've been looking for a face like yours!
SHE: I'm a plastic surgeon. I've been looking for a face like yours!!!
HE: May I have the pleasure of this dance?
SHE: No, I'd like to have some pleasure too!!!

the sardar...
Q: Why did the Sardar take a pair binoculars with him to a funeral?
A: It was a distant relative's funeral.

gabbbar...
Gabber: Kitne Aadmi they.
Sambha: Sardar Do,
Gabber: Mujhe ginti nahi aati. Do kitne hotey hain?
Sambha: Sardar Do Ek ke baad aata hai.
Gabber : Aur Do ke pehle?
Sambha: Do ke pehle Ek aata hai.
Gabber: To beech mein kaun aata hai?
Sambha: Beech mein koi nahi aata.
Gabber: To fir Dono ek saath kyon nahi atey?
Sambha: Do Ek ke baad hi aa sakta hai, kyonki Do ek se bada hai.
Gabber: Do ek se bada hai? Kitna bada hai?
Sambha Do ek se Ek bada hai?
Gabber: Agar Do ek se ek bada hai to ek ek se kitna bada hai?
Sambha: Sardar, Maine tumhara namak khaya hai, mujhe goli mar do

ek ladki...
A Lady is standing up on top of the hill and she is going to push her Father down from the hill top.....
SO what is the name of this lady ???
... Well her Name is PUSH-PA!!!!!!!!!!

HE: How did you get to be so beautiful?
SHE: I must have been given your share!!!
HE: Will you come out with me this Saturday?
SHE: Sorry! I'm having a headache this weekend!!!
HE: Go on, don't be shy. Ask me out!
SHE: Okay, get out!!!
HE: I think I could make you very happy
SHE: Why? Are you leaving?
HE: What would you say if I asked u to marry me?
SHE: Nothing. I can't talk and laugh at the same time!!!
HE: Can I have your name?
SHE: Why, don't you already have one?
HE: Shall we go and see a film?
SHE: I've already seen it!!!
HE: Do you think it was fate that brought us together?
SHE: Nah, it was plain bad luck!!!
Today, there have been 1 visitors (1 hits) on this page!
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free