17
$\begingroup$

There is a secret operator $F$ that takes two whole numbers and outputs a new number. For example

$$\begin{split}F(6,9) &= 15\\ F(66,11) &= 110 \\ F(86,18) &= 179\end{split}$$

Can you find what $F$ does and what is the output of $F(601,81)$ ?

Hint:

F may not be defined for all inputs

$\endgroup$
  • 9
    $\begingroup$ I LaTeXed your question! $\endgroup$ – Culver Kwan Jul 15 at 8:04
  • 3
    $\begingroup$ does F always produce whole, positive integers when given whole numbers? Because if not, you can always solve $F(x,y)=ax + by + c$ for a,b,c and get a very, very ugly result. $\endgroup$ – subrunner Jul 15 at 8:40
  • 1
    $\begingroup$ @subrunner What if it is a non-linear operator? I suspect there is some concatenation involved. $\endgroup$ – Earlien Jul 15 at 9:03
  • 2
    $\begingroup$ thanks for latexing $\endgroup$ – Dmitry Kamenetsky Jul 15 at 9:25
  • 2
    $\begingroup$ @brady-gilg The word operator has several meanings, and you'd have to settle on one to make an exact distinction. In computer language design, for example, operator generally means "function of one or two variables that is written in a prefix or infix form". Thus - is a unary operator because -x applies the operator to the variable x, and + is a binary operator because x+y applies the operator to x and y. $\endgroup$ – Ross Presser Jul 15 at 17:40
36
$\begingroup$

The answer could be:

Rotating the whole numbers, rather parameters, and not the individual integers, by 180 degrees and adding them together.

$F( 6, 9) \quad\rightarrow 9 + 6 \quad= 15$
$F(66,11) \rightarrow 99 + 11 = 110$
$F(86,18) \rightarrow 98 + 81 = 179$

Therefore the output of $F(601, 81)$ would be

$109 + 18 = 127$

| improve this answer | |
$\endgroup$
  • 9
    $\begingroup$ +1 for sheer mindbending non-mathematical genius! Now I know why the question wasn't tagged 'mathematics' :) $\endgroup$ – subrunner Jul 15 at 9:35
  • 3
    $\begingroup$ Hi Ewasted and welcome to Puzzling! It would improve your answer to be more specific about what 'flipping' means in your answer. If you could explicitly mention rotation instead in your answer it would be much clearer. (To me, flipping 601 could mean either (i) reversing the digits to 106 or flipping each individual digit across its horizontal axis to get 901 - neither of these is quite what you mean!) Thanks :) $\endgroup$ – Stiv Jul 15 at 9:35
  • 3
    $\begingroup$ Sorry, I fixed it now :-) $\endgroup$ – Ewasted Jul 15 at 9:46
  • 1
    $\begingroup$ You got it. Well done! $\endgroup$ – Dmitry Kamenetsky Jul 15 at 10:52
7
$\begingroup$

For what it's worth, here's the solution as a short C# program. No string operations necessary :)

void Main()
{
  F(6,9).Dump();      //  15
  F(66,11).Dump();    // 110
  F(86,18).Dump();    // 179
  F(601,81).Dump();   // 127
 }

 int F(int x, int y)
 {
  return rotate(x)+rotate(y);
 }

 int rotate(int num)
 {
  int result =0;
  for (; num > 0; num /= 10)
  {
      int digit = num % 10;
      switch (digit)
      {
          case 0: case 1: case 2: case 5: case 8: break;
          case 3: case 4: case 7: throw new ArgumentException($"can't flip {digit}");
          case 6: digit = 9; break;
          case 9: digit = 6; break;
          default: throw new ArgumentException("I can't even");
      }
      result = result * 10 + digit;
  }
  return result;
 } 

| improve this answer | |
$\endgroup$
  • $\begingroup$ Really nice. Could the 'rules' be changed so the number remains as is if it can't be rotated? $\endgroup$ – JosephDoggie Jul 16 at 21:07
  • $\begingroup$ Sure, although that goes against the Hint at end of the question here. But if you want: just change the line with can't flip {digit}, replacing the word throw and everything after it with break; $\endgroup$ – Ross Presser Jul 16 at 21:24
  • 1
    $\begingroup$ I didn't see the hint at first. $\endgroup$ – JosephDoggie Jul 17 at 12:07

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.