找到所有可能的數字組合以達到給定的總和 - Finding all possible combinations of numbers to reach a given sum

問題:

How would you go about testing all possible combinations of additions from a given set N of numbers so they add up to a given final number?您將如何測試給定N組數字中所有可能的加法組合,以便將它們加起來爲給定的最終數字?

A brief example:一個簡單的例子:

  • Set of numbers to add: N = {1,5,22,15,0,...}要添加的一組數字: N = {1,5,22,15,0,...}
  • Desired result: 12345預期結果: 12345

解決方案:

參考一: https://stackoom.com/question/JR4s
參考二: Finding all possible combinations of numbers to reach a given sum
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章