consider there are N balls in a basket. 2 players play the turns
alternatively ..AT each turn,the player
can take 1 or 2 balls from the basket. the first player starts the game..
Both the players play optimally.
i) Given N,tell whether the 1st player win or loss ?
ii) If player 1
how is winning going to decided
On Sat, Jan 12, 2013 at 6:33 PM, siva sivavikne...@gmail.com wrote:
consider there are N balls in a basket. 2 players play the turns
alternatively ..AT each turn,the player
can take 1 or 2 balls from the basket. the first player starts the game..
Both the
Are we supposed to assume that every ball played is a hit? Or should we
consider a hit or a fail case??
On Sat, Jan 12, 2013 at 7:12 PM, Raunak Gupta raunak.gupt...@gmail.comwrote:
how is winning going to decided
On Sat, Jan 12, 2013 at 6:33 PM, siva sivavikne...@gmail.com wrote:
consider
The player who plays the last turn and finishes the game wins ...
I think the approach would be similar to this ..
http://www.spoj.com/problems/TWENDS/
.. @vamshi .. Can't get your question? .. what you refer to hit or fail
case in picking up a ball?..
At the end any of the 2 players can
@siva..
if (n%3 == 0)
Player 1 will lose
else
Player 1 will win. The no. of balls picked in the first turn will be
n%3
On Saturday, 12 January 2013 18:33:45 UTC+5:30, siva wrote:
consider there are N balls in a basket. 2 players play the turns
alternatively ..AT each turn,the
@siva..
if (n%3 == 0)
Player 1 will lose
else
Player 1 will win. The no. of balls picked in the first turn will be
n%3
--
yes the below logic is correct
1- 1st(1)
2- 1st(2)
3- 2nd(1,2 or 2,1)
4- 1st (1,2,1 or 1,1,2)
5-1st(2, 1, 2 or 2, 2, 1)
6- 2nd(2, 1, 3) or 1, 2,3)) 2nd will win
7- 1st(1, 1, 2, 3 or 1, 2, 1,3 or .,.
8- 1st (2, 1, 2, 3 or 2, 2,1, 3 or ..
In above 3 can be (1,2) or (2,1)
Thanks
Kumar Anurag
On
For simple reasons according to me:
1- It reduces overhead drastically,thus more efficient execution time is
achieved. Consider a recursive function call having array parameters -
func (int a[100][100], int b[100][100]).. Now instead if we use pointers-
func(int **a, int **b), the overhead on the
Use a set ADT ( C++ STL). Traverse the entire 2d matrix and keep on adding
each element to the set. The set ADT stores, sorts and removes redundant
data values and you get sorted list after traversal. Now again traverse the
set ADT and store it in an array.
On Wed, Jan 9, 2013 at 4:53 PM,