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?
Answers were Sorted based on User's Feedback
Answer / playboy
There are N buckets & each contains n eggs in it.
Then let opponent to start a game.
If opponent picks x eggs then u choose n-x from perticular
bucket.
This way u can win...
Is This Answer Correct ? | 2 Yes | 2 No |
It is said that there are N egg bags with eggs in it. So
every bag should have eggs..
Now answer depends on Number of Bags containing only one bag
Suppose there is
1. all bag contains more then 1 egg then I will choose first
2. only one bag with one egg then I will choose second
3. Two bags contain one egg I will choose third..
So It depends on how I reach to the last bag in first place
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / lokesh
if the XOR of all the numbers of eggs is zero than second
player win else first player will win.
(From NIM game(game theory))
Is This Answer Correct ? | 1 Yes | 2 No |
Answer / rahul
N%2
if it gives 0 then the person can choose to go second.if
nonzero then he should go first.But this logic is acceptable
only if there is atleast one egg in each basket.
Is This Answer Correct ? | 2 Yes | 7 No |
write a program for 4 4 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 2 2 2 2 2 2 3 3 3 3 4 4
What are types of structure?
What is the use of typedef in c?
Why do we write return 0 in c?
what is the use of #pragma pack, wer it is used?
Where can I get an ansi-compatible lint?
How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same
write a c program to find the roots of a quadratic equation ax2 + bx + c = 0
11 Answers CSC, St Marys, TATA,
Do character constants represent numerical values?
21. #define square(x) x*x main() { int i; i = 64/square(4); printf("%d",i); }
what is void pointer?
Differentiate fundamental data types and derived data types in C.