Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please solve using Matlab . To receive a thumbs up DO NOT USE ITERATIONS(loops) IN SOLUTION CODE!!!! Function Name: geoffCollins Inputs: 1. (char) A 5x10
Please solve using Matlab. To receive a thumbs up DO NOT USE ITERATIONS(loops) IN SOLUTION CODE!!!!
Function Name: geoffCollins Inputs: 1. (char) A 5x10 character array representing a football field and associated players Outputs: 1. (char) An updated 5x10 character array representing the field, players, and path of the football after the play is run 2. (char) A statement describing the outcome of the play Topics: (control flow), (nested conditionals), (masking), (RHS and LHS indexing) Background: 4th quarter. 12 seconds left on the clock. It's 4th and goal for the College Football Playoff National Championship against Alabama. Geoff scans his playbook one last time and then looks up, a mischievous twinkle in his eyes. He knows what to do. JK. It's 4th and 26, halfway down the field, and Tech is facing the Citadel, hoping to pull out a single win for the year. Geoff pulls his 404 The Culture cap further over his eyes and crosses his arms over his playbook. No amount of preparation can save the Jackets now. He summons the spirit of Paul Johnson, smacks his quarterback's bum as the offense takes the field, and crosses his fingers. Function Description: You are given a football field represented by a 5x10 character array. The quarterback (the starting position of the football) is represented by the character 'Q'. Any receivers that exist will be represented by the character 'R'. Any defenders that exist will be represented by the character 'D'. Any open spaces will be represented by the space character. The 'o' is guaranteed to be in the first row of the array. The objective is to move the ball to the bottom row of the array. There are two potential plays you can make, prioritized in this order: 1. The quarterback can throw the ball to a receiver. The receiver must be located EXACTLY 4 indices away from the quarterback, exclusive, either straight down, towards the bottom-left diagonal, or towards the bottom-right diagonal. If a receiver is located in one of these positions, the play is successful. However, if one or more defenders are located directly adjacent to the receiver, not including diagonals (left one index, right one index, or "down" one index (up the array)), the play is blocked. If no receivers are located exactly 4 indices away, this play cannot be used. 2. The quarterback can run straight down the field. The quarterback moves down the column he was originally located in until reaching the bottom row or encountering a defender. If he reaches the bottom row, the play is successful. If a defender is located in the quarterback's path once he begins running, the play is blocked. If a defender is If the play fails, output: 'Even Paul Johnson can't face impossible odds.' Examples: fieldl = D R DR [outi, senti] = geoffCollins (fieldl) outi X R DX sentl 'The quarterback threw the ball and the play was blocked field2 = DO R 1 D D [out2, sent2] geoffCollins (field2) out 2 DX X X XR DXD sent2 + 'The quarterback ran the ball and the play was successful.' Motaan Notes: If there are multiple receivers on the field, a maximum of one is guaranteed to be located at the correct throwing range. You do not have to worry about indexing out of bounds when checking for the locations of the potential receivers, or the defenders potentially blocking the receivers. You do not have to worry about changing a defender potentially blocking a receiver to an 'X' before checking if the play was successful or blocked (this would only occur if the ball was thrown straight down and a defender was located exactly above the receiver). This situation will not be included. A receiver will never block the path of a running quarterback. Hints: The find() function may be useful to find the starting location of the quarterback. . Try to create your own scenarios and test them against the solution code to make sure your code passes more than just the three given test cases! Function Name: geoffCollins Inputs: 1. (char) A 5x10 character array representing a football field and associated players Outputs: 1. (char) An updated 5x10 character array representing the field, players, and path of the football after the play is run 2. (char) A statement describing the outcome of the play Topics: (control flow), (nested conditionals), (masking), (RHS and LHS indexing) Background: 4th quarter. 12 seconds left on the clock. It's 4th and goal for the College Football Playoff National Championship against Alabama. Geoff scans his playbook one last time and then looks up, a mischievous twinkle in his eyes. He knows what to do. JK. It's 4th and 26, halfway down the field, and Tech is facing the Citadel, hoping to pull out a single win for the year. Geoff pulls his 404 The Culture cap further over his eyes and crosses his arms over his playbook. No amount of preparation can save the Jackets now. He summons the spirit of Paul Johnson, smacks his quarterback's bum as the offense takes the field, and crosses his fingers. Function Description: You are given a football field represented by a 5x10 character array. The quarterback (the starting position of the football) is represented by the character 'Q'. Any receivers that exist will be represented by the character 'R'. Any defenders that exist will be represented by the character 'D'. Any open spaces will be represented by the space character. The 'o' is guaranteed to be in the first row of the array. The objective is to move the ball to the bottom row of the array. There are two potential plays you can make, prioritized in this order: 1. The quarterback can throw the ball to a receiver. The receiver must be located EXACTLY 4 indices away from the quarterback, exclusive, either straight down, towards the bottom-left diagonal, or towards the bottom-right diagonal. If a receiver is located in one of these positions, the play is successful. However, if one or more defenders are located directly adjacent to the receiver, not including diagonals (left one index, right one index, or "down" one index (up the array)), the play is blocked. If no receivers are located exactly 4 indices away, this play cannot be used. 2. The quarterback can run straight down the field. The quarterback moves down the column he was originally located in until reaching the bottom row or encountering a defender. If he reaches the bottom row, the play is successful. If a defender is located in the quarterback's path once he begins running, the play is blocked. If a defender is If the play fails, output: 'Even Paul Johnson can't face impossible odds.' Examples: fieldl = D R DR [outi, senti] = geoffCollins (fieldl) outi X R DX sentl 'The quarterback threw the ball and the play was blocked field2 = DO R 1 D D [out2, sent2] geoffCollins (field2) out 2 DX X X XR DXD sent2 + 'The quarterback ran the ball and the play was successful.' Motaan Notes: If there are multiple receivers on the field, a maximum of one is guaranteed to be located at the correct throwing range. You do not have to worry about indexing out of bounds when checking for the locations of the potential receivers, or the defenders potentially blocking the receivers. You do not have to worry about changing a defender potentially blocking a receiver to an 'X' before checking if the play was successful or blocked (this would only occur if the ball was thrown straight down and a defender was located exactly above the receiver). This situation will not be included. A receiver will never block the path of a running quarterback. Hints: The find() function may be useful to find the starting location of the quarterback. . Try to create your own scenarios and test them against the solution code to make sure your code passes more than just the three given test casesStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started