tag:blogger.com,1999:blog-4115025577315673827.post7373530345276504115..comments2019-10-08T12:02:40.465+05:30Comments on CSE Blog - quant, math, computer science puzzles: Math Game of Zero StringUnknownnoreply@blogger.comBlogger8125tag:blogger.com,1999:blog-4115025577315673827.post-2113995242904621502014-04-04T09:21:09.409+05:302014-04-04T09:21:09.409+05:30Very good!Very good!pathankhan salmanhttps://www.blogger.com/profile/06503740596277603928noreply@blogger.comtag:blogger.com,1999:blog-4115025577315673827.post-31547710746463006282013-11-10T21:09:55.368+05:302013-11-10T21:09:55.368+05:30excellent!!excellent!!Aditya Rhttps://www.blogger.com/profile/03797968688772401767noreply@blogger.comtag:blogger.com,1999:blog-4115025577315673827.post-19323910642523411692013-07-21T08:46:39.677+05:302013-07-21T08:46:39.677+05:30Not sure how to prove it mathematically, but if yo...Not sure how to prove it mathematically, but if you move from right-to-left, and you encounter a 1, and there are no 1 bits to the right of it, flip it to 0. No matter what the opponent tries to do, this strategy will win every time.barbshttps://www.blogger.com/profile/02289762124111938433noreply@blogger.comtag:blogger.com,1999:blog-4115025577315673827.post-38704705741132396862013-07-18T12:48:41.370+05:302013-07-18T12:48:41.370+05:30base case : trivial
let us say we know how to win ...base case : trivial<br />let us say we know how to win n-1 bit game - Assumption 1<br />for n bit game , we will use the same strategy to win the n-1 bits and ignore the most significant bit.<br />once we win the n-1 bit : <br /><br />if MSB is 1 ( we have control over this bit) , so we flip and win<br />if MSB is 0 ( given adversary wants to prolong indefinitely) , the only option for adversary is to flip it , else we will win , since all n bits will be 0. If the adversary flips to 1 (good for us , because it gives us the control over the MSB , so we keep it aside or maybe even hide it , doesn't really matter because adversary can do nothing about this bit anymore since it is 1 until unless flipped to 0 lol) . Now we are back to n-1 bit game (the only thing worth noting is that we are starting from a winning state (because n-1 bits are already 0). Whatever the move adversary takes , we can get back to the winning state from our initial assumption 1. So once we are back to the winning state with n-1 bits , we can flip the MSB (since it was 1 all this while ) to win the n bit game.<br />dontevenbotherhttps://www.blogger.com/profile/13451012657610194784noreply@blogger.comtag:blogger.com,1999:blog-4115025577315673827.post-23248551198786003462013-07-18T12:30:04.177+05:302013-07-18T12:30:04.177+05:30Base case : trivial (for 0 and 1 bit)
Let us assum...Base case : trivial (for 0 and 1 bit)<br />Let us assume there exists a strategy to win n-1 bits game (i.e for any possible combinatorial n-1 bits sequence can be converted to a sequence that contains (n-1) 0s) . For clarity let me call this winning state as W.<br /><br />For n bit game , we will use same strategy to reach a W where I have won the right most n-1 bits , leaving the left most nth bit . I can reach this state W because we are scanning from right to left or in layman terms i will play as if i didn't knw the most significant bit (MSB) exists or not.<br /><br />Now if the MSB is 1 (implies i have the control , so i can flip and win ) : trivial <br />if MSB is 0 : and given that the adversary tries to prolong indefinitely : the only option for adversary is to flip this to 1 (else I win by default because i am on the last bit , which is still 0 and my previous n-1 bits are already 0). Once the MSB is flipped to 1 (I again get the total control on MSB , so keep it aside or ignore it as if it doesn't exist anymore ) . Now we are left with n-1 bits all 0s and MSB which we do not care about as 1. Now whatever the adversary may do with the n-1 0 bits in the next turn , I can come back to the W (winning) state where all n-1 bits are 0. Once I reach W state , and because MSB is 1 , i can just flip it to win. <br /><br />The solution is based on induction but the key insight is the problem is reduced to a smaller size problem as soon as the MSB is flipped to 1.. Once MSB becomes 1 , the adversary can do nothing about it and the game can be played as if its a n-1 bit game , but to force the adversary to flip MSB to 1 (if it was originally 0) , you have to win the n-1 bit game. dontevenbotherhttps://www.blogger.com/profile/13451012657610194784noreply@blogger.comtag:blogger.com,1999:blog-4115025577315673827.post-35207851904890886152013-07-18T10:18:00.663+05:302013-07-18T10:18:00.663+05:30Rough Sketch of proof:
We describe a procedure t...Rough Sketch of proof: <br /><br />We describe a procedure that leads to our win for any arbitrary binary string of length k.<br /><br />Assume you have some X 0's and Y 1's to begin with, where X and Y are natural numbers. <br /><br />Procedure:<br /><br />On each of your moves, we break into two cases depending on all your opponent's moves leading up to that move:<br /><br /> a) If your opponent hasn't changed any "0"s to "1"s before this point, then change this particular "1" to a "0"<br /><br /> b) If your opponent has changed a "0" to a "1", then leave this particular "1" unchanged<br /><br />Repeat until you win.<br /><br />Why this procedure works: Let's call the rightmost "1" in the starting bit sequence "special" (excluding the leftmost bit). <br /><br />Now note your opponent is guaranteed to lose after making move i (position i)in the number if all bits to the left of i are one, and all bits before i and including i are zero. Thus by following the above procedure, either we get an additional "1" to the right of the "special", OR our opponent changes a "0" that is left of the "special" and all the other "1"s that came before it become zero.<br /><br />Now note that this second case must eventually come true, we always must get a new "special" that is to the left of the original "special" (because there are a finite number of digits that come before the "special" - just think about it). When this happens, the new "1" that is formed is the new "special".<br /><br />Thus all "1"s must migrate to the left after some number of repetitions. Once the leftmost bit in the string becomes a "1", it will never be changed until the winning repetition (because the only case in which it would be changed is if every bit before it was zero). Thus once the leftmost bit is a "1", we can ignore it and pretend we have a string of length one bit shorter. If we keep repeating, all the bits must eventually become one. When this happens we can zero out every bit in one move.bob henlyhttps://www.blogger.com/profile/12486535221219441825noreply@blogger.comtag:blogger.com,1999:blog-4115025577315673827.post-79186502375523041472013-07-16T21:58:19.423+05:302013-07-16T21:58:19.423+05:30Here you are assuming that in order to win, all th...Here you are assuming that in order to win, all the digits should be 1 just before. <br />This, according to me is an incorrect assumption.<br />Eg. tell me how will you play for 10101101.Aadityahttps://www.blogger.com/profile/02995546118029271979noreply@blogger.comtag:blogger.com,1999:blog-4115025577315673827.post-39388997620321719722013-07-15T14:31:33.552+05:302013-07-15T14:31:33.552+05:30Base Case: You trivially win if there are 0 bits. ...Base Case: You trivially win if there are 0 bits. You easily win if there's 1 bit.<br /><br />Step:<br />1. Assume you can win when there are N-1 bits, for some N>1.<br />2. To win on a sequence of size N, simulate winning on the first N-1 bits.<br />3. Once the first N-1 bits are all 1, the last bit is either 0 or 1.<br />4. If the last bit is 0, flip it to 1 to win.<br />5. If the last bit is 1 and the adversary does not flip it you win.<br />6. If the last bit is 1 and the adversary flips it, go to step 2.<br /><br />Step 6 can only be reached once, because when step 6 is reached you gain control of the last bit and will win when step 4 is reached for the second time.<br /><br />Therefore, by induction, you can force all bits to be 1 for any finite constant sized sequence of bits.Strilanchttps://www.blogger.com/profile/09375682759275016445noreply@blogger.com