Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Finding a configuration Recall the suitcase-packing problem from the lecture. We are going to turn the problem around and ask instead: given a coin purse

Finding a configuration

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 Weight
0 leah 1/8
1 shiblum 1/4
2 shiblon 1/2
3 senine 1
4 antion 1
5 seon 2
6 shum 4
7 limnah 7

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 lists.

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.

Your submission should include a function find_coins( weight ).

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

What do Dimensions represent in OLAP Cubes?

Answered: 1 week ago