Question: You are given a list containing tuples. Each tuple has 2 digits, each between 0 and 9. For example, here is a list with two

You are given a list containing tuples. Each tuple has 2 digits, each between 0 and 9.

For example, here is a list with two tuples. [(1,2), (5,1)]. You are to use the tuples to construct a sequence of numbers. The meaning of each tuple s as follows: (the digit to be used, how many times).

In the example above you have two tuples, so you need to construct a generator to produce the next number, in increasing numerical order, where each number you generate has exactly two ones (1,2) and one five (5,1). You can use as many zeros as needed to generate the next number. So, for this example, the first few numbers generated would be 115, 151, 511, 1015, 1051,

Question:

Write a generator

def nextOne(s):

Where s is the list of tuples

For the purpose of this problem, you may assume that each input list has only two tuples.

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!