-2
我一直在看下面请转换我的伪代码的工作Python程序
给出的问题给定一组S = {X1,X2,。 。 。 ,xn},整数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
欢迎来到StackOverflow。请阅读并遵守帮助文档中的发布准则。 [最小,完整,可验证的示例](http://stackoverflow.com/help/mcve)适用于此处。在您发布代码并准确描述问题之前,我们无法有效帮助您。 StackOverflow不是一个编码或教程服务。 – Prune