# Reversible number problem

These are the reversible numbers

In this example we have an operation that on one side gives the result 6 and turning it gives it 12.

Is it possible using reversible numbers and mathematical operations +, - , * to find a solution for:

1. 2021 and 1202
2. 2022 and 2202

Example of near solution: 1181 + 28 + 1 + 811 = 2021, but reverse 118 + 1 + 82 + 1811 = 2012 instead of 1202

Avoiding trivial solutions using 0 or the own dates, there are solutions for both problems

The best solution is the one that uses the least quantity of digits.

• Don't "2021+0" and "2022+0" work? Is there something more specific you're looking for?
– Deusovi
Nov 28, 2021 at 22:39
• @Deusovi yes but 0 alone it is not alloweds Nov 29, 2021 at 1:28
• @bobble I invented as all of my puzzles. I don´t think someone else invented same problem before, but you never know. Nov 29, 2021 at 1:30
• Okay, what about "2021+1-1" and "2022+1-1"?
– Deusovi
Nov 29, 2021 at 3:33
• I think @Deusovi has the correct answer above, but it's probably not the intended one. Nov 29, 2021 at 5:40

Interesting problem! I was tempted to use brute-force with a "x - y + z" general format, just to see what happens. I'm sharing bellow my results.

Problem Formulation

I came with a definition of a general problem find(A, B) that, given integers A, B, yields positive integers x, y, z such that z + x - y = B and rev(y) - rev(x) + rev(z) = A. This second equation follows the fact that when you reverse z + x - y, you simply get rev(y) - rev(x) + rev(z). There would be infinite solutions but i filtered for the ones with fewer digits (i didn't show only the smallest that i got because i thought it's fun to check the patterns).

find(1202, 2021) [Executed in 12.7s]

find(1202, 2021)
[size_08] 2201 + 1 - 181 = 2021,  181 - 1 + 1022 = 1202
[size_09] 1022 + 1001 - 2 = 2021,  2 - 1001 + 2201 = 1202
[size_09] 1202 + 888 - 69 = 2021,  69 - 888 + 2021 = 1202
[size_09] 2111 + 11 - 101 = 2021,  101 - 11 + 1112 = 1202
[size_09] 2201 + 22 - 202 = 2021,  202 - 22 + 1022 = 1202
[size_10] 1811 + 890 - 680 = 2021,  089 - 068 + 1181 = 1202
[size_10] 1811 + 891 - 681 = 2021,  189 - 168 + 1181 = 1202
[size_10] 1811 + 892 - 682 = 2021,  289 - 268 + 1181 = 1202
[size_10] 1811 + 895 - 685 = 2021,  589 - 568 + 1181 = 1202
[size_10] 1811 + 896 - 686 = 2021,  989 - 968 + 1181 = 1202
[size_10] 1811 + 898 - 688 = 2021,  889 - 868 + 1181 = 1202
[size_10] 1811 + 899 - 689 = 2021,  689 - 668 + 1181 = 1202
[size_10] 1850 + 800 - 629 = 2021,  629 - 008 + 0581 = 1202
[size_10] 206 + 2020 - 205 = 2021,  502 - 0202 + 902 = 1202
[size_10] 209 + 2020 - 208 = 2021,  802 - 0202 + 602 = 1202
[size_10] 506 + 2120 - 605 = 2021,  509 - 0212 + 905 = 1202
[size_10] 509 + 2120 - 608 = 2021,  809 - 0212 + 605 = 1202
[size_10] 806 + 2120 - 905 = 2021,  506 - 0212 + 908 = 1202
[size_10] 809 + 2120 - 908 = 2021,  806 - 0212 + 608 = 1202
[size_11] 1022 + 1221 - 222 = 2021,  222 - 1221 + 2201 = 1202
[size_11] 1112 + 1111 - 202 = 2021,  202 - 1111 + 2111 = 1202
[size_11] 1121 + 1100 - 200 = 2021,  002 - 0011 + 1211 = 1202
[size_11] 1295 + 1015 - 289 = 2021,  682 - 5101 + 5621 = 1202
[size_11] 1298 + 1008 - 285 = 2021,  582 - 8001 + 8621 = 1202


find(2022, 2202) [Finished in 12.6s]

find(2022, 2202)
[size_08] 2022 + 181 - 1 = 2202,  1 - 181 + 2202 = 2022
[size_09] 2022 + 202 - 22 = 2202,  22 - 202 + 2202 = 2022
[size_09] 2112 + 101 - 11 = 2202,  11 - 101 + 2112 = 2022
[size_10] 1212 + 1010 - 20 = 2202,  02 - 0101 + 2121 = 2022
[size_10] 2151 + 160 - 109 = 2202,  601 - 091 + 1512 = 2022
[size_10] 2151 + 260 - 209 = 2202,  602 - 092 + 1512 = 2022
[size_10] 2151 + 560 - 509 = 2202,  605 - 095 + 1512 = 2022
[size_10] 2151 + 660 - 609 = 2202,  609 - 099 + 1512 = 2022
[size_10] 2151 + 860 - 809 = 2202,  608 - 098 + 1512 = 2022
[size_10] 2151 + 960 - 909 = 2202,  606 - 096 + 1512 = 2022
[size_10] 2181 + 189 - 168 = 2202,  891 - 681 + 1812 = 2022
[size_10] 2181 + 289 - 268 = 2202,  892 - 682 + 1812 = 2022
[size_10] 2181 + 589 - 568 = 2202,  895 - 685 + 1812 = 2022
[size_10] 2181 + 689 - 668 = 2202,  899 - 689 + 1812 = 2022
[size_10] 2181 + 889 - 868 = 2202,  898 - 688 + 1812 = 2022
[size_10] 2181 + 989 - 968 = 2202,  896 - 686 + 1812 = 2022
[size_11] 1212 + 1210 - 220 = 2202,  022 - 0121 + 2121 = 2022
[size_11] 1218 + 1199 - 215 = 2202,  512 - 6611 + 8121 = 2022


Finally, for the sake of curiosity, i also tried a x * y + z model:

 find_xy_plus_z(1202, 2021):
[size_06] 1 * 2021 + 0 = 2021,  0 + 1202 * 1 = 1202  (this one doesn't count)
[size_09] 10 * 102 + 1001 = 2021,  1001 + 201 * 01 = 1202
[size_09] 10 * 100 + 1021 = 2021,  1201 + 001 * 01 = 1202
[size_09] 001 * 20 + 2001 = 2021,  1002 + 02 * 100 = 1202
[size_09] 002 * 10 + 2001 = 2021,  1002 + 01 * 200 = 1202
[size_09] 001 * 10 + 2011 = 2021,  1102 + 01 * 100 = 1202

find_xy_plus_z(2022, 2202):
[size_09] 10 * 200 + 0202 = 2202,  2020 + 002 * 01 = 2022
[size_09] 20 * 100 + 0202 = 2202,  2020 + 001 * 02 = 2022
[size_09] 10 * 120 + 1002 = 2202,  2001 + 021 * 01 = 2022
[size_09] 10 * 110 + 1102 = 2202,  2011 + 011 * 01 = 2022
[size_09] 10 * 100 + 1202 = 2202,  2021 + 001 * 01 = 2022

[Finished in 219ms]


• Nice, but I think you either need to filter out the numbers with leading zeroes (trailing zeros before rotation) or output them "correctly"... I particularly like the solutions that use the upside-down version of the target number in its calculation, connecting it to itself! For presentation, I think that having the presented solution slightly re-arranged to avoid an intermediate negative number in the calculation would be better though - e.g. [big] - [small] + 2022 = 2202 <-> 2022 = 2202 + [small] - [big] Nov 30, 2021 at 8:33
• Agreed, @Steve! Which is why i considered the maximum of the lengths of x and rev(x), y and rev(y), z and rev(z), as we couldn't immediately understand Rodolfo's intent with the puzzle. Something of the sort also happens in a xy+z model, apparently. Now i wonder if anyone could come with a xy+zw solution (or any other format) with 7 or less digits. :) Nov 30, 2021 at 20:29

If I understand correctly what you're asking, then

no, it's not possible to find two four-digit numbers such that their difference is $$2021$$ and their flipped versions' difference is $$1202$$.

Proof:

say the four-digit numbers are $$ABCD$$ and $$WXYZ$$, and let $$'$$ denote flipping, so that $$ABCD-WXYZ=2021\quad\text{and}\quad Z'Y'X'W'-D'C'B'A'=1202.$$ So $$D-Z$$ is $$1$$ modulo $$10$$ and $$Z'-D'$$ must be either $$1$$ or $$2$$. Since we're looking for four-digit numbers, neither $$D$$ nor $$Z$$ can be zero, so the only options are $$D=9$$ and $$Z=8$$, so that $$ABC9-WXY8=2021\quad\text{and}\quad 8Y'X'W'-6C'B'A'=1202.$$ Now the second formula means $$C'$$ must be $$8$$ or $$9$$ and $$Y'$$ must be $$0$$ or $$1$$ or $$2$$, which means $$C$$ must be $$6$$ or $$8$$ and $$Y$$ must be $$0$$ or $$1$$ or $$2$$, but then it's not possible for the first formula to be correct.

Similarly, for the second problem,

no, it's not possible to find two four-digit numbers such that their difference is $$2022$$ and their flipped versions' difference is $$2202$$.

Proof:

again, we start with two formulae $$ABCD-WXYZ=2022\quad\text{and}\quad Z'Y'X'W'-D'C'B'A'=2202.$$ So $$D-Z$$ is $$2$$ modulo $$10$$ and $$Z'-D'$$ must be either $$2$$ or $$3$$. Again, neither $$D$$ nor $$Z$$ can be zero, so there are no options here: we must have $$Z'>D'$$, and either $$D>Z$$ or $$D=1$$ and $$Z=9$$ (again neither of them can be $$0$$), and in this way it's not possible.

• you can use as many digits and operations as you want, but best solution is the one that uses less digits. Nov 29, 2021 at 1:56
• I have solution for both problems. Example of near solution 1181+28+1+811 = 2021, but reverse 118+1+82+1811= 2012 instead of 1202 Nov 29, 2021 at 1:59

For the moment this is the best solutions I know:

1. Uses 12 digits
2. Uses 14 digits