Sort 12 Discussions, By:
Please Login in order to post a comment
Here is Taste Like winning problem solution in Python Java C++ and C programming- https://programs.programmingoneonone.com/2021/07/hackerrank-tastes-like-winning-problem-solution.html
I hate writing O(n) algorithms where n is an input value (rather than the memory size of the input); those are just exponential algorithms making a poor effort to pretend otherwise. But apparently it's good enough here.
I really dont get what the question want, any simpler explanation?
This challenge is poorly written. Here's a better explanation.
In (this version of) the game of Nim, whoever takes the last stone wins. On your turn, you can take as many stones as you want from any single pile. You have to take at least one stone on your turn (you cannot pass). It is a well known result in game theory that if both players play optimally, then the winner is decided by the following property. On your turn let p be the number of piles, let size[i] be the number of stones currently in pile i. If size XOR size XOR size ... XOR size[p] != 0, then it is possible for you to make a move that forces your opponent to lose (eventually). If that XOR is 0, then no matter what you do, the opponent (if they play optimally) can make a move that forces you to lose (eventually).
size XOR size XOR size ... XOR size[p] != 0
This challenge wants the number of initial setups such that the first player can force a win, with one extra condition: at the start of the game no two piles have the same number of stones.
So, you want to count the number of ways to take n distinct integers from [1, 2^m-1] such that the XOR of those n values is not zero.
i didnt understood ques and messed up at last because output were different. how r they supposed to take stones ? i didnt got it till now... explain plz.