algorithm - Represent a number as a sum of a subset of an array -
given natural number s>10, generate array of n natural numbers = (a1, a2, …, ak, …, an) such s sum of m ai. constraint 1: ai < s/2 constraint 2: m >= k constraint 3 (optional): ai != aj sorry, i’m not sure how describe problem using proper mathematical notation, idea simple: generate values add pre-defined total. , add more values (“decoys” were) make task of selecting right values use more difficult. let's s=18 , want represented sum of @ least 3 values. so, "winning" array a=(7,8,3,4,5) because 7+8+3=18 , there's no way use less 3 values 18. i have simple algorithm kinda works: input: s - sum k - number of values required add s n - total number of values (includes decoys) output: - array of values ai 1) generate k values dividing s k , adding , subtracting random numbers. ensures ai more or less random while still adding s. 2) generate (n-k) random values less s/2 each. 3) combine generated values 1 array a. 4) test s can repres...