Skip to content

Latest commit

 

History

History
36 lines (19 loc) · 1.08 KB

File metadata and controls

36 lines (19 loc) · 1.08 KB

Subset Selection Problem

Problem Description

Find all the subsets from a set of numbers whose sum is zero. Constraint: Subset size must be 5
Set={-12, -3, -6, 7, 2, -2, 6, 3, 9, -7, -5, -8, 1, 11, -9, -4}

Find all the subsets from a set of numbers whose sum is zero. Constraint: Subset size must be 3 to 6 only
Set={-12, -3, -6, 7, 2, -2, 6, 3, 9, -7, -5, -8, 1, 11, -9, -4}

Approch

App Screenshot

Technology used

  • Python
  • random library
  • set

Detailed Solution Description

We have used python's random library for generating different samples of certain size then by using sum operator calculated its sum and when its equal to 0 then add it to result. iterating these step 1000 times in loop provide us all possible subset with element sum equal to 0.

Real-World Applications

  • Financial Portfolio Optimization: Selecting subsets of assets to meet target returns or risk levels.
  • Cryptography: Selecting subsets of keys or data that satisfy security constraints.