Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with my C++ intro class free write review. Having a hard time with the

ID: 3758193 • Letter: N

Question

Need help with my C++ intro class free write review. Having a hard time with the a 3-part gameplay question. Please Help.

Functions to write:

Question 3)

part A)

/**
* Requires: size <= MAX_SIZE and size is a positive even integer.
* Modifies: Nothing.
* Effects : Returns true if and only if the board has been solved,
*           i.e. all squares are RED or BLUE and the board does not
*           violate any of the rules of 0hh1.
* Used In : play_board()
*/

bool board_is_solved(const int board[MAX_SIZE][MAX_SIZE], int size);

Part B)

/**
* Requires: Nothing.
* Modifies: cout, row, col
* Effects : Checks if the input was valid: row_input is between 1 and
*           size inclusive, col_input is between A and (A + size - 1)
*           inclusive, and color_char is one of (X, O, x, o, -).
*           If input is invalid, prints an error message and returns
*           false.
*           Otherwise translates row_input and col_input to 0-indexed
*           row and column numbers, assigns them to row and col, and
*           returns true.
* Used In : make_move()
* Note    : The following message is printed as appropriate:
*           "Sorry, that's not a valid input." You might have to consider using toupper() library function at some point
*/

bool check_valid_input(int size, int row_input, char col_input,
                       char color_char, int &row, int &col);

Part C)

/**
* Requires: size <= MAX_SIZE and size is a positive even integer,
*           0 <= row && row < size && 0 <= col && col < size.
* Modifies: cout
* Effects : Returns true if and only if the specified square was not
*           set in the original board, and placing the given color in
*           the given square of the current board does not create an
*           invalid board. Prints messages informing the user that
*           original squares cannot be changed or that a move violates
*           a rule, as appropriate.
* Used In : make_move()
* Note    : The following messages are printed as appropriate:
*           "Sorry, original squares cannot be changed."
*           "Sorry, that move violates a rule."
*/

bool check_valid_move(const int original_board[MAX_SIZE][MAX_SIZE],
                      const int current_board[MAX_SIZE][MAX_SIZE],
                      int size, int row, int col, int color);

---------------------------------------------------------------------------------------

Really appreciate the help! Also any explaination will be very appreciated to help me understand this question. If you need more information, please do not hesitate to comment.

(note: please do not use system("Pause")

These links will be helpful to identify functions to call (assume these functions are already defined):

Utility.h

http://pastebin.com/3aYXfPCx    

Driver.h

http://pastebin.com/zHXcvnwA

Main.cpp

http://pastebin.com/3jyPuibc

Explanation / Answer

#include #include #include #include int main() { typedef std::uint64_t num; // ys[x] is the length of the chain starting at x. // xms is the set of numbers that yield the longest chains. // ym is the length of the longest chain so far. std::map ys = {{1,1}}; std::set xms = {1}; num ym = 1; for (num i = 2; i < 1000000; ++i) { std::stack xs; num x = i, y = ys[x]; // Compute successive chain elements until // a base element is reached whose chain // length has already been memoized. while (!y) { xs.push(x); x = (x & 1) ? (3*x + 1) : (x/2); y = ys[x]; } // The lengths of the newly computed elements // can be found by repeatedly incrementing // the base element's chain length. while (!xs.empty()) { x = xs.top(); ys[x] = ++y; xs.pop(); } // Keep track of which number(s) // yield the longest chain(s). if (y >= ym) { if (y > ym) { xms.clear(); ym = y; } xms.insert(x); } } for (num xm : xms) std::cout