#NEWLINE# def subset_sum( x , R ) : #NEWLINE# #INDENT# 'Subsetsum\n\n    :param x: table of non negative values\n    :param R: target value\n    :returns bool: True if a subset of x sums to R\n    :complexity: O(n*R)\n    ' #NEWLINE# b = ( [ False ] * ( xi + 1 ) ) #NEWLINE# b [ 0 ] = True #NEWLINE# for xi in x : #NEWLINE# #INDENT# for s in range ( R , ( xi - 1 ) , ( - 1 ) ) : #NEWLINE# #INDENT# b [ s ] |= b [ ( s - xi ) ] #NEWLINE# #UNINDENT# #UNINDENT# return b [ R ]