Question: Write a function dream_score(matrix) that takes in a list of lists, and returns the maximum possible score as an integer. You may assume the following:

Write a function dream_score(matrix) that takes in a list of lists, and returns the maximum possible score as an integer. You may assume the following:

  1. The turtle can "teleport" to any cell.
  2. Each cell can only be visited "once".
  3. You do not need to visit each cell (such as traps).
  4. There may be an item or trap on the goal.

Eve will always travel from the cave entrance to the goal, so items or traps on the goal (assumption 4) must still be taken into account.

The parameters to this function are as follows:

  • matrix is a list of lists, where the "outer lists" denote rows and "inner lists" denote columns. Each cell is given an integer value denoting the "score" in the cell.

Input Assumptions:

  • You can assume that the input arguments are syntactically correct given the definitions, and will always be non-empty (i.e a minimum grid size of 11).

Here are example calls to your function:

dream_score([[0, -1000, 0, 0 , 0], [0, 0, 150, 0, -1000], [0, -1000, 1000, -1000, 0], [-1000, 1000, -1000, -150, 0], [1000, 150, 0, 0, -150]])
>>> 3150
dream_score([[0, 150, 150, 150], [150, 150, 150, 150], [150, 150, 150, 150], [150, 150, 150, 150]])
>>> 2250
dream_score([[0, 0, 0], [0, -1000, 0], [-150, 0, 0]])
>>> 0

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!