3
$\begingroup$

Start with the digits:

      $1\ 0\ 1\ 0\ 1\ 0\ 1\ 0\ 1\ 0\ 1$

You may then add (only!) these simple arithmetic operators:

      $+\ -\ \times\ \div$

You may also remove the space between no more than 3 adjacent digits, to make larger numbers:

      $1\ 0\ 1$ can be concatenated to $101$, for example
      $1\ 0\ 1\ 0\ 1$ cannot be concatenated to $\require{enclose}\enclose{horizontalstrike}{10101}\ $ (too many digits)

You must then insert one equal sign $\ =\ $ between two numbers to form a valid and correct equation.

What is the fewest operators you can add to form a valid equation?

[Added bonus question]
What is the fewest operators you can add to form a valid equation if operators only appear on one side of the equal sign?


Unary negation $-1$ is allowed.
Unary plus $+1$ is not allowed.
Binary addition, subtraction, multiplication, and division are allowed.
No other operators are allowed.
No decimal points, and no rounding.
Leading zeroes on numbers are not allowed.
Base 10 only.

Order of operations:
What Perl uses. Basically, BO(DM)(AS):
  • left to right
  • multiplication and division done together in one pass
  • addition and subtraction done together in a lower priority pass
You may add parentheses if required to reorder evaluation. Each pair counts as an operator.

$\endgroup$
  • $\begingroup$ Just to be clear: (1) you're allowed any number of arithmetic operators, not just one of each?, (2) you can do any number of space-removals, just not so as to make any single number longer than 3 digits? $\endgroup$ – Gareth McCaughan Mar 3 at 0:01
  • $\begingroup$ Further clarification: (3) the number 0 is allowed despite the "no leading zeroes" rule? $\endgroup$ – Gareth McCaughan Mar 3 at 0:04
  • $\begingroup$ Yes to all the above. $\endgroup$ – Rubio Mar 3 at 0:14
  • $\begingroup$ That's an interesting title you got there. $\endgroup$ – Rand al'Thor Mar 3 at 8:45
6
$\begingroup$

Here is a simple, but optimal, solution.

10+101+0=10+101

uses a total of

three additions, one =, and no other operators.

The best one could hope for is

two operators (and one =) -- since no number can be longer than 3 digits, we have to break up the string of digits in at least three places. So the above can't be improved much.

And in fact,

we have to break in at least four places, so the above is optimal. Why? Because if we ever break after a 1 then the next number starts with a 0 and hence must be exactly a 0; if there is a single-digit number then the remaining 10 digits must still form >3 groups (because no group is longer than 3), so we get at least 5 groups in all, hence at least 4 group-breakers, hence at least 3 operators. On the other hand, if we never break after a 1 then all our groups other than perhaps the last one are of even size, hence of size at most 2, which again means at least 5 groups in all.

$\endgroup$
  • $\begingroup$ "The best one could hope for is" exactly what I'm thinking about right now. ;-) The solution you've provided (and its trivial variants) is the easy one. $\endgroup$ – EKons Mar 3 at 0:07
  • $\begingroup$ I actually think it's impossible to do better than the easy one, but I haven't checked my reasoning yet or even written it down explicitly... [EDITED to add:] Yup, seems to be correct. $\endgroup$ – Gareth McCaughan Mar 3 at 0:09
4
$\begingroup$

To answer the bonus question, you'll need:

$10-10+101+0=101$

This is optimal for the reason given in Gareth's answer by himself:

we have to break in at least four places, so the above is optimal. Why? Because if we ever break after a 1 then the next number starts with a 0 and hence must be exactly a 0; if there is a single-digit number then the remaining 10 digits must still form >3 groups (because no group is longer than 3), so we get at least 5 groups in all, hence at least 4 group-breakers, hence at least 3 operators. On the other hand, if we never break after a 1 then all our groups other than perhaps the last one are of even size, hence of size at most 2, which again means at least 5 groups in all.

Of course, the main solution has already been given.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.