problem with Apples and Mangoes

E

einstien

Let,
A = Apple
M = Mango

Given p apples, and q mangoes take here p =5, q= 6

and arrangement like this AAMMAMMAMAM,

have to change them like this

AM AM AM AM AM M

or

MA MA MA MA MA M

in simple, arranging the couples,writing remaining as individual.

{ here is the condition
reversing them has to give the original arrangement}

Thanks.
 
C

cnoe

Let,
P = your post
R = someone reading your post

P R

Result: Reader can find no question in your post.

You're welcome.

OK this is simplem, you have 8M, 3A and their order is
given like this for you,

M M M M A A M M M A M


you have to arrange them in pairs

as MA MA MA and remaining as M M M M M;

if you reverse it again you have to go back to
original order.

Thanks.
Any more information please ask it.
 
U

user923005

Let,
A = Apple
M = Mango

Given p apples, and q mangoes take  here p =5, q= 6

and arrangement like this AAMMAMMAMAM,

have to change them like this

AM AM AM AM AM     M

or

MA MA MA MA MA     M

in simple, arranging the couples,writing  remaining  as individual.

{ here is the condition
reversing them has to give the original arrangement}

Smells like a sort/merge to me.
Or, in this case, with only two distinct items, create two auxiliary
lists.
Separate all M into list one.
Separate all A into list two.
Merge the distinct lists back into the original list.

I am sure that there are plenty of other solutions.

P.S.
You want and not because your
post contains not even a hint of a C question.
 
C

cnoe

Smells like a sort/merge to me.
Or, in this case, with only two distinct items, create two auxiliary
lists.
Separate all M into list one.
Separate all A into list two.
Merge the distinct lists back into the original list.

I am sure that there are plenty of other solutions.

P.S.
You want and not because your
post contains not even a hint of a C question.

ok I 'll post there.
Thanks.
 
K

Keith Thompson

cnoe said:
einstien said:
Let,
A = Apple
M = Mango
Given p apples, and q mangoes take  here p =5, q= 6
[snip]

Let,
P = your post
R = someone reading your post

P R

Result: Reader can find no question in your post.

You're welcome.

OK this is simplem, you have 8M, 3A and their order is
given like this for you,

M M M M A A M M M A M


you have to arrange them in pairs

as MA MA MA and remaining as M M M M M;

if you reverse it again you have to go back to
original order.

Thanks.
Any more information please ask it.

We don't need more information. You do.

blargg's point is that you've stated a problem, but you haven't asked
a question. Just what is it that you want? It looks very much like
this is a homework problem, and your assignment is to write a C
program to solve it (but you haven't actually said so). If you're
asking us to write a C program for you that solves the problem, that's
not going to happen; we won't do your homework for you.

Try it yourself. Write a C program that solves the problem, or at
least try to do so. If you run into trouble, we'll be glad to help
out with any C language issues.

Incidentally, if I understand the problem correctly, part of it
appears to be insoluble. If you start with an arbitrary sequence of
As and Ms, and arrange them in pairs as you've specified, then you
lose all the information about how they were originally arranged; the
final result depends only on the number of As and Ms, not on their
order. I suspect the problem is that you haven't stated it accurately
(or perhaps I've just misunderstood).

But so far, given that you haven't said or asked anything that's
actually relevant to the C language, there's not much we can do to
help you (other than to encourage you to ask a clearer question).
 
C

cnoe

cnoe said:
Let,
A = Apple
M = Mango
Given p apples, and q mangoes take  here p =5, q= 6
[snip]
Let,
P = your post
R = someone reading your post
P R
Result: Reader can find no question in your post.
You're welcome.
OK this is simplem, you have 8M, 3A and their order is
given like this for you,
M M M M A A M M M A M
you have to arrange them in pairs
as MA MA MA and remaining as M M M M M;
if you  reverse it again you have to go back to
original order.
Thanks.
Any more information please ask it.

We don't need more information.  You do.

blargg's point is that you've stated a problem, but you haven't asked
a question.  Just what is it that you want?  It looks very much like
this is a homework problem, and your assignment is to write a C
program to solve it (but you haven't actually said so).  If you're
asking us to write a C program for you that solves the problem, that's
not going to happen; we won't do your homework for you.

Try it yourself.  Write a C program that solves the problem, or at
least try to do so.  If you run into trouble, we'll be glad to help
out with any C language issues.

Incidentally, if I understand the problem correctly, part of it
appears to be insoluble.  If you start with an arbitrary sequence of
As and Ms, and arrange them in pairs as you've specified, then you
lose all the information about how they were originally arranged; the
final result depends only on the number of As and Ms, not on their
order.  I suspect the problem is that you haven't stated it accurately
(or perhaps I've just misunderstood).

But so far, given that you haven't said or asked anything that's
actually relevant to the C language, there's not much we can do to
help you (other than to encourage you to ask a clearer question).

--
Keith Thompson (The_Other_Keith) (e-mail address removed)  <http://www.ghoti.net/~kst>
Nokia
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

yeah, I want to program program it, I don't want
any code, but a basic idea from you people would be helpful.

given a sequence something like this

M M M A A A M M A

I've to write a program to arrange them in pairs

like this MA MA MA MA; M

and if I reverse it I've to go back to the
original sequence.


Thanks.
 
F

Flash Gordon

cnoe wrote, On 19/11/08 19:37:
Any more information please ask it.

There are two pieces of information I would like.

1) Why don't you post with a consistent name.
2) Why do you think other people should do your homework for you?
 
C

Chris M. Thomasson

[...]
#define FRUIT "M M M M A A M M M A M"
#include <stdio.h>
#include <string.h>
#define Oo(O) putchar(O)
#define O(o,O) o=(Oo(*o++),oO(o,O,o),o)
#define oO(OO,oo,o) OO=strchr(o,oo)
int main(void){char*oO(Oo,'A',FRUIT),*oO(oO,'M',FRUIT)
;while(Oo&&oO){O(Oo,'A');O(oO,'M');if(Oo&&oO)Oo(' ');}
if(Oo||oO)Oo('\t');while(Oo){O(Oo,'A');if(Oo)Oo(' ');}
while(oO){O(oO,'M');if(oO)Oo(' ');}Oo('\n');return 0;}

=^D
 
V

viza

yeah, I want to program program it, I don't want any code, but a basic
idea from you people would be helpful.

given a sequence something like this

M M M A A A M M A

I've to write a program to arrange them in pairs

like this MA MA MA MA; M

and if I reverse it I've to go back to the original sequence.

If you can't write out the program program on its own, then just try
writing instructions that the program has to follow:

-Set the count of apples and mandarins* to zero.
-Read in the data.
-Look at each letter in turn.
-if it is an A, increase the count of apples.
-ditto for mandarins.
-once you have looked at all the characters, write out as many pairs as
are appropriate.
-then write out the spares.

As Keith already said, unless there is some pattern in the input that we
haven't noticed, this transformation is not reversible.

* I don't like mango - I will eat it if you put it in front of me, but I
wouldn't order it if I had the choice and I've certainly never bought one.
 
A

Andrey Tarasevich

Eric said:
#define FRUIT "M M M M A A M M M A M"
#include <stdio.h>
#include <string.h>
#define Oo(O) putchar(O)
#define O(o,O) o=(Oo(*o++),oO(o,O,o),o)
#define oO(OO,oo,o) OO=strchr(o,oo)
int main(void){char*oO(Oo,'A',FRUIT),*oO(oO,'M',FRUIT)
;while(Oo&&oO){O(Oo,'A');O(oO,'M');if(Oo&&oO)Oo(' ');}
if(Oo||oO)Oo('\t');while(Oo){O(Oo,'A');if(Oo)Oo(' ');}
while(oO){O(oO,'M');if(oO)Oo(' ');}Oo('\n');return 0;}

Mmmmaaammmmaa mia!
 
D

Doug Miller

OK this is simplem, you have 8M, 3A and their order is
given like this for you,

M M M M A A M M M A M


you have to arrange them in pairs

No. I don't. You do.
as MA MA MA and remaining as M M M M M;

if you reverse it again you have to go back to
original order.

Again: No. I don't. You do.

Have fun.
Thanks.
Any more information please ask it.

Is this homework?
 
C

CBFalconer

blargg said:
Let,
P = your post
R = someone reading your post

P R

Result: Reader can find no question in your post.

He doesn't need to post a question. However Reader also can find
no information in the post.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top