program problem

K

kittu

the program says
there r 21 match sticks.there r 2 players computer and user.
both pick matchsticks one by one starting with user.
they can pick 1or2or3or4 match sticks at a time.
the player who picks the last match stick losses the match.
condition is that computer has always to win.
can somebody please tell me how can this programm be formed
 
M

Michael Mair

kittu said:
the program says
there r 21 match sticks.there r 2 players computer and user.
both pick matchsticks one by one starting with user.
they can pick 1or2or3or4 match sticks at a time.
the player who picks the last match stick losses the match.
condition is that computer has always to win.
can somebody please tell me how can this programm be formed

This is not a C question.
Ask in a newsgroup where this kind of problems are topical.
If you have problems implementing the programme in standard
C, you are welcome to ask here.

Hints: The computer just has to take a number of match sticks
such that the sum of his and the immediately before drawn
player match sticks is always the same. Solve the problem
for six match sticks first.

Cheers
Michael
 
V

Vladimir S. Oka

kittu opined:
the program says

You mean the homework assignment...
there r 21 match sticks.there r 2 players computer and user.
both pick matchsticks one by one starting with user.
they can pick 1or2or3or4 match sticks at a time.
the player who picks the last match stick losses the match.
condition is that computer has always to win.

There are no words like "r" and "1or2or3or4".
can somebody please tell me how can this programm be formed

Yes, here's a version that takes 1, 2 or 3 sticks. I'm sure you can
easily adapt it to your needs.

<http://www.rskey.org/gene/calcmuseum/25nimb.htm>

At the very least it'll help you search for the solution. Otherwise,
your question is better asked in comp.programming or similar.

PS
Before you complain, you didn't specify the programming language.
 

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
473,773
Messages
2,569,594
Members
45,123
Latest member
Layne6498
Top