>>> from itertools import combinations
...
... # 주어진 숫자들
... numbers = [-2385336, -2535400, -2398830, -2077934, -1743612, -264318, -507786,
... -1666318, -2327352, -1828248, -1305642, -1586440, -2052896, -1463416,
... -1381830, -1442316, -1364752, -1842094, -1321748, -2019424, -1481248,
... -1415268, -684962, -1602660, -1469860, -943156, -947624, -1360698,
... -1576082, -1469860, -1257664, -1581000, -1356276, -1414876, -1158420,
... -1677600, -1651212, -1427472, -1347458, -1010876, -1964440, -1177140,
... -687640, -1133086, -1269752, -80700, -1096668, -281456, -1038220,
... -1932934, -1420540, -1849972, -209113, -1963912, -1111358, -2300572,
... -2254960, -342980, -870520, -886930, -1277072, -1099020, -907824,
... -1004636, -1184948, -1613416, -1029214, -1613416, -1227560, -1048804,
... -633942, -1603818, -964924, -1129512, -1374524, -1615024, -1881420,
... -1257976, -1016080, -617245, -1486170, -472256, -815216, -1066174,
... -392800, -186744, -1361394, -992830, -863608, -81944, -762424,
... -775964, -957844, -607892, -1113552, -939548, -469224, -469224,
... -469224, -1118674, -1371608, -187880, -1034080, -1446546, -1539342,
... 742660, -1060882, -1060882, -1850820, -979188, -127358, -446920,
... 773710, 1346536, 1730264, 1175700, -1495372]
...
... # 주어진 숫자들 중에서 합이 -15,786,983이 되는 조합을 찾는 함수
... def find_combination(numbers, target_sum):
... for r in range(1, len(numbers) + 1):
... for combination in combinations(numbers, r):
... if sum(combination) == target_sum:
... return combination
... return None
...
... # 합이 -15,786,983이 되는 조합 찾기
... combination = find_combination(numbers, -15786983)
...
... # 결과 출력
... if combination:
... print("조합을 찾았습니다:")
... print(combination)
... else:
... print("해당하는 조합을 찾을 수 없습니다.")
중복