7
$\begingroup$
0#0=0
1#1=3
10#10=170
42#42=2730
1024#1024=2098176
123456789#987654321=132560718793697457
314159265358979#218281828459045=88427971900355630574283039269

1#2#3#4#5#6#7#8#9=28931977

Find 2#2#2.

$\endgroup$
3
  • $\begingroup$ Inspired by this, I bet! $\endgroup$
    – Jafe
    Commented May 2 at 0:59
  • $\begingroup$ of course :) nice bounty btw $\endgroup$
    – Sny
    Commented May 2 at 1:51
  • $\begingroup$ One day we'll crack that one... it's been in my head for months... @Jafe $\endgroup$ Commented May 2 at 15:04

1 Answer 1

10
$\begingroup$

It concatenates…

in binary!

More specifically…

It converst the inputs from decimal to binary, concatenate the binary strings, then converts the result back to a decimal number.

Therefore…

2#2#2=0b10#0b10#0b10=0b101010=42. The answer to life, the universe, and this question!

More fun properties:

This operator is associative, but not commutative.
It has a left identity (0), but no right identity—unless you count 0 in binary to be technically digitless.
It can be implemented fairly easily by using shift operators and (insert favorite method for counting bits).

$\endgroup$
1
  • $\begingroup$ One more property if we allow twos complementation: $(-1)#n=n-2^m$ where $m$ is chosen to make the next power of $2$ beyond $m$. E.g. $(-1)#100=100-128=-28$. $\endgroup$ Commented May 2 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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