Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
9
Task/Thue-Morse/Python/thue-morse-1.py
Normal file
9
Task/Thue-Morse/Python/thue-morse-1.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
m='0'
|
||||
print(m)
|
||||
for i in range(0,6):
|
||||
m0=m
|
||||
m=m.replace('0','a')
|
||||
m=m.replace('1','0')
|
||||
m=m.replace('a','1')
|
||||
m=m0+m
|
||||
print(m)
|
||||
7
Task/Thue-Morse/Python/thue-morse-2.py
Normal file
7
Task/Thue-Morse/Python/thue-morse-2.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
>>> def thue_morse_digits(digits):
|
||||
... return [bin(n).count('1') % 2 for n in range(digits)]
|
||||
...
|
||||
>>> thue_morse_digits(20)
|
||||
[0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1]
|
||||
|
||||
>>>
|
||||
9
Task/Thue-Morse/Python/thue-morse-3.py
Normal file
9
Task/Thue-Morse/Python/thue-morse-3.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
>>> def thue_morse_subs(chars):
|
||||
... ans = '0'
|
||||
... while len(ans) < chars:
|
||||
... ans = ans.replace('0', '0_').replace('1', '10').replace('_', '1')
|
||||
... return ans[:chars]
|
||||
...
|
||||
>>> thue_morse_subs(20)
|
||||
'01101001100101101001'
|
||||
>>>
|
||||
9
Task/Thue-Morse/Python/thue-morse-4.py
Normal file
9
Task/Thue-Morse/Python/thue-morse-4.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
>>> def thue_morse(n):
|
||||
... (v, i) = ('0', '1')
|
||||
... for _ in range(0,n):
|
||||
... (v, i) = (v + i, i + v)
|
||||
... return v
|
||||
...
|
||||
>>> thue_morse(6)
|
||||
'0110100110010110100101100110100110010110011010010110100110010110'
|
||||
>>>
|
||||
Loading…
Add table
Add a link
Reference in a new issue