Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please write in Python. Recall the suitcase-packing problem from the lecture. We are going to turn the problem around and ask instead: given a coin

image text in transcribedPlease write in Python.

Recall the suitcase-packing problem from the lecture. We are going to turn the problem around and ask instead: given a coin purse of known weight and a set of possible coins, which possible sets of coins satisfy this weight? We consider a set of coins with the following possible weights and names. (We don't need the names, but it's easier to talk about in troubleshooting.) If they are minted gold tokens their weight is synonymous with their value Index Coin Welght 1/8 shiblum shiblon 1/2 senine 4 antion 1% seon 6 shum imnah Compose a function find_coins( weight which accepts a weight and finds all sets of coins that could yield that weight, returning these as a list of list s. Note that coins could be repeated; that is, for a weight of 1 we could have 8 leahs, 4 shiblums, or 4 leahs and 2 shiblums. To limit this, we will say that we only allow a maximum of twelve coins in a candidate solution. itertools.combinations will not allow repeated items; you instead need to use itertools.combinations_with_replacement. A brute-force search is acceptable Some test cases are >>> find_coins( 0.25 >>> find_coins( e.5 >>> find_coins( 1.5) (e, e, e, e, 3), (e, e, e, e, 2, 2), (e, e, e, e, e, e, e, e, 2), (e, e, e, e, 6, 6, 6, e, e, e, 1), (e, e, e, e, e, e, e, e, e, e, e, e)]

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

Students also viewed these Databases questions

Question

LOQ 3-8: What are sleeps functions?

Answered: 1 week ago