Solving calculation puzzle

3

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

Arjihad

Posted 2021-02-14T12:37:52.277

Reputation: 1 020

Question was closed 2021-02-15T03:14:30.693

1Cool ideas, have you try to implement them? – yarchik – 2021-02-14T12:43:32.820

Do we use each operator only once? – Conor Cosnett – 2021-02-14T12:51:00.047

2You can use each operator as often as you want. – Arjihad – 2021-02-14T12:53:16.423

Two related questions. – J. M.'s ennui – 2021-02-14T12:56:52.943

easy: 77+77+1+1 – Daniel Huber – 2021-02-14T13:05:42.433

1I 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 77+77+1+1 is not valid. – Arjihad – 2021-02-14T13:17:02.200

can 7 be used 3 times or 2 times? does it have to be used four times? – Conor Cosnett – 2021-02-14T13:21:00.890

Yes. Im gonna edit the question with some examples to make it easier. – Arjihad – 2021-02-14T13:21:51.113

Answers

6

Here are all $4$ solutions to the puzzle

enter image description here

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
 ]

Conor Cosnett

Posted 2021-02-14T12:37:52.277

Reputation: 6 215