Code puzzle
Moderator: Michael Wallace
- Ben Wilson
- Legend
- Posts: 4547
- Joined: Fri Jan 11, 2008 5:05 pm
- Location: North Hykeham
Code puzzle
A door has an electronic code lock, where the code is always 3 digits between 1 and 5 inclusive. Repeat digits are not allowed, so whilst 423 is a valid code, 433 isn't. However, the door is set up to only recognise the last three digits entered. This means that if the code was 423 and you entered 15423, the door would unlock.
The question is: what is the fewest digits needed to run through all possible combinations and unlock the door, and what would that string of digits look like?
(Btw, I don't actually know the answer to this one myself)
The question is: what is the fewest digits needed to run through all possible combinations and unlock the door, and what would that string of digits look like?
(Btw, I don't actually know the answer to this one myself)
-
- Postmaster General
- Posts: 3661
- Joined: Sun Oct 25, 2009 6:18 pm
Re: Code puzzle
Just to clarify your example, does this mean that if you were to type "15423" then the lock would recognise the three digit combinations of "154", "542" and "423"?
- Ben Wilson
- Legend
- Posts: 4547
- Joined: Fri Jan 11, 2008 5:05 pm
- Location: North Hykeham
Re: Code puzzle
Yes, in that order.Ryan Taylor wrote:Just to clarify your example, does this mean that if you were to type "15423" then the lock would recognise the three digit combinations of "154", "542" and "423"?
- Graeme Cole
- Series 65 Champion
- Posts: 2041
- Joined: Tue Jul 06, 2010 9:59 pm
Re: Code puzzle
What do you mean by "repeat digits"? The same digit twice consecutively, or the same digit twice anywhere in the code?
For example, is it valid for the code to be 343?
For example, is it valid for the code to be 343?
-
- Enthusiast
- Posts: 265
- Joined: Wed Sep 09, 2009 3:18 pm
Re: Code puzzle
Graeme, I interpreted it to mean no repeated digits anywhere within the three (the repeated digits case would be substantially easier, I think). Hopefully that is the case, as I found quite a neat way to do this. The sequence below is a minimum solution (i.e. solves all 60 codes using 62 digits), but is by no means unique.
2, 3, 1, 2, 4, 1, 2, 5, 1, 3, 2, 1, 3, 4, 1, 3, 5, 1, 4, 2, 1, 4, 3, 1, 5, 4, 1, 5, 2, 1, 5, 3, 1, 4, 5, 1, 2, 3, 5, 2, 4, 5, 2, 3, 4, 5, 3, 4, 2, 5, 3, 2, 4, 3, 5, 4, 3, 2, 5, 4, 2, 3
2, 3, 1, 2, 4, 1, 2, 5, 1, 3, 2, 1, 3, 4, 1, 3, 5, 1, 4, 2, 1, 4, 3, 1, 5, 4, 1, 5, 2, 1, 5, 3, 1, 4, 5, 1, 2, 3, 5, 2, 4, 5, 2, 3, 4, 5, 3, 4, 2, 5, 3, 2, 4, 3, 5, 4, 3, 2, 5, 4, 2, 3
-
- Post-apocalypse
- Posts: 13308
- Joined: Mon Jan 21, 2008 10:37 pm
Re: Code puzzle
I think I saw a YouTube video on this once. Either Numberphile or Singingbanana or something.
- Charlie Reams
- Site Admin
- Posts: 9494
- Joined: Fri Jan 11, 2008 2:33 pm
- Location: Cambridge
- Contact:
Re: Code puzzle
http://en.wikipedia.org/wiki/De_Bruijn_sequence with some tweaks.
-
- Enthusiast
- Posts: 265
- Joined: Wed Sep 09, 2009 3:18 pm
Re: Code puzzle
Nice, could see it had something to do with Hamiltonian paths and presumed there must be a neat mathematical approach. Surprised I've never come across it before, actually.
-
- Post-apocalypse
- Posts: 13308
- Joined: Mon Jan 21, 2008 10:37 pm