login
Number of odd terms in each row of the iterates of the Christmas tree pattern map (A367508).
4

%I #17 Dec 29 2023 13:54:46

%S 1,0,2,1,0,3,0,2,0,2,0,4,1,0,3,1,0,3,0,3,0,5,0,2,0,2,0,4,0,2,0,2,0,4,

%T 0,2,0,4,0,4,0,6,1,0,3,1,0,3,0,3,0,5,1,0,3,1,0,3,0,3,0,5,1,0,3,0,3,0,

%U 5,0,3,0,5,0,5,0,7,0,2,0,2,0,4,0,2,0,2,0

%N Number of odd terms in each row of the iterates of the Christmas tree pattern map (A367508).

%C See A367508 for the description of the Christmas tree patterns, references and links.

%H Paolo Xausa, <a href="/A368464/b368464.txt">Table of n, a(n) for n = 1..13494</a> (first 15 orders).

%e The first 4 tree pattern orders are shown below (left), with the corresponding number of odd terms on the right.

%e .

%e Order 1: |

%e 0 1 | 1

%e |

%e Order 2: |

%e 10 | 0

%e 00 01 11 | 2

%e |

%e Order 3: |

%e 100 101 | 1

%e 010 110 | 0

%e 000 001 011 111 | 3

%e |

%e Order 4: |

%e 1010 | 0

%e 1000 1001 1011 | 2

%e 1100 | 0

%e 0100 0101 1101 | 2

%e 0010 0110 1110 | 0

%e 0000 0001 0011 0111 1111 | 4

%e .

%e Apparently, removing the 0 terms from the order i pattern (for i >= 2), gives the row lengths of the order i-1 pattern (cf. A363718).

%t With[{imax=8},Map[Total,Map[Mod[FromDigits[#],2]&,NestList[Map[Delete[{If[Length[#]>1,Map[#<>"0"&,Rest[#]],Nothing],Join[{#[[1]]<>"0"},Map[#<>"1"&,#]]},0]&],{{"0","1"}},imax-1],{3}],{2}]] (* Generates terms up to order 8 *)

%o (Python)

%o from itertools import islice

%o from functools import reduce

%o def uniq(r): return reduce(lambda u, e: u if e in u else u+[e], r, [])

%o def agen(): # generator of terms

%o R = [["0", "1"]]

%o while R:

%o r = R.pop(0)

%o yield sum(1 for b in r if b[-1] == '1')

%o if len(r) > 1: R.append(uniq([r[k]+"0" for k in range(1, len(r))]))

%o R.append(uniq([r[0]+"0", r[0]+"1"] + [r[k]+"1" for k in range(1, len(r))]))

%o print(list(islice(agen(), 88))) # _Michael S. Branicky_, Dec 25 2023

%Y Cf. A363718, A367508, A368463, A368465.

%K nonn

%O 1,3

%A _Paolo Xausa_, Dec 25 2023