Question: Using R programming: You are a smart thief. You plan to steal money from houses along a street. There are n houses along a street,

Using R programming:

You are a smart thief. You plan to steal money from houses along a street.

There are n houses along a street, each house has certain amount of cash stashed.

You want to steal as much money as possible. However, adjacent houses have security system connected and it will automatically contact the police if two adjacent houses were both broken into.

Given a sequence of non-negative integers representing the amount of money of each house, determine the maximum amount of money you can steal without alerting the police.

Write an R function that takes the amount of money of each house as input, and the following as outputs: (1) the maximum amount you can steal. (2) the strategy (stealing /not stealing each house) to achieve the maximum amount.

Test your function using the input:

set.seed(250) House.money = round(runif(n=100, min=10, max=1000),digits=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!