# What's the combination for the safe?

The CFO sat back in his leather chair, which creaked and squeaked. "It's actually pleather," he said to the intern sitting nervously opposite him, a notepad resting on his knees. "We're very cost-conscious here. The intern, who'd already discovered that the building's only toilet operated on the time-tested 'take-a-number-and-wait-to-be-called' system, nodded carefully.

"All reports are to be stored in that safe," said the CFO, pointing to a squat grey box. "We change the $$7$$-digit combination every month, and no combination may be re-used. We like to think the combinations are efficient. You get one chance to enter the code, or the safe locks you out for 24 hours. Old combinations are written on this post-it note so that no mistakes are made."

The CFO's cell-phone rang at that moment, and the intern politely stared at his shoes trying not to listen. When the CFO hung up he stood up. "I have to go and... fix things," he said. "While I'm gone get started on reading the reports in the safe. I shall be back expeditiously."

The intern looked at the safe, slowly realising that the CFO hadn't told him what the current combination was. After looking at the post-it note for a few minutes though, he entered the combination in the safe and was busy squinting at reports written in 6-pt font (to save space) by the time the CFO returned.

The combinations written on the post-it note are: $$5124637$$ $$7125364$$ $$4152637$$ $$5162734$$ $$6243517$$ What combination did the intern enter into the safe, and how did he know it would work?

UPDATE (14/03)

Hint 1:

No code can ever start with $$1$$ (and, being efficient, the codes use the digits $$1$$ through to $$7$$ only and once each. When the firm was using five digit codes the entire set were $$31425, 51243$$ and $$41523$$).

Hint 2:

To be efficient, each digit is chosen so that it depends on all the digits that precede it.

• There's always a relevant XKCD, but sometimes there's also a relevant Dilbert. – Brandon_J Mar 12 at 18:54
• The intern must be a genius. I've been looking at this for much longer than a few minutes and can't see any pattern. I think efficient is the key here, but looking at the distance your finger has to travel between key presses yields no results. Neither does looking at the permutation order. This guy needs a raise. – Amorydai Mar 13 at 19:21
• @Amorydai I'll add a hint tomorrow. The intern didn't work out for other reasons :( – postmortes Mar 13 at 19:23
• @Amorydai dunno if this helps, but Rot13(rnpu qvtvg bayl rire punatrf ol mreb, bar, gjb, be guerr.) – Brandon_J Mar 13 at 22:27
• @So far all I've got: Rot13(Vs lbh fxrgpu gur ahzoref va n evat, naq pbaarpg gurz va beqre, gurer frrzf gb or fbzr fbeg bs cnggrea, ohg abg rabhtu gung V pna znxr n cerqvpgvba sbe gur ynfg pbqr...) – Fifth_H0r5eman Mar 14 at 9:21

5164237

Each digit

is a factor of the sum of its predecessors

However this isn't the only remaining permutation of the digits 1-7 that fits.

4263517

works as well.

• This is it, though annoyingly it's not the only permutation: $4263517$ also works, but I missed the one you found when I was enumerating them. Well done! – postmortes Mar 15 at 6:58
• This answer invalidates part of the initial problem: "We change the 7-digit combination every month, and no combination may be re-used." What do you do after using the above ? – Overmind Mar 15 at 13:03
• Also, since the intern guessed the number, I assumed there was some pattern to the numbers. Why was 7 chosen as the first digit for the second combo? Why was 4 chosen for the third? I guess they were just random after all. Not very efficient. – Amorydai Mar 15 at 14:14
• @Overmind they move to 8-digit combinations. The question doesn't state that they only ever use 7-digit combinations (and the hint lists the 5-digit combinations they've used) – postmortes Mar 15 at 14:48
• @postmortes Jesus! At least the scheme you use is self-consistent. However, as a feedback on your puzzle - the hints you give are wholly inadequate. "We change the 7-digit combination every month" - actually does imply that they only use 7-digit combos. 5-digit ones were only introduced in a hint - hard to draw conclusions from that, AND you gave them out of order! Maybe if you at least said we were looking for the last acceptable 7-digit combo it would make more sense. I don't think the single word "efficient" is suitable as a hint for all this. – Amorydai Mar 15 at 15:48

I think I got it.

The keyword here is efficient. When written out the keypresses on a 3x3 Numpad, only the 3rd Code is efficient by the keypresses alone. The third code "4152637" is the keys from the second row of the keypad up to the first row, from left to right, and then the seven at the end. The most efficient code, and also the solution.

Hope I explained it well enough, I don't know how to "spoiler" a graphic / pre-format yet.

• Sorry, no. All the given codes are efficient, and you're looking for the current code. – postmortes Mar 14 at 8:18
• I've added a couple of hints now as well :) – postmortes Mar 14 at 8:25
• Wait, so that means that the code he used is not in the list? Because you said "looking for the current code" – Chris Mar 14 at 8:35
• That's right. You're told that the post-it note only contains the old combinations – postmortes Mar 14 at 8:38

I would use :

6215734

By the logic that:

Second digit seems incremental every 4, so after 1111 and 2, logic dictates of a high probability of number 2 for the second position:
x2xxxxx
Last digit alternates between 7 and 4 so it's 4's turn now:
x2xxxx4

After each 2 there's an incremental number 24,5,6,7 so next will be 1 (column parity patterns also check):
x21xxx4

Sum of each 2 numbers by column have each 2 times a decreasing pattern (sum of 1st 2 columns 1st numbers: 12, c2p1+c3p1: 11, c3p1+c4p1: 9, c4p1+c5p1: 11, logic - c5p1+c6p1 must be 6:
621xxx4

Now we can get to study of the patterns of previous entries. There is no straight 3-in-a-line combination (because of safety efficiency) so it's safe to say that we exclude 3-5-7 and 7-5-3 from our remaining entries (inefficient from a safety point of view):
621x7x4

This leaves us with 2 combinations: 375, 573

Finally, since 5 is always near a 1 or a 2 (51, 25, 52, 51, 51) we may as well respect that with a 15:
6215734

An alternate to this can be found by studying the logic of the 11, 12 and 13 patters present all over, but that would take an excessive amount of math to demonstrate so I'd rather go with the option above.

• Hi! Please add spoiler tags with >!, thanks. – pirate Mar 14 at 14:00
• Sorry, tag is broken. – Overmind Mar 14 at 14:04
• See my edit, :) – pirate Mar 14 at 14:07
• That's not the right code, sorry. You have made some relevant observations but what you're looking for can be stated much more simply. – postmortes Mar 14 at 15:13
• Thanks @pirate, looks like the tag must be on all lines; good thing it's working. – Overmind Mar 15 at 9:27