Home > Riddles > The code with checksum and reverse

The code with checksum and reverse

A four-digit code leaves three traces: a sum, a multiple, and what happens when you read it backwards. The key is not to try combinations, but to turn those clues into restrictions on positions.

A code has four different digits. It is known that: - is a multiple of 9;

  • the last figure is the remainder by dividing the sum of the first three by 10;
  • By reversing the order of its figures, the number obtained exceeds the original by 369 units. What is the code?

Hints

Show hints
  1. If you call the code abcd, the reverse condition compares dcba with abcd.
  2. The difference can be written using only the differences d − a and c − b.
  3. When using the last digit condition, remember that it does not require equality with the entire sum, but rather equality modulo 10.

Solution

Show full solution

Answer: $$3924.$$ Let the code be $abcd$. The number obtained by inverting its figures is $dcba$. How this reverse surpasses the original by 369 units: $$
dcba-abcd=369.

$$ That is to say: $$

(1000d+100c+10b+a)-(1000a+100b+10c+d)=369.

$$ Grouping: $$

999(d-a)+90(c-b)=369.

$$ We divide by 9: $$

111(d-a)+10(c-b)=41.

$$ Since $a,b,c,d$ are figures, the differences $d-a$ and $c-b$ are between $-9$ and $9$. so that $$

111(d-a)+10(c-b)=41,

$$ the only possibility is: $$

d-a=1,\qquad c-b=-7.

$$ Therefore: $$

d=a+1,\qquad c=b-7.

$$ Now we use the condition of the last figure: $$

d\equiv a+b+c\pmod{10}.

$$ Replacing $d=a+1$ and $c=b-7$: $$

a+1\equiv a+b+(b-7)\pmod{10}.

$$ Then: $$

1\equiv 2b-7\pmod{10},

$$ so that $$

2b\equiv 8\pmod{10}.
$$ So $b$ must be congruent to 4 modulo 5. Furthermore, since $c=b-7$ must be a number, $b$ can only be 7, 8, or 9. Of those three values, the only one congruent to 4 modulo 5 is: $$b=9.$$ So: $$c=2.$$ It remains to be used that the code is a multiple of 9. The sum of its figures must be a multiple of 9: $$a+9+2+(a+1)=2a+12.$$ Since $a$ is a figure and $d=a+1$, the only valid possibility is: $$2a+12=18,$$ so $$a=3,$$ So: $$d=4.$$ The code is: $$3924.$$ Check: your figures are different; $3+9+2+4=18$, then it is a multiple of 9; $3+9+2=14$, whose remainder when divided by 10 is 4; its reverse is 4293, and $4293-3924=369$.

Related riddles

Keep practicing

If you enjoyed this one, try more pure-logic riddles, explore this theme, browse the full archive, or read the riddle-solving guide.

← Previous: The magician and the five cards · Next: The scale and the bola distinta →