User Tools

Site Tools


chess:programming:de_bruijn_sequence:about_de_bruijn_sequences

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
chess:programming:de_bruijn_sequence:about_de_bruijn_sequences [2021/10/28 13:56] peterchess:programming:de_bruijn_sequence:about_de_bruijn_sequences [2021/10/28 14:19] (current) – [Chess - Programming - de Bruijn Sequence - About De Bruijn Sequences] peter
Line 27: Line 27:
   * The answer is **Yes**, it is possible to make a non-repeating sequence of numbers that covers every sub-sequence internally, just once.   * The answer is **Yes**, it is possible to make a non-repeating sequence of numbers that covers every sub-sequence internally, just once.
     * This is a de Bruijn Sequence.     * This is a de Bruijn Sequence.
 +
 +  * See [[Chess:Programming:de Bruijn Sequence:About De Bruijn Sequences:The shortest sequence of numbers for the 4-digit PIN|The shortest sequence of numbers for the 4-digit PIN]]
  
 </WRAP> </WRAP>
Line 32: Line 34:
 ---- ----
  
-===== De Bruijn sequences =====+===== De Bruijn sequences; B(k,n) =====
  
 De Bruijn sequences can be described by two parameters: De Bruijn sequences can be described by two parameters:
Line 40: Line 42:
  
 <WRAP info> <WRAP info>
-**NOTE:**  These are typically describe by the representation B(k,n).+**NOTE:**  These are typically describe by the representation **B(k,n)**.
  
-  * The PIN example above, the notation would be B(10,4).+  * The PIN example above, the notation would be **B(10,4)**.
  
 </WRAP> </WRAP>
 +
 +----
 +
 +===== Simple B(2,2) =====
 +
 +A really simple example: B(2,2).
 +
 +  * The dictionary {0,1} will be used for the possible values.
 +
 +To generate a string that contains sub-strings of each possible combination of two digits:
 +
 +{{:chess:programming:de_bruijn_sequence:de_bruijn_sequences_-_b2-2.png?200|}}
 +
 +<code bash>
 +0011
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  
 +
 +  * The first two digits give us 00, 
 +  * The next two 01
 +  * Then 11.
 +  * To get to 10, we need to __Wrap Around__ taking the last digit from the string, and the first digit.
 +    * This could also be accomplished by appending the first character from the string to the end to make 00110.
 +
 +</WRAP>
 +
 +
 +<WRAP info>
 +**NOTE:**  There can be multiple De Bruijn solutions to any problem.
 +
 +<code>
 +distinct solutions = (((k!)^k)^(n-1)) / (k^n)
 +</code>
 +
 +  * Since every adjacent pair of digits in the string is unique, it does not matter what the starting position is.
 +  * As k and n increase, the number of possible solutions grows rapidly.
 +
 +</WRAP>
 +
 +----
 +
 +===== B(2,6) =====
 +
 +Here is a solution for B(2,6):
 +
 +<code>
 +0000001000011000101000111001001011001101001111010101110110111111
 +</code>
 +
 +----
 +
 +===== B(6,2) =====
 +
 +Here is the output for B(6,2):
 +
 +<code bash>
 +001020304051121314152232425334354455
 +</code>
 +
 +<WRAP info>
 +**NOTE:**  The size of the dictionary has been changed here.
 +
 +  * Rather than simple binary k=2, this is increased to k=6 to use possible values {0,1,2,3,4,5}.
 +  * Reading this from left to right shows: 00, 01, 10, 02, 20 … 41, 15 … 33, 34 … 55, 50
 +    * this 50 at the end is comprised of the last 5 and the first 0.
 +
 +</WRAP>
 +
  
 ---- ----
chess/programming/de_bruijn_sequence/about_de_bruijn_sequences.1635429390.txt.gz · Last modified: 2021/10/28 13:56 by peter

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki