**Question:** Write a program that outputs all possibilities to put + or - or nothing between the numbers 1

Related Tags:

This question can be solved with the divide-and-conquer paradigm. Let's break this down into mathematical equations, and try to see what we come up with.

So first, we have the base question. The function f() takes in numbers 1..9, and based on the conditions given, returns 100.

The question says we may use +, - or concatenate two consecutive numbers, so we can break this down into three components.

`1 + f(2..9) = 100``1 - f(2..9) = 100``f(12, 3..9) = 100`

`f(2..9) = 100 - 1 = 99``f(-2, 3..9) = 100 - 1 = 99``f(12, 3..9) = 100`

`2 + f(3..9) = 99``2 - f(3..9) = 99``f(23, 4..9) = 99``-2 + f(3..9) = 99``-2 - f(3..9) = 99``f(-23, 4..9) = 99``12 + f(3..9) = 99``12 - f(3..9) = 99``f(123, 4..9) = 99`

Came up with a better solution or have a question? Comment below!

Next Challenge: FizzBuzz