Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

solve this in python. i have 40 mins in hand before it's due Anche input/16287 The game of jump consists of a board with n

image text in transcribed
image text in transcribed
solve this in python. i have 40 mins in hand before it's due
Anche input/16287 The game of jump consists of a board with n positive integers in a row except for the first column, which always contains zero. These numbers represent the cost to enter each column. Here is a sample came board where is 6 030 657 10 The object of the games to move from the first column to the last column in the lowest total cost. The number in each column represents the cost to enter that column. You aways start the game in the firsu colunt and have two types of moves. You can either move to the adjacent column or jump over the adjacent column to land two columns over. The cost of a game is the sum of the costs of the visited columns in the board shown above, there are several ways to get to the end. Starting in the first column cur cost so far is . We could jump to 80, then jump to 57, then move to 10 for a total of 80 +57.10 - 147 However, a cheaper path would be to move to 3.mp to the jump to 16, for a total cost of 3.6.10.19 Write a recursive solution to this problem that computes the cheapest cost of the game and outputs this value for an arbitrary large game board represented as a list. Because the program can take long time to run on large boards you can assure that the board site is at most 50 columns. Your program does need to output the actual sequence of moves, only the cheapest cost of this sequence Your program must read input from a text file named input.txt and must send output to stdout the computer's screen. The input file consists of a sequence of ines, where each line corresponds to a board. The numbers on a line are the costs to enter the columns on the board. For example, the above board is represented in the input file as 03 8065710 Sample input file is as follows 031055710 098 744 253585 46 4 052598394220 6 2049965374377 0 24 1715 61096186543 26 19 757 9750 936 252 The corresponding output is as follows: 19 87 138 185 333 Please make sure to write your code in functions. No code should be written outside of functions. Use comments to document and explain your code where needed. For full credit your program must follow the problem specifications precisely. A program that does not run will not receive a trade above 60 Please make sure to rate your file LastName First Name HW2.py when you upload it to blackboard Apps M Gmail 0 Outlook YouTube Maps M MyMSU 05 75 743 11 0 380 657 10 098 7 44 25 3 5 85 46 4 0 57 59 83 9 42 70 0 20 49 96 53 7 43 77 0 24 17 15 61 49 61 8 65 43 26 997 57 97 50 93 6 82 52

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

Recommended Textbook for

More Books

Students also viewed these Databases questions