RosettaCodeData/Task/Thue-Morse/Python/thue-morse-2.py

8 lines
194 B
Python
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
>>> 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]
>>>