{"id":188,"date":"2013-01-01T21:38:06","date_gmt":"2013-01-02T05:38:06","guid":{"rendered":"http:\/\/puzzlezapper.com\/blog\/?p=188"},"modified":"2013-01-02T15:12:18","modified_gmt":"2013-01-02T23:12:18","slug":"more-fun-with-binary-words-de-bruijn-sequences","status":"publish","type":"post","link":"https:\/\/puzzlezapper.com\/blog\/2013\/01\/more-fun-with-binary-words-de-bruijn-sequences\/","title":{"rendered":"More Fun with Binary Words: De Bruijn Sequences"},"content":{"rendered":"<p>In the <a href=\"https:\/\/puzzlezapper.com\/blog\/2012\/12\/symmetry-variations-on-binary-words\/\">previous post<\/a>, we explored symmetry variations on binary words in the context of crossed stick puzzles. Now I want to look at some ways to play with <em>sequences<\/em> of these binary words. For reference, I&#8217;ll recap the table of numbers of different binary words of various types and lengths from that post. As before, swapping 1&#8217;s and 0&#8217;s with each other gives equivalent <em>invertible<\/em> words, and turning words backwards gives equivalent <em>reversible<\/em> words. <\/p>\n<p>You&#8217;ll notice some new columns in this version of the table. <em>Cyclic<\/em> words remain equivalent over any number of <i>cyclic shifts<\/i> or moves that take every digit but the last down by one place and put the last into the first place. You can think of the digits as black and white beads on a necklace, where the necklace stays the same however you rotate it. The cyclic property can be combined with invertibility and reversibility; reversing a cyclic word is equivalent to &#8220;flipping over&#8221; the necklace.<\/p>\n<table>\n<tr>\n<td>Length<\/td>\n<td>Fixed<\/td>\n<td>Invertible<\/td>\n<td><a href=\"http:\/\/oeis.org\/A005418\" title=\"Link to Online Encyclopedia of Integer Sequences\">Reversible<\/a><\/td>\n<td>Inv. &#038; Rev.<\/td>\n<td><a href=\"http:\/\/oeis.org\/A000031\" title=\"Link to Online Encyclopedia of Integer Sequences\">Cyclic<\/a><\/td>\n<td><a href=\"http:\/\/oeis.org\/A000013\" title=\"Link to Online Encyclopedia of Integer Sequences\">Cyclic Inv.<\/a><\/td>\n<td><a href=\"http:\/\/oeis.org\/A000029\" title=\"Link to Online Encyclopedia of Integer Sequences\">Cyclic Rev.<\/a><\/td>\n<td><a href=\"http:\/\/oeis.org\/A000011\" title=\"Link to Online Encyclopedia of Integer Sequences\">Cyclic Inv. &#038; Rev.<\/a><\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td>2<\/td>\n<td>1<\/td>\n<td>2<\/td>\n<td>1<\/td>\n<td>2<\/td>\n<td>1<\/td>\n<td>2<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>4<\/td>\n<td>2<\/td>\n<td>3<\/td>\n<td>2<\/td>\n<td>3<\/td>\n<td>2<\/td>\n<td>3<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td>8<\/td>\n<td>4<\/td>\n<td>6<\/td>\n<td>3<\/td>\n<td>4<\/td>\n<td>2<\/td>\n<td>4<\/td>\n<td>2<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td>16<\/td>\n<td>8<\/td>\n<td>10<\/td>\n<td>6<\/td>\n<td>6<\/td>\n<td>4<\/td>\n<td>6<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>5<\/td>\n<td>32<\/td>\n<td>16<\/td>\n<td>20<\/td>\n<td>10<\/td>\n<td>8<\/td>\n<td>4<\/td>\n<td>8<\/td>\n<td>4<\/td>\n<\/tr>\n<tr>\n<td>6<\/td>\n<td>64<\/td>\n<td>32<\/td>\n<td>36<\/td>\n<td>20<\/td>\n<td>14<\/td>\n<td>8<\/td>\n<td>13<\/td>\n<td>8<\/td>\n<\/tr>\n<tr>\n<td>7<\/td>\n<td>128<\/td>\n<td>64<\/td>\n<td>72<\/td>\n<td>36<\/td>\n<td>20<\/td>\n<td>10<\/td>\n<td>18<\/td>\n<td>9<\/td>\n<\/tr>\n<\/table>\n<p>One classic puzzle involving binary words is to find a necklace where every possible word of a given length is present exactly once exactly once as a substring of the necklace. These necklaces are known as De Bruijn sequences. For example, here&#8217;s a De Bruijn sequence of length 4 binary words:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/puzzlezapper.com\/blog\/wp-content\/uploads\/2013\/01\/debruijn-4f.png\" alt=\"\" title=\"De Bruijn sequence for fixed length 4 binary words\" width=\"159\" height=\"159\" class=\"aligncenter size-full wp-image-192\" srcset=\"https:\/\/puzzlezapper.com\/blog\/wp-content\/uploads\/2013\/01\/debruijn-4f.png 159w, https:\/\/puzzlezapper.com\/blog\/wp-content\/uploads\/2013\/01\/debruijn-4f-150x150.png 150w\" sizes=\"auto, (max-width: 159px) 100vw, 159px\" \/><\/p>\n<p>Since we have a bunch of variations on binary words, we can look for De Bruijn sequences of each of them. Neither the cyclic nor the reversible words will make proper De Bruijn sequences. Consider the length 3 word <code>000<\/code>. There can&#8217;t be another 0 on either end of that, because that would make a second instance of <code>000<\/code> in the sequence. So there must be a substring of <code>10001<\/code> in the sequence. But that gives instances of both <code>001<\/code> and <code>100<\/code> which are equivalent to each other both as cyclic and reversible words. The same reasoning applies to longer words. <\/p>\n<p>However, you can make <em>improper<\/em>, non-cyclic De Bruijn sequences. For example, <code>00010111<\/code> is an improper De Bruijn sequence of the reversible length 3 words. For the reversible length 4 words, even an improper De Bruijn sequence is impossible. (Try to make one, if you are wondering why.) Problem <strong>#29<\/strong> is to find an improper De Bruijn sequence for the reversible words of length 5.<\/p>\n<p>The invertible and reversible length 4 words do have an improper De Bruijn sequence: <code>000011010<\/code>. And with plain invertible words, proper cyclic De Bruijn sequences are again possible. Here&#8217;s a De Bruijn sequence of the invertible words of length 4:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/puzzlezapper.com\/blog\/wp-content\/uploads\/2013\/01\/debruijn-4i.png\" alt=\"\" title=\"De Bruin sequence for the invertible words of length 4\" width=\"102\" height=\"102\" class=\"aligncenter size-full wp-image-198\" \/><\/p>\n<p>Problem <strong>#30<\/strong>: Find a De Bruijn sequence of the invertible words of length 5.<\/p>\n<p>Unlike polyform puzzles, De Bruijn sequences are considered a topic for respectable mathematics, which means that they are well studied, and therefore it can be assumed that anything written here is well known by those who know such things. Still, they are fun to think about, and have real world applications. For example, in the study of Sanskrit poetry, a mnemonic based on the nonsense word <em>yam\u0101t\u0101r\u0101jabh\u0101nasalag\u0101<\/em> has been employed. In this word, the syllables correspond to the names of three syllable feet, (like anapests and dactyls in western poetry) and the three syllable segment starting with a given syllable has the same stress pattern as the foot denoted by that name. (The syllables with macrons are stressed and the others are unstressed.) If you truncate the last two syllables, the stress patterns &#8220;wrap around&#8221; to create a proper De Bruijn sequence.<\/p>\n<p>And I still haven&#8217;t gotten to Gray Codes. Well, I&#8217;ll get to that in a later post. Unless I get distracted and never get back to it, which is a real possibility.<\/p>\n<p>(Sources: Wikipedia on <a href=\"http:\/\/en.wikipedia.org\/wiki\/Yamatarajabhanasalagah#A_mnemonic\">Sankrit Prosody<\/a> and <a href=\"http:\/\/en.wikipedia.org\/wiki\/De_Bruijn_sequence\">De Bruijn Sequences<\/a>, and <em>Professor Stewart&#8217;s Cabinet of Mathematical Curiosities<\/em> by Ian Stewart.)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In the previous post, we explored symmetry variations on binary words in the context of crossed stick puzzles. Now I want to look at some ways to play with sequences of these binary words. For reference, I&#8217;ll recap the table of numbers of different binary words of various types and lengths from that post. As &hellip; <a href=\"https:\/\/puzzlezapper.com\/blog\/2013\/01\/more-fun-with-binary-words-de-bruijn-sequences\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">More Fun with Binary Words: De Bruijn Sequences<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[99,102,101,71],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-recreational-mathematics","tag-binary-words","tag-cyclic-sequences","tag-de-bruijn-sequences","tag-symmetry"],"_links":{"self":[{"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/comments?post=188"}],"version-history":[{"count":17,"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":208,"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/posts\/188\/revisions\/208"}],"wp:attachment":[{"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/media?parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/categories?post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/puzzlezapper.com\/blog\/wp-json\/wp\/v2\/tags?post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}