Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Switching cities python code knowledge required PLEASE PROVIDE SCREEN SHOTS OF CODE FOR THIS PROBLEM I HAVE COMPLETED PART OF THE CODE FOR YOU JUST

Switching cities python code knowledge required PLEASE PROVIDE SCREEN SHOTS OF CODE FOR THIS PROBLEM I HAVE COMPLETED PART OF THE CODE FOR YOU JUST FILL IN THE PORTION OF CODE THATS NEEDED FOR goodfeedback thanks

image text in transcribed

image text in transcribed

import sys

def cities(months, switchingCost, profitInCity1, profitInCity2): # # Please write code here # profit = 0 cityList = [1 for i in range(months)] return profit,cityList

# Read input header = sys.stdin.readline().strip(' ').split(' ') city1 = sys.stdin.readline().strip(' ').split(' ') city1 = [int(x) for x in city1] city2 = sys.stdin.readline().strip(' ').split(' ') city2 = [int(x) for x in city2]

profit,cityList = cities(int(header[0]), int(header[1]), city1, city2) listString = ' '.join(str(x) for x in cityList)

print profit # max profit print listString # cities

Please do not use approach (memoization) for this problem, as the system won't allow recursive functions to go deep enough. to ATTENTION: This problem is slightly different from the description in the homework handout. For the programming part, assume that the journey should start at city 1 You can still relocate to city 2 right away (and earn the profit of the first month in city 2), although, you have to pay relocation cost for that You are running a business in two cities. At the beginning of each month, you have the choice of spending the whole month in city 1 or city 2, and at the end of each month, you earn money based on the city you spent the month in and the month in question (profit can be different for different months/cities n addition, changing location from city 1 to city 2 has a constant cost you need pay, every time you want to do it. For example, you may operate your business out of city 1 during the first month, and then pay the relocation cost and move to city 2 to spend the second month there, and so on Your job is to calculate the maximum possible profit from your business assuming you start the journey in city 1 Note that starter code takes care of reading the input and printing the output. You only need to complete the function in cities. py that receives the parameters as argument, and returns the requested "max profit" value and list cities you are staying in your function consists of 4 parameters: months: the total number of months for which your business will be operating switching Cost: the relocation cost profitInCity1: a list of integers representing the monthly profits while in city 1 (size is "months") profitlnCity2: a list of integers representing the monthly profits while in city 2 (size is "months

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_2

Step: 3

blur-text-image_3

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

Hands-On Database

Authors: Steve Conger

2nd Edition

0133024415, 978-0133024418

More Books

Students also viewed these Databases questions

Question

prepare a flexible budget for the laundry department

Answered: 1 week ago

Question

What Is acidity?

Answered: 1 week ago

Question

Explain the principles of delegation

Answered: 1 week ago

Question

State the importance of motivation

Answered: 1 week ago

Question

Discuss the various steps involved in the process of planning

Answered: 1 week ago

Question

What are the challenges associated with tunneling in urban areas?

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago