Question: Consider the following two-player game, played on a long bar of chocolate with two rows of little squares. On each turn, a player takes

Consider the following two-player game, played on a long bar of chocolate 

Consider the following two-player game, played on a long bar of chocolate with two rows of little squares. On each turn, a player takes a rectangular-shaped "bite" out of the chocolate by choosing a square and removing it, and every square which is any number of squares below and/or to the right of that square. The top-left square is a really bitter dark chocolate and the player who eats it loses. Every state of the game can be described by two numbers ab, where a and b are the number of squares remaining in the top and bottom rows, respectively. Below are three of the many possible moves when a 6, b = 3: - A state is said to be winning if the player whose turn it is has a guaranteed winning strategy (no matter what their opponent does), and losing otherwise. By default, a = b = 0 is winning, since in the previous turn, their opponent must have eaten the bitter chocolate. A more complicated winning state would be a = b = 2. In this state, the winning strategy would be to just take a bite out of the bottom-right square to get a = 2, b = 1. Here's one way that this can play out: P1 P1 P2, e.g. Design a backtracking algorithm for solving the following problem: "Given a state (a, b), return TRUE if it's winning, and FALSE otherwise." Your algorithm should be a pure, boolean-valued function of the form: CHOC(a, b): // your code here

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The goal is to avoid eating the bitter chocolate at the topleft corner The challenge is to determine whether a given state aba b is a winning or losin... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related General Management Questions!