Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write pseudocode or code in any language for a program that print all combinatio

ID: 3713627 • Letter: W

Question

Write pseudocode or code in any language for a program that
print all combinations that sum up to ‘sum’ by inserting the operators between digits in
‘number’.

- Program should read the command-line arguments passed to the program.

- The first argument is "number" and the second argument is "sum."

- Using integer arithmetic operators ‘+’ and ‘-’, print all combinations that sum up
to ‘sum’ by inserting the operators between digits in ‘number’.

- The program should use a recursive function to generate all combinations.

An example:

Expected output for the ‘number=123456789’ and ‘sum=0’.
There are 22 matched ones among 2 × 38 = 13, 122 combinations.

Explanation / Answer

Hi Dear,

Please find my implementation.

Output:

Enter digit:123456789
Enter sum value: 0
1 + 2 - 34 - 56 + 78 + 9 = 0
1 - 2 - 34 + 5 + 6 + 7 + 8 + 9 = 0
1 - 23 - 4 - 56 - 7 + 89 = 0
12 + 3 + 4 - 5 - 6 - 7 + 8 - 9 = 0
12 + 3 - 4 + 5 - 6 + 7 - 8 - 9 = 0
12 + 3 - 45 + 6 + 7 + 8 + 9 = 0
12 - 3 + 4 + 5 + 6 - 7 - 8 - 9 = 0
12 - 3 + 4 + 56 - 78 + 9 = 0
12 - 3 - 4 - 5 + 6 - 7 - 8 + 9 = 0
12 - 3 - 4 - 5 - 6 + 7 + 8 - 9 = 0
12 + 34 - 56 - 7 + 8 + 9 = 0

Process finished with exit code 0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote