subject

Can someone please help me with this PYTHON problem! please answer with code! the only parts that you need to change have # YOUR CODE HERE Subset Product¶
This next one asks you to employ a common recursive pattern — that of computing all the subsets of a given set of things. In this problem, you are to determine whether or not an integer P>1P>1 can be compute as the product of any combination of a provided list of integers (where each factor f >0>0 can only be used once).
Examples:
given P=10P=10 , and the list [2, 3, 4, 5], we see that 2×5=102×5=10 , so the answer is yes
given P=81P=81 , and the list [2, 2, 3, 3, 4, 9], 3×3×9=813×3×9=81 , so the answer is yes
given P=100P=100 and the list [3, 4, 5, 8, 10], the answer is no
Complete the implementation of the recursive can_make_product, which returns True or False based on whether the argument p can be computed as the product of some subset of the list of integers vals.
In [ ]:
def can_make_product(p, vals):
# YOUR CODE HERE
raise NotImplementedError()
. . .
In [ ]:
# (5 points)
from unittest import TestCas
tc = TestCase()
tc. assertTrue(can_make_product(10, [2, 5]))
tc. assertTrue(can_make_product(10, [2, 3, 4, 5]))
tc. assertTrue(can_make_product(10, [3, 4, 2, 5]))
tc. assertTrue(can_make_product(10, [10]))
tc. assertTrue(can_make_product(81, [2, 2, 3, 3, 4, 9]))
tc. assertTrue(can_make_product(66402, [2, 4, 5, 12, 17, 25, 31, 63]))
tc. assertFalse(can_make_product(10, [2, 2, 2, 4]))
tc. assertFalse(can_make_product(243, [2, 2, 3, 3, 3, 4, 4, 4]))
tc. assertFalse(can_make_product(81, [2, 3, 5, 9, 11]))
tc. assertFalse(can_make_product(100, [3, 4, 5, 8, 10]))
tc. assertFalse(can_make_product(12369, [3, 4, 5, 8, 19, 20, 31]))

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:40
Program using c++ only on visual studio pig is a simple two player dice game, played with one die. the first player to reach or surpass 50 is the winner. each player takes a turn rolling the dice. they add to the pot with each roll, having to decide to roll again and increase the pot, or cash out. the risk being they could lose the amount they’ve accumulated into the pot. the rules for each player’s die roll. 1. roll the dice. a. if user rolled a 1, i. the pot gets set to zero ii. the other player goes to step 1. b. a roll of 2-6 is added to the pot. 2. user can choose to hold or roll again. a. choice roll. return to step 1. b. choice hold. i. increment player score by the pot amount. ii. pot gets set to 0. iii. second player gets to roll and goes to step 1. program requirements: ● before each opponent begins ○ output the score for the person and the computer. ○ output the opponents whose turn is beginning and ask the user to hit enter to continue. ● with each dice roll. ○ output the die value, and amount of the round pot. ○ if it’s the users roll ask if they want to roll again ( r ) or hold ( h ). your program should allow r, r, h or h as valid input. if input is anything else, ask the user again until valid input is obtained. ○ the ai will continue playing until the round pot is 20 or more. ● once a player’s score is greater or equal to 50 then they have won, it will no longer ask if they want to keep rolling the die or not. ● once there is a winner ○ score totals are output along with who the winner was. user or computer ○ player is asked if they want to play again y or n. valid input should be y, y, or n, n. ● when a new game starts the starting roll goes to the player that did not roll last. if the user rolled last in the previous game, then the computer rolls first and vice versa. when the program first begins, the player will make the first roll of the first game. development notes : ● you will need a way to roll dice in your program. the rand() function works well, but returns an integer. if we want numbers 0 – 9 we can get the value modulus 10. ● call srand() with a value to seed it. it’s common to seed it with the current computer clock, include ctime, and then call srand(time(
Answers: 1
question
Computers and Technology, 22.06.2019 17:00
Acase study allows a more detailed look at the life of a single subject than any other study.
Answers: 3
question
Computers and Technology, 23.06.2019 17:00
1. which of the following is not an example of an objective question? a. multiple choice. b. essay. c. true/false. d. matching 2. why is it important to recognize the key word in the essay question? a. it will provide the answer to the essay. b. it will show you a friend's answer. c. it will provide you time to look for the answer. d. it will guide you on which kind of answer is required.
Answers: 1
question
Computers and Technology, 24.06.2019 00:30
Match the sentence fragment in the first column with the appropriate ending in the second column. a little per favore?
Answers: 1
You know the right answer?
Can someone please help me with this PYTHON problem! please answer with code! the only parts that yo...
Questions
question
English, 04.04.2020 10:34
question
English, 04.04.2020 10:35
question
History, 04.04.2020 10:35
Questions on the website: 13722360