Everything is ready except that they need some resistors in their main circuits! For each drone, it needs two extra resistors that must be connected in series to produce the desired total resistance. Namely, total resistance R=R₁+R₂ R₁ R₂ For example, if you need a total resistance of 10 ohms, you can connect two resistors with resistances 2 ohms and 8 ohms, or another pair of 3 ohms and 7 ohms. You are given as many drones as possible, and they all need the same resistance R. In your hands, you are given a lot of

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

please answer the question using python coding

Question 2: Finding Resistor Pairs
We are going to fly a lot of drones to scout out an area!
Everything is ready except that they need some resistors in their main circuits! For each drone, it needs two extra
resistors that must be connected in series to produce the desired total resistance. Namely, total resistance R = R₁ + R₂.
amm
R₁
R₂
For example, if you need a total resistance of 10 ohms, you can connect two resistors with resistances 2 ohms and 8
ohms, or another pair of 3 ohms and 7 ohms.
You are given as many drones as possible, and they all need the same resistance R. In your hands, you are given a lot of
resistors such that every resistor is unique and none of them has the same resistance with each other (Note that we will
relax this uniqueness requirement in the later part). And of course, every resistor has a positive non-zero integer value
of resistance. Your task is, given a tuple that contains the resistance values of all the resistors, find out all the pairs of
resistors that can produce a total sum of R ohms. For example, if you have a tuple of resistors:
resistorList = (75,80,90,77,88,91,60,74,73,70,55,93,59)
You can call your function to find out what are the combinations for different total resistance. These two examples find
all the resistors that can sum up to 150 ohms and 152 ohms.
>>> print (matchResistors (resistorList, 150))
[(59, 91), (60, 90), (70, 80), (73, 77)]
>>> print (matchResistors (resistorList, 152))
[(59, 93), (75, 77)]
Standard
Write the function 'matchResistors (R, n)' to return a list of tuples L. And each of the tuple contains a pair of resistor
in the list L that sum up to R like the examples above.
Again, here are some rules for your function in order to gain full marks:
•
You cannot modify the original input. And your function should work with inputs of both lists and tuples. You
cannot hardcode the input
•
You cannot import any packages or functions but you may use any of the built-in functions and methods. You
may use sorted () function and .sort () method freely. However, you cannot use any set operations. (Believe
us, that is not helpful at all.)
• Every item in your output must be unique (in this part). Namely, you cannot output the same pair twice, even if
you swap the two values.
Transcribed Image Text:Question 2: Finding Resistor Pairs We are going to fly a lot of drones to scout out an area! Everything is ready except that they need some resistors in their main circuits! For each drone, it needs two extra resistors that must be connected in series to produce the desired total resistance. Namely, total resistance R = R₁ + R₂. amm R₁ R₂ For example, if you need a total resistance of 10 ohms, you can connect two resistors with resistances 2 ohms and 8 ohms, or another pair of 3 ohms and 7 ohms. You are given as many drones as possible, and they all need the same resistance R. In your hands, you are given a lot of resistors such that every resistor is unique and none of them has the same resistance with each other (Note that we will relax this uniqueness requirement in the later part). And of course, every resistor has a positive non-zero integer value of resistance. Your task is, given a tuple that contains the resistance values of all the resistors, find out all the pairs of resistors that can produce a total sum of R ohms. For example, if you have a tuple of resistors: resistorList = (75,80,90,77,88,91,60,74,73,70,55,93,59) You can call your function to find out what are the combinations for different total resistance. These two examples find all the resistors that can sum up to 150 ohms and 152 ohms. >>> print (matchResistors (resistorList, 150)) [(59, 91), (60, 90), (70, 80), (73, 77)] >>> print (matchResistors (resistorList, 152)) [(59, 93), (75, 77)] Standard Write the function 'matchResistors (R, n)' to return a list of tuples L. And each of the tuple contains a pair of resistor in the list L that sum up to R like the examples above. Again, here are some rules for your function in order to gain full marks: • You cannot modify the original input. And your function should work with inputs of both lists and tuples. You cannot hardcode the input • You cannot import any packages or functions but you may use any of the built-in functions and methods. You may use sorted () function and .sort () method freely. However, you cannot use any set operations. (Believe us, that is not helpful at all.) • Every item in your output must be unique (in this part). Namely, you cannot output the same pair twice, even if you swap the two values.
Your output may be in a different order, and that is ok. Coursemology checker (i.e., test_resistors) is doing
the job of checking any possible correct order for you.
The followings are two more tasks. We recommend you to make a backup for the above and just submit it in case you
cannot finish the following two parts.
Duplications
your function 'matchResistors (R,n)' can take in inputs with duplicate resistors. In other
words, the input may contains two resistors with the same value. Note that each resistor can still only be used at most
once. Hence, in the sample run below, once one of the 10 ohm resistor is used with a 12 ohm resistor, both are not
available anymore but since there is still another 10 ohm and another 12 ohm, we can still get another pair. However, if
your output has duplicates, they must have the correct number of copies.
>>> matchResistors ((10, 12, 40,12,10), 22)
[(10, 12), (10, 12)]
>>> matchResistors ((1,5,5,9,1), 10)
[(1, 9), (5, 5)]
Large Inputs (5 marks)
your function 'matchResistors (R, n)' can handle large cases, e.g. the length of the input
tuple > 1000000. (The function shuffle () is just used to create an example input list. Namely, it just randomly shuffle
the list.)
>>> from random import shuffle
>>> longlist = [i for i in range(1, 100000)]
>>> shuffle(longlist)
>>>print(len(matchResistors (longList, 10000)))
4999
Transcribed Image Text:Your output may be in a different order, and that is ok. Coursemology checker (i.e., test_resistors) is doing the job of checking any possible correct order for you. The followings are two more tasks. We recommend you to make a backup for the above and just submit it in case you cannot finish the following two parts. Duplications your function 'matchResistors (R,n)' can take in inputs with duplicate resistors. In other words, the input may contains two resistors with the same value. Note that each resistor can still only be used at most once. Hence, in the sample run below, once one of the 10 ohm resistor is used with a 12 ohm resistor, both are not available anymore but since there is still another 10 ohm and another 12 ohm, we can still get another pair. However, if your output has duplicates, they must have the correct number of copies. >>> matchResistors ((10, 12, 40,12,10), 22) [(10, 12), (10, 12)] >>> matchResistors ((1,5,5,9,1), 10) [(1, 9), (5, 5)] Large Inputs (5 marks) your function 'matchResistors (R, n)' can handle large cases, e.g. the length of the input tuple > 1000000. (The function shuffle () is just used to create an example input list. Namely, it just randomly shuffle the list.) >>> from random import shuffle >>> longlist = [i for i in range(1, 100000)] >>> shuffle(longlist) >>>print(len(matchResistors (longList, 10000))) 4999
Expert Solution
Step 1

Here is the answer below:-

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY