tag:blogger.com,1999:blog-786333285568106173.post6157470378495383941..comments2024-01-25T01:05:59.968-05:00Comments on WebDiarios de Motocicleta: A Classic ProblemMihaihttp://www.blogger.com/profile/11599372864611039927noreply@blogger.comBlogger13125tag:blogger.com,1999:blog-786333285568106173.post-60048174998218324672009-03-31T05:57:00.000-04:002009-03-31T05:57:00.000-04:00Typo: replace "2^d levels" (at the end) by "a few ...Typo: replace "2^d levels" (at the end) by "a few levels"...Horasehttps://www.blogger.com/profile/18030308390304035463noreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-67442986770366330262009-03-31T02:46:00.000-04:002009-03-31T02:46:00.000-04:00Here is a simple heuristic. It does not seem very ...Here is a simple heuristic. It does not seem very useful, but anyway. It gives a lower bound on the advantage the first player can get. V[1..2n] is the current state of the list. B(V) is the best advantage doable by first player starting the game on V. A(V) is the absolute value of the sum of odd elements minus sum of even elements. V[i..j] is the sublist from index i to index j.<BR/><BR/>Now, compute L(V) = max{min(A(V[2..2n-1])+V[1]-V[2n] , A(V[3..2n])+V[1]-V[2]) , min(A(V[2..2n-1])+V[2n]-V[1] , A(V[1..2n-2])+V[2n]-V[2n-1]) }<BR/><BR/>Then B(V) >= L(V), i.e., the sum of the current advantage, and L(V) gives you a lower of the final advantage for the first player, who can choose to remove the element that raises the lower bound the most. Maybe the only interest of the heuristic is that it takes linear preprocessing time and constant time per round (in a round, the two players play).<BR/><BR/>Since it is fast, the heuristic can be extended to explore 2^d level of the game-tree at each round. Can it be useful for solving the problem in o(n^2) time? Can we compute an upper bound in the same fashion?Samuelnoreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-45901299665331477572009-03-30T16:39:00.000-04:002009-03-30T16:39:00.000-04:00Mihai: Ah! Sorry about the misread.Mihai: Ah! Sorry about the misread.Charlesnoreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-24351823530158107112009-03-30T07:32:00.000-04:002009-03-30T07:32:00.000-04:00Say if it were the case that O(n) algorithm does n...Say if it were the case that O(n) algorithm does not exist. How do you go about proving such a result. Any ideas?ashwin kumar b vhttps://www.blogger.com/profile/07777870747608944808noreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-29966020712651598882009-03-29T15:57:00.000-04:002009-03-29T15:57:00.000-04:00Charles: Yes, of course. o(n^2) means "better than...Charles: Yes, of course. <BR/><BR/>o(n^2) means "better than n^2".Mihaihttps://www.blogger.com/profile/11599372864611039927noreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-79020664106022909112009-03-29T15:39:00.000-04:002009-03-29T15:39:00.000-04:00If we can determine optimal values, it's straightf...If we can determine optimal values, it's straightforward to extend the algorithm to determine optimal moves.<BR/><BR/>Then we can just play out the optimal "game" and see what the outcome has to be. If it's a draw, then P1, under best play, will draw or win. If it's a lose, then P1, under best play, could either lose, draw, or win. If it's a win, then P1 will have to win.<BR/><BR/>Many people have already remarked we can determine optimal values in O(n^2) time, so determining the outcome will be on the same order.Charlesnoreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-64287257801255205132009-03-29T01:07:00.000-04:002009-03-29T01:07:00.000-04:00Say the odd and even sums are equal. Determining t...Say the odd and even sums are equal. Determining the outcome (draw vs 1st player wins) in o(n^2) time seems interesting. I don't see how to do it yet.<BR/><BR/>In the same spirit, can we determine the optimal value for the first player in o(n^2)?Mihaihttps://www.blogger.com/profile/11599372864611039927noreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-76431646617146657112009-03-28T15:47:00.000-04:002009-03-28T15:47:00.000-04:00I spoke too early. The O(n^2) I described doesn't ...I spoke too early. The O(n^2) I described doesn't work but another one does: consider M(i,j) the maximum advantage that a player can obtain when playing first on a queue composed of V[i],...V[j]. M(i,j) = max(V[i]-M(i+1,j), V[j]-M(i,j-1)). We start with M(i,i) = V[i] and we fill the diagonals until we compute M(1,n).<BR/><BR/>But (as Anonymous indicated) this is only needed when the sum of numbers with odd index is equal to sum of numbers with even index.<BR/><BR/>About the chocolate problem: the player that eats the poisoned corner dies. :P A player can stay alive if he can leave the chocolate in a squarish shape after his move. This doesn't hold if the poisoned square is not in a corner. ;-)RMEhttps://www.blogger.com/profile/01918334756162531030noreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-63809724441438556452009-03-28T13:55:00.000-04:002009-03-28T13:55:00.000-04:00A similar problem: Two players have a chocolate wi...A similar problem: Two players have a chocolate with MxN squares. A move consists of (1) breaking the chocolate along a horizontal or along a vertical and (2) eating one of the two pieces. If only one square remains then it must be eaten. The bottom-right corner is poisoned. Who dies?rgrighttps://www.blogger.com/profile/02991214367108471744noreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-61017165118947456912009-03-28T00:58:00.000-04:002009-03-28T00:58:00.000-04:00under some assumption first player always wins. P1...under some assumption first player always wins. P1 takes sum of all odd indexed elements and even indexed elements and forces P2 to always choose element with index odd or even depending on which sum is smallest.<BR/><BR/>If sum of numbers with odd index is equal to sum of numbers with even index then some times P1 can force a win and some times P2 can force a draw. This can be found by a dynamic programming algorithm which runs in O(n^2) time.<BR/><BR/>I thought if we can get an algorithm which runs in O(n) time and finds the solution even when the sums are equal. Any ideas?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-53430065836488874752009-03-27T22:46:00.000-04:002009-03-27T22:46:00.000-04:00This problem is more fun when posed as a pizza: A ...This problem is more fun when posed as a pizza: A pizza has an even number (1000?) of slices, of varying size. Players take turns taking slices: the first player can take any slice, but subsequent moves must take from the open end of the pizza. So its exactly the same as your problem, except the first player gets to choose where to define the ends of the queue. The goal is to take the most pizza. Since it is an even number of slices, we can two-color them. Either the red slices or the blue slices constitute a majority of the pizza, and the first player can guarantee he takes all slices of one color, thereby winning.<BR/><BR/>This problem becomes much harder when there are an -odd- number of slices: the two coloring trick no longer works. But of course as a two player game of perfect information, it must be that either the first player or the second player always can guarantee at least a draw. Who is it? What is the winning strategy?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-48011393325712303982009-03-27T20:13:00.000-04:002009-03-27T20:13:00.000-04:00We can assume that the elements are revealed at th...We can assume that the elements are revealed at the beginning, right? :-) If that's the case then the first player can determine in O(n^2) the winning strategy. He can do this by finding in linear time what is the best strategy to leave each element as the last one be picked.RMEhttps://www.blogger.com/profile/01918334756162531030noreply@blogger.comtag:blogger.com,1999:blog-786333285568106173.post-19341903573017994122009-03-27T19:09:00.000-04:002009-03-27T19:09:00.000-04:00Second player can't win.Second player can't win.rgrighttps://www.blogger.com/profile/02991214367108471744noreply@blogger.com