There are N egg baskets and the number of eggs in each
basket is a known quantity. Two players take turns to remove
these eggs from the baskets. On each turn, a player must
remove at least one egg, and may remove any number of eggs
provided they all belong to the same basket. The player
picking the last egg(s) wins the game. If you are allowed to
decide who is going to start first, what mathematical
function would you use to decide so that you end up on the
winning side?
Upload a C program to demonstrate the behaviour of the game.
Answers were Sorted based on User's Feedback
Answer / venu
condition: First person should win
The logic is:
1.if n== odd
First person will remove all eggs from the basket.
next until empty baskets ==1, First person will just do
what ever the second person do. Once last basket comes he
will remove all eggs.
2.if n== even
First person will take out all eggs except one, 2nd
person forced to loose 1 chance as he will remove that egg.
Now next step is just do the (1)
| Is This Answer Correct ? | 1 Yes | 0 No |
How do you write a program which produces its own source code as its output?
What is the difference b/w Structure & Array?
How can I call a function, given its name as a string?
we all know about the function overloading concept used in C++ and we all learnt abt that.... but that concept is already came in C in a very smaller propotion ... my question is IN WHICH CONCEPT THERE IS A USE OF FUNCTION OVERLOADING IS USED in C language?????????????
Can you assign a different address to an array tag?
Write a program for finding factorial of a number.
what is c programming?
Which header file is used for clrscr?
what is the use of c program?
4 Answers Synergy, Web Synergies,
What is modifier & how many types of modifiers available in c?
Explain the difference between call by value and call by reference in c language?
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1