You are implementing a board game where you are given a size M x N for the board, where M is the number of rows and N is the number of columns. In this board game you are playing with some fixed size lego pieces (2x4), where each player places i piece on the board every turn until no more piece can fit onto the board, and the last player to move wins. The problem is to implement a method for making a move on this board, placing a piece wherever there is space available, and returns a boolean indicating whether or not the player that has just made the move has won. Follow up question: The method should also find if there is any move that can be made that will make it so that the next player is unable to place a piece anywhere on the board in their next turn, and make that move. You choose how to represcnt the board and lego pieces in the problem, during my interview I chose to use a 2D array of booleans for the board, where each boolean indicates whether that spot on the board is occupied, and for the lego piece I asked the interviewer if I could assume the lego piece would be rectangular, which he agreed to. Simple example (small board for demonstration purposes, board length = 2 x 3, lego piece length = I x 2): Empty Board: 000 000 Board after player i makes move, placing lego piece at top right corner: OXX 000 At this point, player 2 can make a move that will prevent player 1 from placing another piece: ОХХ XXO and so the method should be able to find and make that winning move, rather than an alternative move that would miss an opportunity for a win: OXX ОХХ
You are implementing a board game where you are given a size M x N for the board, where M is the number of rows and N is the number of columns. In this board game you are playing with some fixed size lego pieces (2x4), where each player places i piece on the board every turn until no more piece can fit onto the board, and the last player to move wins. The problem is to implement a method for making a move on this board, placing a piece wherever there is space available, and returns a boolean indicating whether or not the player that has just made the move has won. Follow up question: The method should also find if there is any move that can be made that will make it so that the next player is unable to place a piece anywhere on the board in their next turn, and make that move. You choose how to represcnt the board and lego pieces in the problem, during my interview I chose to use a 2D array of booleans for the board, where each boolean indicates whether that spot on the board is occupied, and for the lego piece I asked the interviewer if I could assume the lego piece would be rectangular, which he agreed to. Simple example (small board for demonstration purposes, board length = 2 x 3, lego piece length = I x 2): Empty Board: 000 000 Board after player i makes move, placing lego piece at top right corner: OXX 000 At this point, player 2 can make a move that will prevent player 1 from placing another piece: ОХХ XXO and so the method should be able to find and make that winning move, rather than an alternative move that would miss an opportunity for a win: OXX ОХХ
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
If answered wrong i will downvote it
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 3 steps
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY