fork download
  1. from itertools import combinations
  2.  
  3. numbers = [1571.48, 327.53, 286.60, 349.50, 517.67, 247.00, 882.73, 274.00, 237.50, 301.00, 973.50, 288.75, 347.50, 326.81]
  4.  
  5. for i in range(len(numbers)):
  6. for combination in combinations(numbers, i):
  7. s = sum(combination)
  8. if abs(s - 4600.31) < 1 or abs(s - 2331.26) < 1:
  9. print('A soma de ', combination, 'resultou em', s)
Success #stdin #stdout 0.02s 28376KB
stdin
Standard input is empty
stdout
A soma de  (1571.48, 327.53, 517.67, 882.73, 973.5, 326.81) resultou em 4599.72
A soma de  (327.53, 286.6, 349.5, 247.0, 882.73, 237.5) resultou em 2330.86
A soma de  (327.53, 247.0, 882.73, 237.5, 288.75, 347.5) resultou em 2331.01
A soma de  (286.6, 349.5, 882.73, 274.0, 237.5, 301.0) resultou em 2331.33
A soma de  (247.0, 882.73, 237.5, 288.75, 347.5, 326.81) resultou em 2330.29
A soma de  (882.73, 274.0, 237.5, 301.0, 288.75, 347.5) resultou em 2331.48
A soma de  (1571.48, 286.6, 349.5, 247.0, 882.73, 973.5, 288.75) resultou em 4599.5599999999995
A soma de  (1571.48, 286.6, 882.73, 237.5, 301.0, 973.5, 347.5) resultou em 4600.3099999999995
A soma de  (327.53, 349.5, 517.67, 247.0, 274.0, 288.75, 326.81) resultou em 2331.2599999999998
A soma de  (327.53, 517.67, 274.0, 237.5, 301.0, 347.5, 326.81) resultou em 2332.0099999999998
A soma de  (1571.48, 327.53, 286.6, 349.5, 517.67, 247.0, 973.5, 326.81) resultou em 4600.090000000001
A soma de  (1571.48, 327.53, 286.6, 349.5, 517.67, 274.0, 301.0, 973.5) resultou em 4601.280000000001
A soma de  (1571.48, 327.53, 517.67, 247.0, 973.5, 288.75, 347.5, 326.81) resultou em 4600.240000000001
A soma de  (1571.48, 286.6, 349.5, 517.67, 274.0, 301.0, 973.5, 326.81) resultou em 4600.56
A soma de  (1571.48, 517.67, 274.0, 301.0, 973.5, 288.75, 347.5, 326.81) resultou em 4600.71
A soma de  (286.6, 349.5, 247.0, 274.0, 237.5, 301.0, 288.75, 347.5) resultou em 2331.85