So remember all those puzzles about 100 or 1000 or however many logicians abducted by aliens and they are going to be killed if they can't figure out their hat color or the number on their back? Well it turns out you were such a bright mind that the aliens abducted you, and luckily you were one of the logicians that survived.

Unfortunately, instead of taking you back home, they just left you in a room with all the other logicians that survived. Escaping doesn't seem very likely any time soon because right now everyone is focusing on getting food every day. There is a single fridge in the corner of the room but it is one of those newfangled fridges and it has a security code that you have to put in to open it. The fridge has a panel on the top that displays 5 digits, and those digits change every day, along with the fridge restocking. The problem is that when the fridge restocks, the security code changes. For the first six days, you've had to brute force the code by just typing every combination in until you get it (only 100000 combinations, not too bad), but you really need to figure out what the pattern is for the codes so you can focus on escaping instead of cheeseburgers.

The panel numbers and codes for that day are as follows:

Panel -- Code
12345 = 56306
04418 = 35129
20530 = 65048
54472 = 68425
00000 = 00000
60454 = 95126
29830 = 39175
00000 = 03334
08224 = 35386
14412 = ?????

Today the panel says 14412. Can you figure out the code and what the algorithm is so you can get the food easily each day?

About the brute-force method: Pertaining to David James' comment,the brute force method started with 00000 on the fifth day, but it does not follow the pattern of 00001, 00002... One logician is in charge of the brute-forcing and each day he starts with the panel number, and then does what seems like a random sequence. At least that's what you all think... he's been a little bit looney since the abduction but you all let him use his "sequence" to make him happy.

Yesterday in the fridge, someone found a fortune cookie which contained the following fortune:

Look backwards to go forward

It's probably just a generic fortune mass produced in a cookie factory, but what if it's a clue about solving the code?

Another fortune cookie has shown up:


What could those numbers be referring to?

More fortune cookies:



Codes to a day need not connect
But codes to the panel need be
Look how to get panel from code
And you'll be able to get free

Last fortune cookie:

There can be more than one, but each can't be more than once.

Days passed: 9 (seems like a lot more though)

Note: Please post partial answers if you think you have anything so I can see where you are having problems

  • 1
    $\begingroup$ Is the code always strictly greater than the panel number when it's greater than 00000? $\endgroup$ Commented May 21, 2015 at 7:27
  • 1
    $\begingroup$ Write down the 6 codes we already know, unplug the fridge briefly every 6 days, and hopefully the sequence of codes will repeat. Also, I suspect they were happy on day 5 if their brute force method was to start at code 00000 since they would have gotten it right on the first try that day. $\endgroup$ Commented May 21, 2015 at 8:00
  • 4
    $\begingroup$ If we call panel digits Pn and code digits Cn, then this seems to hold true: C3 = C2 - P3... So, one digit down, 4 to go... $\endgroup$
    – Alconja
    Commented May 21, 2015 at 10:00
  • 1
    $\begingroup$ 86,400 seconds in a day, so that is some super fast typing! $\endgroup$
    – JLee
    Commented May 21, 2015 at 16:13
  • 2
    $\begingroup$ Hmm... why is the fortune cookie 68425 and not 68472? (Of course these new fortune cookies are C1-C2-C3-P4-P5, following on Jefferson's observation.) $\endgroup$
    – Brian
    Commented May 31, 2015 at 21:00

1 Answer 1


It's not possible to determine exactly the code to enter on any given day, but we can narrow it down a great deal as follows:

First, let's define the digits of the Panel as being Pn and the digits of the Code as being Cn. Now, there are various mathematical relationships that can be applied, to relate digits of the code to digits of the panel:

  • $C2 - C3 = P3$
  • $C5 \mod C1 = P1$
  • $C1(C2 + C3) = P4,P5$
  • $C1 - C3 + C4 = P2$

Thus we have a set of equations, which collectively cover all the digits of the code. However, because there's ambiguity (eg. with the mod operator), we still can't directly determine any given code.

Taking the latest panel value of $14412$, we know the following:

  • $C2 - C3 = 4$
  • $C5 \mod C1 = 1$
  • $C1(C2 + C3) = 12$
  • $C1 - C3 + C4 = 4$

(I'm sure an actual mathematician would do a cleaner job of this part of the logic, but I'll fumble along). We can rework these equations to give us, $C1(4 + 2C3) = 12$ (combining equation 1 & 3), or $C1 = \frac{12}{(4 + 2C3)}$.

Given that $C1$ must be a whole number, then $C3$ must be $0$, $1$, $4$, making $C1$ equal to $3$, $2$, or $1$. However, we also need the remainder when dividing $C5$ by $C1$ to be $1$ (noting that there's precedent in the examples for treating x%0 as 0), which means $C1\ne1$.

Re-entering these possible values in the third equation to get $C2$, we have our code as either $251??$ or $340??$. Then using the 4th equation to get $C4$, we arrive at $2513?$ or $3401?$. Finally, using the 2nd equation we get a $C5$ value of $1$, $3$, $5$, $7$, $9$ (for the first possible code) and $1$, $4$, $7$ (for the second).

Thus, today's code is one of the following:

  • $25131$
  • $25133$
  • $25135$
  • $25137$
  • $25139$
  • $34011$
  • $34014$
  • $34017$

So, not perfect, but certainly faster than brute forcing $100,000$ combinations...

  • $\begingroup$ What I was hinting at with the last fortune cookie as well as earlier is that there are multiple codes per day that work, but each only works once for a given panel code (sort of a backwards conversion). When 00000 repeats, the first code can't be used again. Originally I was just trying to find a way of fitting it into the story that there were multiple codes for a panel. Nice job though. $\endgroup$ Commented Jun 2, 2015 at 5:30
  • $\begingroup$ @Mistereman22 - it should be the first hint $\endgroup$ Commented Jun 9, 2015 at 7:11

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