Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re^2: Generic De Bruijn Sequenceby QM (Parson) |
on Apr 19, 2017 at 23:07 UTC ( [id://1188339]=note: print w/replies, xml ) | Need Help?? |
De Bruijn is supposed to be cyclic AAACCCBCCACBBCBACABCAABBBABAA Yes. The last $n-1 chars overlap with the beginning. The debug prints show each permutation lined up with the output string, so you can see how the graph is traversed and the output constructed. I could have just used the last char of each permutation, and had a true De Bruijn output, but that didn't suit my needs. I found the Python code, but didn't like it because of the lack of explanation. To understand it, I have to trace code that does a lot of index math, instead of reading comments hinting at an algorithm that makes sense on a higher level. It's not far removed from pointer math and assembler code, so it doesn't seem very Pythonic, as they like to say. If nothing else, my code at least tries to say what it's doing. So the next guy can try to understand it, and not blindly accept it, nor need to walk through on paper to believe that it's correct. -QM
In Section
Cool Uses for Perl
|
|