Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/283.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
请将我的伪代码转换为工作的Python程序_Python_Python 3.x - Fatal编程技术网

请将我的伪代码转换为工作的Python程序

请将我的伪代码转换为工作的Python程序,python,python-3.x,Python,Python 3.x,我一直在研究下面给出的问题 给定一组S={x1,x2,…,xn}的整数和一个称为target的整数t,确定S的子集的和是否等于t 有人能把我的伪代码转换成一个能工作的Python程序吗 If L is a set of integers and x is another integer, then we use the shorthand L + x to denote the list of integers derived from L by increasing each element

我一直在研究下面给出的问题

给定一组S={x1,x2,…,xn}的整数和一个称为target的整数t,确定S的子集的和是否等于t

有人能把我的伪代码转换成一个能工作的Python程序吗

If L is a set of integers and x is another integer, then we use the shorthand L + x to denote the list of integers derived from L by increasing each element of L by x, i.e. L + x = {`k + x | `k ∈ L}. For example, if L = {1, 5, 9}, then L + 3 = {4, 8, 12}.
下面是基于动态规划方法的SSP伪代码

1:    L ← {0}
2:    for x ∈ {x1, . . . , xn} do
3:        L ← L ∪ (L + x)
4:        remove from L every element that is greater than t
5:     end for
6:     return True if t ∈ L, False otherwise

首先,不,我们不能将其转换为可供您使用的Python代码。那是作弊

在代数上,结果要容易得多。目标是可以实现的

目标可以被x整除;和
目标欢迎来到StackOverflow。请阅读并遵循帮助文档中的发布指南。适用于这里。在您发布代码并准确描述问题之前,我们无法有效地帮助您。StackOverflow不是编码或教程服务。