2
$\begingroup$

In the context of puzzles such as this:

Write a program that outputs all possibilities to put + or - or nothing between the numbers 1,2,…,9 (in this order) such that the result is 100. For example 1 + 2 + 3 - 4 + 5 + 6 + 78 + 9 = 100.

Is there a name for the "nothing"-operation between 7 and 8?

What it would do is I think: let a,b be positive integers

$a$ nothing $b= a\times 10 +b$

Also if you think this belongs to a special Tag please edit the Tag in there.

$\endgroup$
  • 6
    $\begingroup$ Perhaps concatenation or decimal concatenation $\endgroup$ – Henry Sep 7 '18 at 23:02
4
$\begingroup$

It's called concatenation. And it's not $a \times 10 + b$. That fails for numbers with more than one digit.

The correct formula is $a \cdot 10^{1 + \lfloor\log_{10}(b)\rfloor} + b$ where we define $\log_{10}(0) = 0$.

$\endgroup$
  • 3
    $\begingroup$ Even your formula fails if $b$ has leading zeros. Unfortunately, no operation can distinguish between $21$ and $201$ by referring only to the values of $2$ and either $1$ and $01$. However, inasmuch as no parentheses appear, we can impose a convention that the operation always associates to the left, and then the simple formula $a\times10+b$ will still work. (So ‘$2(01)$’ evaluates to $2\times10+(0\times10+1)=21$ if we use decimal concatenation for both operations, but ‘$201$’ is interpreted as ‘$(20)1$’, which correctly evaluates to $(2\times10+0)\times10+1=201$ using the simple formula.) $\endgroup$ – Toby Bartels Sep 7 '18 at 23:20
  • $\begingroup$ @TobyBartels My formula doesn't fail for any non-negative integer $a, b$. It's a function over the integers, not strings. There is no such thing as an integer with leading zeroes. $\endgroup$ – orlp Sep 8 '18 at 2:59

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.