Background
So I've been inspired by this puzzleing SE question to create a similar Code Golf challenge. The basic puzzle format is you must use 4 numbers, such as 5 5 5 5, to equal some other number, such as 35, using only plus, minus, multiply, divide (float division only), factorial, exponent, concatination (I'll grudingly allow concatination of calculations), and parentheses. You may only use the four of the input number (no more, no less), but you may use as many pluses, minuses, multiplies, etc. as you please.
The Challenge
Given one input number, n, can you use it exactly four times to make input number x? If so how? Numbers n and x will be inputed through a form n, x
. If a particular input set is not solvable then it should return the word Impossible
(case-sensative). This is code-golf, shortest code wins.
Edit: This is different from the four fours because this generalizes the problem into any four of the same number, as opposed to any four fours
Expected input-outputs
5, 19
could return (5!-(5*5))/5
or (5-5/5)!-5
4, 30
could return (4+(4/4))!/4
1, 11111
should return Impossible
N.B: these are merely examples, and there are possibly a great many solutions to each input set.
1,11111
is impossible? Also, is division, integer division or real division? i.e. is1/2
0
or0.5
? \$\endgroup\$concat(4×4, 4)
yield 164? \$\endgroup\$