RosettaCodeData/Task/Thue-Morse/Python/thue-morse-2.py
2023-07-01 13:44:08 -04:00

7 lines
194 B
Python

>>> 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]
>>>