If I have a list of 40 numbers and I want to select 5 numbersand test if their sum equals a certain constant, In python ?
Suppose I have a list [a1,a2…..a40], then I want to selecta2,a3,a7,a8,a9 and check if a2+a3+a7+a8+a9=500 if yes I print itand then select other 5 numbers from the main array and check forthe sum,keep repeating until and unless I’ve used all possiblecombinations.How to do so in python ?
Expert Answer
An answer will be send to you shortly. . . . .