# Solving calculation puzzle [closed]

I recently got asked how to achieve a result of 100 only using the numbers {1,7,7,7,7} (the number 1 can be used only once and the number 7 can be used four times at maximum so not every number have to be used) and the operations +, -, *, / and also brackets. So I tried many different calculations and never got to 100. Of course I cant try all the possible combinations so I thought I could use Mathematica to see wether this is possible or not. One idea would be to generate a set with all numbers (rather integers) we could get from all possible combinations and the other idea would be to find an explicit expression to calculate the result from the given numbers.

Examples:

7*7+7*7+1 = 99

7*(7+1)+7 = 63

7*(7+1)+7*7 = 105

((7 + 7)/7)*(7 + 1) = 16

7*7*(7/7 + 1) = 98

• Cool ideas, have you try to implement them? Commented Feb 14, 2021 at 12:43
• Do we use each operator only once? Commented Feb 14, 2021 at 12:51
• You can use each operator as often as you want.
– Arji
Commented Feb 14, 2021 at 12:53
• Two related questions. Commented Feb 14, 2021 at 12:56
• I wrote {1,7,7,7,7} instead of {1,7} to express that the number 1 can only be used once and the number 7 can be used four times. So 7*7+7*7+1+1 is not valid.
– Arji
Commented Feb 14, 2021 at 13:17

## 1 Answer

Here are all $$4$$ solutions to the puzzle

# Technique #1

heavily plagiarizing this excellent answer

Apparently Groupings is the tool for the job!

ans = Groupings[
Permutations[{7, 7, 7, 7, 1}]~Join~Permutations[{7, 7, 7, 1}]
, {Plus, Subtract, Times, Divide} -> 2
, HoldForm
];
Grid[
Thread[{Quiet[Select[ans, ReleaseHold[#] == 100 &]]} ]
, Frame -> All
, FrameStyle -> Red
]