Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
2N friends(A,B,C...,2N) are standing in the Circle.There is exactly one person standing opposite of one other person. Some of them are facing inward and some of them are facing outwards. given some facts our task is to build standing positions and answer a few questions. If Arrangement not possible or more than one arrangement possible then print "ARRANGEMENT NOT POSSIBLE"



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 peoples are facing inwards, where n is a number
"8n" means : n peoples 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

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 are A, B, C and D are standing in a circle
There are 6 facts separated by semicolon
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


What I have tried:

I have no idea how to solve this
Posted
Updated 12-Jul-19 20:33pm

We are more than willing to help those that are stuck: but that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

Start by grabbing a sheet of paper and a pencil, and trying it manually for a small set of data. It should become pretty clear what you need to do once you can do it manually.
 
Share this answer
 
Comments
Deep1992 13-Jul-19 1:52am    
Just give me the starting point how to begin..... rest I will handle it
OriginalGriff 13-Jul-19 1:57am    
Literally: try it on paper and see how it's supposed to work.

Working this out is part of the assignment: unless you develop the skill fairly early in your course, you will be completely throws later when things start to get complicated.
Deep1992 13-Jul-19 2:01am    
okay I m trying
Quote:
I have no idea how to solve this

First, you need to understand the problem. The only way is to solve repeatedly the problem by hand with different examples, invent some sample data as you need to cover all cases.
So, take a sheet of paper and pencil, then try to solve the problem by hand.
It is a trial and error process, this is how you will learn.

Problem analyze is a skill you will gain by experience, we can't teach you experience.
In your case, experience comes as you have solved many kinds of problems and when you detect similarities with previous problems, because chances are that the solution is similar too.

- Learn one or more analyze methods, E.W. Djikstra/N. Wirth Stepwize Refinement/top-Down method is a good start.
Structured Programming.pdf[^]
https://en.wikipedia.org/wiki/Top-down_and_bottom-up_design[^]
https://en.wikipedia.org/wiki/Structured_programming[^]
https://en.wikipedia.org/wiki/Edsger_W._Dijkstra[^]
https://www.cs.utexas.edu/users/EWD/ewd03xx/EWD316.PDF[^]
- Learn Algorithms and Data-Structures.

Dynamic programming - Wikipedia[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900