Super Mario is on the run collecting coins. In level # 1, whenever he takes a coin, the next coin is automatically blocked with an iron brick. Which coins should Mario take in order to maximize his gains?(see image) In level # 2, the same rules of level 1 apply, but with a twist: Mario has a bag that can take only a limited number of coins. Which coins can Mario take in order to maximize his gains (provided that the coins fit inside his bag)? Implement the following function for level# 2 using C++:

Np Ms Office 365/Excel 2016 I Ntermed
1st Edition
ISBN:9781337508841
Author:Carey
Publisher:Carey
Chapter8: Working With Advanced Functions
Section: Chapter Questions
Problem 2.8CP
icon
Related questions
Question

Do in C++ programming

Super Mario is on the run collecting coins. In level # 1, whenever he takes a coin, the next coin is automatically blocked with an iron brick. Which coins should Mario take in order to maximize his gains?(see image)

In level # 2, the same rules of level 1 apply, but with a twist:

Mario has a bag that can take only a limited number of coins. Which coins can Mario take in order to maximize his gains (provided that the coins fit inside his bag)?

Implement the following function for level# 2 using C++:

  • unsigned max_coins(vector<unsigned> coins, unsigned capacity)

$3
3$
(0)
skip Take
$9
$9 $2
$7
Take
$7
$3 $6 $9
6$
skip Take
$9
$1
= $25
Transcribed Image Text:$3 3$ (0) skip Take $9 $9 $2 $7 Take $7 $3 $6 $9 6$ skip Take $9 $1 = $25
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Topological Sort
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr