Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

the 3 part of picture is one problem you should answer a and b part Your friend is developing a board game. They have come

the 3 part of picture is one problem you should answer a and b part

image text in transcribedimage text in transcribedimage text in transcribed
Your friend is developing a board game. They have come up with the following design of the board as below, it is a sequence of integers in a row coloured either green or red. I 2 3 -i 5 6 i" ll 9 ID- II I2 I3 H IS IS I? D I! I9 Each player has a token they can use to move around the board. The rules are as follows: 0 The player can choose any square to start from. 0 If the square is green, they must move right {by any number of squares} to a square with a number greater than their current one. 0 If the square is red, they must move left (by any number of squares) to a square with a number greater than their current one. 0 This is repeated until no moves are available, then the player is nished. ' When all players are nished, the player who had the most moves wins. Your task is to design an algorithm using dynamic programming to always win this game, given a specied board layout as input. Namely, your algorithm will receive an array of n integers A[0...n 1] and an array of n colours C[0...n 1] E[r,-..], corresponding to the integer in the cell with the same index. Your algorithm should return a sequence of indices I[0...k 1] which represents the longest sequence of moves possible in the game (the indices of the cells where the player places their token in the order in which it is doneL More formally, it is the longest sub-sequence of the board layout satisfying: More formally, it is the longest sub-sequence of the board layout satisfying: . 0 I[j]. . If C[I [j]] is red, then I[j + 1]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Programming questions