Can you crack the combination lock? - Solution
The sequence 11221 contains all 2-digit combinations using the numbers 1 and 2.
A sequence such as that is called a De Bruijn sequence. I show you three methods to find such sequence. The first two involve making diagrams called graphs, and either taking a path that visits every node of a graph (a hamilton path), or a path that visits every edge of a graph (euler path). The third method is an algorithm for making 'Lyndon words' which if you string them together will make our De Bruijn sequence.
De Bruijn Sequences: http://en.wikipedia.org/wiki/De_Bruijn_sequence
Hamilton Path: http://en.wikipedia.org/wiki/Hamiltonian_path
Euler Path: http://en.wikipedia.org/wiki/Eulerian_path
Lyndon Words: http://en.wikipedia.org/wiki/Lyndon_word
There is an efficient method of generating a list of all Lyndon words of lengths that divide n, using the digits 1 to k, which involves a lot less crossing off. This is the method I used to make the final sequence in the video. I did not describe the method in the video, so let me describe it here:
Start the list with a sequence of n 1s, i.e. 11 . . . 1. We will generate successive words until we reach kk . . . k. For any word A = a1a2 . . . an, the successor of A is obtained as follows:
1. Let i be the largest value such that ai is less than k
2. Let B = a1a2 . . . ai-1(ai + 1)
3. Then the successor of A is the first n characters of BB . . . B.
We then decided to reject, replace, or keep the successor of A depending on the value of i:
1. If i does not divide n, the successor of A appears earlier on the list under rotation. Generate a successor to the word before removing it from the list.
2. If i divides n but not equal to n, the successor of A is periodic. Generate a successor to the word then replace BB . . . B with B. Replace 11 . . . 1 at the start of the list with 1.
3. If i = n we keep the successor of A.
This creates a list of Lyndon words, of lengths that divide n, written in lexicographic order.
Together, this list creates a De Bruijn sequence of length k^n, containing all the combinations of length n (if the sequence wraps around) using the digits 1 to k.
Ok then, here's an extra one for you to try. Use the algorithm to give me a sequence containing all 6-digit combinations using the numbers 1 and 2. So combinations like 111111, 112121, 211122 etc. The sequence is 64-digits long (if you let the sequence wrap back to the start).
Видео Can you crack the combination lock? - Solution канала singingbanana
A sequence such as that is called a De Bruijn sequence. I show you three methods to find such sequence. The first two involve making diagrams called graphs, and either taking a path that visits every node of a graph (a hamilton path), or a path that visits every edge of a graph (euler path). The third method is an algorithm for making 'Lyndon words' which if you string them together will make our De Bruijn sequence.
De Bruijn Sequences: http://en.wikipedia.org/wiki/De_Bruijn_sequence
Hamilton Path: http://en.wikipedia.org/wiki/Hamiltonian_path
Euler Path: http://en.wikipedia.org/wiki/Eulerian_path
Lyndon Words: http://en.wikipedia.org/wiki/Lyndon_word
There is an efficient method of generating a list of all Lyndon words of lengths that divide n, using the digits 1 to k, which involves a lot less crossing off. This is the method I used to make the final sequence in the video. I did not describe the method in the video, so let me describe it here:
Start the list with a sequence of n 1s, i.e. 11 . . . 1. We will generate successive words until we reach kk . . . k. For any word A = a1a2 . . . an, the successor of A is obtained as follows:
1. Let i be the largest value such that ai is less than k
2. Let B = a1a2 . . . ai-1(ai + 1)
3. Then the successor of A is the first n characters of BB . . . B.
We then decided to reject, replace, or keep the successor of A depending on the value of i:
1. If i does not divide n, the successor of A appears earlier on the list under rotation. Generate a successor to the word before removing it from the list.
2. If i divides n but not equal to n, the successor of A is periodic. Generate a successor to the word then replace BB . . . B with B. Replace 11 . . . 1 at the start of the list with 1.
3. If i = n we keep the successor of A.
This creates a list of Lyndon words, of lengths that divide n, written in lexicographic order.
Together, this list creates a De Bruijn sequence of length k^n, containing all the combinations of length n (if the sequence wraps around) using the digits 1 to k.
Ok then, here's an extra one for you to try. Use the algorithm to give me a sequence containing all 6-digit combinations using the numbers 1 and 2. So combinations like 111111, 112121, 211122 etc. The sequence is 64-digits long (if you let the sequence wrap back to the start).
Видео Can you crack the combination lock? - Solution канала singingbanana
Показать
Комментарии отсутствуют
Информация о видео
Другие видео канала
![de Bruijn Card Trick](https://i.ytimg.com/vi/EWG6e-yBL94/default.jpg)
![The Assassin Problem 3](https://i.ytimg.com/vi/VUK4461pRzc/default.jpg)
![5040 and other Anti-Prime Numbers - Numberphile](https://i.ytimg.com/vi/2JM2oImb9Qg/default.jpg)
![](https://i.ytimg.com/vi/INRt4kKBzCA/default.jpg)
![ADS1: De Bruijn graphs and Eulerian walks](https://i.ytimg.com/vi/TNYZZKrjCSk/default.jpg)
![The Elo Rating System for Chess and Beyond](https://i.ytimg.com/vi/AsYfbmp0To0/default.jpg)
![Crack Combination Lock Codes! No Code? No Problem!](https://i.ytimg.com/vi/Cg6qbM3weMU/default.jpg)
![Follow-Up: Finite Difference Method](https://i.ytimg.com/vi/ApsmQwAhPwY/default.jpg)
![The Barbie electronic typewriter - with Just My Typewriter](https://i.ytimg.com/vi/7Gwhx-uG5h8/default.jpg)
![What's the probability you live in an odd numbered house?](https://i.ytimg.com/vi/wydlZ9lcEiQ/default.jpg)
![Real-time Safecracking Demonstration of S&G 6741](https://i.ytimg.com/vi/D5JqYJyaIyQ/default.jpg)
![Wythoff's Game (Get Home)](https://i.ytimg.com/vi/AYOB-6wyK_I/default.jpg)
![The Finite Difference Method](https://i.ytimg.com/vi/scQ51q_1nhw/default.jpg)
![Genius student solved this in 1 minute - insanely hard geometry problem](https://i.ytimg.com/vi/OuJQaxZvlYs/default.jpg)
![Maths Puzzle: The self descriptive number solution](https://i.ytimg.com/vi/1GKfEDvhWdY/default.jpg)
![A Colorful Unsolved Problem - Numberphile](https://i.ytimg.com/vi/niaeV_NHh-o/default.jpg)
![Squaring the Circle - Numberphile](https://i.ytimg.com/vi/CMP9a2J4Bqw/default.jpg)
![Zeno's Paradox - Numberphile](https://i.ytimg.com/vi/u7Z9UnWOJNY/default.jpg)
![A Pythagorean Theorem for Pentagons + Einstein's Proof](https://i.ytimg.com/vi/_PyPOXXPIJQ/default.jpg)
![A Video about the Number 10 - Numberphile](https://i.ytimg.com/vi/KZ1BVlURwfI/default.jpg)