TCS CodeVita Previous Year Question | Friend Circle

TCS CodeVita Season 9 Registration is going on Register soon — Click here
TCS CodeVita Previous Year Question must be completed before sitting in the actual round of coding.
CodeVita previous year question

Want to know more about TCS Codevita?We have covered a great part of the introduction to TCS CodeVita here you must read this: Click here to open.

Friend Circle

Problem Description

2N friends (A,B,C… , 2N) are standing in a circle. There is exactly one person standing opposite of one other person. Some of them are facing inwards and some of them are facing outwards. Here given some facts your task is to build the standing positions and answer a few Questions. If the arrangement is not possible or more than one arrangement is possible, then print “ARRANGEMENT NOT POSSIBLE”.
The formats of Facts & Questions and its meanings are as follows.
Facts
“1AB” means : A and B are standing adjacent to each other
“2AB” means : A and B are standing opposite to each other
“3AB” means : A is standing to the immediate left of B 
“4AB” means : A is standing to the immediate right of B
“5A” means : A is facing inwards
“6A” means : A is facing outwards
“7n” means : n people are facing inwards, where n is a number
“8n” means : n people are facing outwards, where n is a number
Questions
“?2A” means : who is standing opposite of A?
‘?3A” means : who is standing to the immediate left of A?
“?4A” means : who is standing to the immediate right of A?
“?5A” means : is A facing inwards? Ans:Y/N
“?6A” means : is A facing outwards? Ans:Y/N

Constraints

1 < N < 10
1 < Total Facts < 30
1 < Total Questions < 20

Input Format

N Multiple facts, separated by semicolon multiple questions, separated by semicolon

Output

Answers, separated by semicolon corresponding to order of questions OR “ARRANGEMENT NOT POSSIBLE”

Test Case

Explanation

Example 1
Input
2 
2AB;72;1AC;6D;4BD;6C
?2D;?3C;?4B;?5A;?6B
Output
C;B;D;Y;N
Explanation
4 people- A, B, C and D are standing in circle.
There are 6 facts separated in semicolons:
2AB ==> A and B are standing opposite
72 ==> 2 people are facing inwards
1AC ==> A and C are standing nearby
6D ==> D is facing outwards
4BD ==> B is standing immediate right of D
6C ==> C is facing outwards
From the above facts, we can build the standing positions as below image:
friend circle tcs codevita question

There are 5 questions:
?2D ==> who is standing opposite of D? Ans:C
?3C ==> who is standing immediate left of C? Ans:B
?4B ==> who is standing immediate right of B? Ans:D
?5A ==> is A facing inwards? Ans:Y
?6B ==> is B facing outwards? Ans:N
Finally printing all answers in a single line separated by semicolon.
Example 2
Input
2
4BA;3CA;3CD;5C;5B
?5A;?3D;?4C;?6B
Output
ARRANGEMENT NOT POSSIBLE
Explanation
We can arrange 4 people in two different ways as the image below, from the facts provided. Directions of A and D can be set differently.
friend circle 2 tcs codevita question



Spread the word and ask your every friend, junior, senior, batchmate, near and dear ones to Register to CodeVita! Click here to register.
Happy Coding!
We will be posting all the questions of CodeVita and also the Mock Tests.
We might not be able to publish all the questions. Keep sending your CodeVita’s question at circuitandcode@gmail.com

Post a Comment

0 Comments