Find a two-digit number that's equal to two times the result of multiplying its digits. Click below to see the answer.
My first attempt at solving this puzzle was to set it up as an equation and try to solve it algebraically. Let's say the two digits are $x$ and $y$. Then the equation would be:
$10x + y = 2xy$
The left-hand side is the two-digit number ($x$ in the tens place, $y$ in the ones place) and the right-hand side is two times the result of multiplying its digits. If you try to isolate either $x$ or $y$, you'll see that it's not very easy to come up with a clean solution. That's because the equation above describes a hyperbola.
That's not exactly a dead end, but it isn't the kind of easy-to-understand (once you see it) solution I like in a logic puzzle. Luckily, there's an easier way. There aren't that many possibilities (we're only dealing with two digits), and we can eliminate a lot of them.
For example, we know that neither digit is 0. Also, we know that $2xy$ is an even number, so $y$ must be even (because the result of adding it to an even number is even). We also know that the product of the digits must be less than 50, otherwise $2xy$ would have three digits. That gets us down to only 32 possibilities to test.
Any other shortcuts that I can think of would only eliminate a few possibilities, but it's easy to just test the remaining ones (I went through them manually, but you could write a short script or use a spreadsheet), and find that the solution is
$36 = 2 * 3 * 6$
$10x + y = 2xy$
The left-hand side is the two-digit number ($x$ in the tens place, $y$ in the ones place) and the right-hand side is two times the result of multiplying its digits. If you try to isolate either $x$ or $y$, you'll see that it's not very easy to come up with a clean solution. That's because the equation above describes a hyperbola.
That's not exactly a dead end, but it isn't the kind of easy-to-understand (once you see it) solution I like in a logic puzzle. Luckily, there's an easier way. There aren't that many possibilities (we're only dealing with two digits), and we can eliminate a lot of them.
For example, we know that neither digit is 0. Also, we know that $2xy$ is an even number, so $y$ must be even (because the result of adding it to an even number is even). We also know that the product of the digits must be less than 50, otherwise $2xy$ would have three digits. That gets us down to only 32 possibilities to test.
Any other shortcuts that I can think of would only eliminate a few possibilities, but it's easy to just test the remaining ones (I went through them manually, but you could write a short script or use a spreadsheet), and find that the solution is
$36 = 2 * 3 * 6$
2 comments:
next(x for x in range(10,100) if int(str(x)[0])*int(str(x)[1])*2 == x)
Mark,
Nice! I'll have to come up with one that has a bigger problem space so it will be harder to solve with one line if code. :)
Post a Comment