Last active
August 29, 2015 14:04
-
-
Save ashaindlin/76ec6e22383233379c67 to your computer and use it in GitHub Desktop.
Thue-Morse sequence generator using horribly inefficient string operations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def thuemorse(n): | |
b = { "0": "1", "1": "0" } | |
s = "0" | |
print "0\t0" | |
for i in range(1, n+1): | |
print "{}\t".format(i), | |
s += ''.join([b[x] for x in s]) | |
print s | |
if __name__ == '__main__': | |
thuemorse(6) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0 0 | |
1 01 | |
2 0110 | |
3 01101001 | |
4 0110100110010110 | |
5 01101001100101101001011001101001 | |
6 0110100110010110100101100110100110010110011010010110100110010110 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment